In my maven eclipse project I see Maven dependency and Referenced Libraries. In some cases they have the same set of jars referring to M2_REPO. And in some they are entirely different. Leaves me confused as to why there are 2 different jar references in the same project.
Maven dependencies are added in pom file to a project. When you build the project, maven dependencies that you have added in pom file will be downloaded from the M2 repository.
Reference libraries are added manually for projects in Eclipse IDE.
When you leave confusing for those jar files, just add all libraries as maven dependencies.
Classes in both Referenced Libraries and Maven Dependencies are visible in Eclipse but Maven build can see only dependencies from pom. If you try to build the project with maven it may fail because of this
Related
I have a Maven web project that depends on other projects that build WAR targets, and then uses the other web projects as overlays. All of these projects are part of a single parent project, imported into Eclipse as a Maven project.
The main web project's POM has dependencies and overlays with maven-war-plugin defined for the other modules.
My problem
in Eclipse, for some reason, when I update the Eclipse project from the Maven project, some of the modules are recognized as coming from other Eclipse projects, and others are expected to come from my Maven repository.
On closer inspection org.eclipse.wst.common.component shows a difference in the dependent-module for some modules.
<dependent-module ... handle="module:/overlay/prj/module1" />
vs.
<dependent-module ... handle="module:/overlay/var/M2_REPO/group/id/module2" />
Why would some modules be recognized differently than others?
Both are equally included as dependencies and overlays in the POM.
My workaround has been to edit this file by hand to get Eclipse to recognize that it should use the other Eclipse project directly (module:/overlay/prj) rather than look to the Maven repo.
I have my own java library created as maven project and has some dependencies included in pom.xml
I want to export project as jar and include it into others maven projects.
The problem is that I need to copy all dependencies from pom.xml of my library into maven projects where is imported my library to make it to work.
How to export my library to not be necessary to copy dependencies of my library.
That is easy to do; the central feature of Maven is that it manages the project dependencies for you.
You need to mvn install your project from the command line; that will install the jar and the pom files to your local repository.
You can then include your library as a Maven dependency in other Maven based projects; Maven will resolve the (transitive) dependencies for your project.
Normally you don't need to list all the dependencies in the project that imports your library. Maven should fetch them for you. What you need to do is to declare dependencies in your library.
Make sure you declare correct types of dependencies. Here is more info. In your case you need to make sure that dependencies you want to copy to the downstream projects are marked as 'compile'
There are tools that make 'Fat' jars by copying all dependencies inside. But they are mostly used to build the final project such as a deployable WAR file or a desktop app. Not in case of the libraries
I went through this link to import a gradle project as dependency into another gradle project. Is there a way to include a maven project as dependency into a gradle project?
If that Maven project is built somewhere else and deployed to a Maven repository, you can specify the artifact it produces as a simple compile dependency. If this Maven project is somehow a subproject of a Gradle multi-project build, I suppose you could hack it to work by simply ignoring the Maven POM file and perhaps adding a build.gradle to that project.
To use the solution described on the link that you provided - both projects must be gradle and included in gradle settings. Therefore you can use project closure to compile and depend on the project without building it explicitly.
I am not aware of any way to do this with maven project. I understand you use some maven plugins that you dont want to rewrite in gradle as simply can not find any equivalents etc. Often had that problem.
In this scenario I would suggest to build maven project and depend on a built jar in your gradle project.
Otherwise you could probably amend sourcesets in your gradle project to include maven classes. But I think it would be to complicated.
If I would be you I would turn it into gradle and try to replicate what you had using maven or just build the artifact and depend on it in dependencies closure.
Gradle is not that new anymore and there are many plugins that are superseding old good maven stuff.
I have a Maven project with 100's of dependencies. Some of these dependencies are not available.
When I run mvn install against the parent pom file (this parent pom references the other projects) then I receive errors that some Maven dependencies cannot be found. But I have to add those dependencies before I can discover what other dependencies may be missing.
Is there a Maven command which will list of the missing dependencies for a project ?
Update :
Another options is to clear out repository folder and attempt to rebuild with Eclipse/Maven plugin - missing dependencies for all projects appear to be listed in problems tab
Maven shows you all dependencies that are missing in the first tier. It's impossible to show also traversing dependencies because without poms included in those dependencies, Maven has no information about further dependencies. So only solution in that situation is to add all missing dependencies (absolutely with pom files) and then re-run maven (install or just mvn dependency:resolve)
I have a maven module for validation which I must pass to a old version of Eclipse which has the Jrules API within. However there is not a maven plugin for this eclipse IDE. So I figured I would do a maven:install on the module and move over the created jar.
However when I try to import->Existing Projects into Workspace->Select archive file:
and point it to the jar no projects appear. I'm at a loss as to how I can move my maven module to the outdated eclipse, without having to grab the 101 jars required for the project and non mavenise it...
Surely their has to be an easy way to this or is maven will monolithic
Use the maven-eclipse-plugin to generate the .project and .classpath files for you:
mvn eclipse:eclipse
This will create the IDE metadata files which reference all of the JARs your project depends on from within your local maven repository folder.
Attempting to import the JAR that is built by the Maven build process into Eclipse using the " import->Existing Projects into Workspace->Select archive file" doesn't work because Eclipse expects to find a .zip/.jar file with the .project metadata files and the source code. Your compiled JAR likely contains neither.
I would recommend using the M2Eclipse maven plugin. Right click the project -> Enable Dependency Management -> Update Project Configuration
I have used eclipse:eclipse extensively and my experience is that M2Eclipse is not only better supported but works better overall.