I am probably missing something but how is the maven ear plugin (I'm using version 2.5) resolving ejbModule dependencies? I have the following structure:
my-parent (multimodule)
-- pom.xml
-- myEar
-----pom.xml
---myEjb
-----pom.xml
In the ear I have the dependency to myEjb.
2 things that are unexpected when i execute mvn package under myEar
It does not build (package) myEjb.
It does try to resolve the depedency to myEjb via repository, which is in our case our custom sonar repository that we configured in settings.xml. I would like not to have to install myEjb to our custom sonar respository in a separate step.
What I expected from the plugin would be: check the ejbModules dependencies, build and package them if not done or something changed, copy the jar to the target directory of the ear project and package the whole thing correctly.
Obviously I am missing something though, anybody can enlighten me?
Based on your structure you have to build from the root of your project which means you have to change to my-parent directory
my-parent (multimodule)
-- pom.xml
-- myEar
-----pom.xml
---myEjb
-----pom.xml
and do
mvn clean package
The behaviour you described that maven tries to solve the dependencies against your local repository is the usual process. You can do partialy building a single module within a multi-module build but in your case this won't work cause you depend on your myEjb which neeeds to be rebuilded. Otherwise you can do a
mvn install
first and after that you can do from the root:
mvn -pl myEjb clean test
which will only build the myEjb module and uses the dependencies from the repository (localy in this case).
Related
I have child project with some dependencies. When I upload this jar to nexus it's ok.
But when I use this jar in my webapplication and I use mvn clean install -U command. Maven create a war, but the child project dependencies isn't in the war lib folder.
What is the problem?
Check with mvn dependency:tree on the project. Often, the problem is a wrong scope. Make sure the dependencies all have scope compile.
I have a Java Maven project where I have some dependencies defined in the pom.xml file. Recently I decided to move from Junit to TestNG so I deleted the Junit dependency from my pom.xml and added the TestNG one.
I was expecting to see the Junit jar library disappear from the Maven Dependencies folder as a part of the process but that didn't happen. I can still see the jar file in the dependencies folder and it is still being used by my test cases.
I can see TestNG jar is there as well but it's not being used. I can change it manually of course but that wasn't my intention.
Am I doing something wrong are there any additional steps that I missed that will allow me to remove the old dependency?
The following applies for the global .m2 folder where maven dependencies can be downloaded and is common to your maven projects.
the .m2 folder will not clean by itself as those dependencies could be used in another project so its wrong assumption that replacing a dependency in a a pom file will automatically remove from your repo.
you can look at the depedency plugin and run the following
mvn dependency:purge-local-repository
or
mvn dependency:purge-local-repository -DreResolve=false
I have an EAR project, defined very similarly as the reference project of WildFly. In addition to that, I have another JAR project JarProject
which is included in:
parent's pom.xml (as a <module> and in its <dependencyManagement>)
the EjbProject's pom.xml (with the scope provided)
the EarProject's pom.xml (with the default scope, compile)
The problem is that when executing mvn eclipse:eclipse or mvn wildfly:deploy (from the parent project) it fails with the error
[ERROR] Failed to execute goal on project EjbProject: Could not resolve dependencies for project groupId:EjbProject:jar:0.0.4-SNAPSHOT: Could not find artifact groupId:JarProject:jar:0.0.4-SNAPSHOT -> [Help 1]
It somehow looks the JarProject in the local repository, and does not see it in the parent project.
Very important note: mvn package works without problems, as mvn package wildfly:deploy or mvn package eclipse:eclipse do, but without pacakgeing before eclipse:eclipse, it fails.
Maven version: 3.0.4 and 3.3.3
I'm not sure I got the question. Hope this will help...
Goals "eclipse:eclipse" and "wildfly:deploy" do not trigger building of your projects. To use a project as a dependency it needs to be built from the parent pom or installed in you repository.
When you do mvn package eclipse:eclipse the package triggers the build of the JarProject.
If you want do be able to do only mvn eclipse:eclipse then you need to perform a mvn install on your JarProject first.
I have successfully imported a parent pom with child modules into IntelliJ. The child modules have dependencies between themselves and IntelliJ has correctly set up the classpaths so that changes to module A are reflected in module B. However these dependencies are not maintained when I execute a maven goal in IntelliJ (compile, jetty:run etc). Here is my structure:
client_libs
-- servlet-filter
-- filter-example
filter-example depends on servlet-filter. However when I run maven compile on filter-example I get:
The POM for com.cloudseal.client:servlet-filter:jar:1.0-SNAPSHOT is missing, no dependency information available
I can work around this by manually installing servlet-filter into my local repo before I execute a maven goal but obviously this is not ideal. How can I get IntelliJ to maintain the relationships between the modules when I execute a maven goal?
You shall be able to just run mvn package but from place/path where your parent pom is.
If this's not working for you, please post your pom.xml files.
there
I met a weird problem. I have a multi-modules enterprise project that is built in Maven. I setup the project hierarchy like this
parentPom
--MyEar (packaging ear)
--MyUtilJar (packaging jar)
--MyEJB (packing ejb)
--MyWeb (packaging war)
In the MyEJB project, the pom.xml actually binds the apt plugin to the generate-sources phase to generate some java codes. MyEJB depends on MyUtilJar project.
My problem is that when I execute the mvn clean compile, everything works fine. But if I execute mvn clean generate-sources instead, it throws error, complaining it cannot resolve dependency for artifact mygroup:MyUtilJar:jar:1.0.
How can I solve this issue?
In order for the generate-sources to work, you need to have all dependencies in a repository - your local one or a remote one. Just having the dependency in a folder near where it's needed won't work.
Try building and installing the until to put it in your local repository then running the generate-sources.