Are maven's profile-specific dependencies propagated to the published artifact? - maven

I need to publish an artifact twice - each with a different set of dependencies. I'm happy to give the artifacts different ids but would like to use the same pom.xml file. I've attempted this with profile-specific dependencies, but I can't seem to get these dependencies visible as transitive dependencies in the artifacts. Is that possible?
pom1.xml - creates profile-specific builds. The A profile adds a dependency on commons-collections 3.2.2 and profile B depends on 3.2.1.
pom2.xml - simply defines a dependency on pom1's artifact.
src/main/java/tt.java - defines an empty class to provide something to compile by pom1.
mvn version is 3.8.5.
% mvn -f pom1.xml -P A dependency:tree
...
[INFO] org.acme:testing:jar:testing
[INFO] \- commons-collections:commons-collections:jar:3.2.2:compile
...
% mvn -f pom1.xml -P B dependency:tree
...
[INFO] org.acme:testing:jar:testing
[INFO] \- commons-collections:commons-collections:jar:3.2.1:compile
...
% mvn -f pom1.xml -P A clean install
...
% mvn -f pom2.xml dependency:tree
...
[INFO] org.acme:testing2:jar:testing
[INFO] \- org.acme:testing:jar:testing:compile
[INFO] \- commons-collections:commons-collections:jar:3.2.1:compile
It seems to me pom2's dependencies should have been on 3.2.2 from profile A.
Any idea on how I might make the dependencies from profile A transitive to dependent poms?
pom1.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>testing</artifactId>
<version>testing</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>A</id>
<properties>
<profile.name>cuda11.2</profile.name>
</properties>
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>B</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profile.name>cpu</profile.name>
</properties>
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
</profile>
</profiles>
<!-- If I move this dependency out of the profile, then it becomes visible
as a transitive depenency to other projects referencing this pom's artifact.
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
-->
</project>
pom2.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>testing2</artifactId>
<version>testing</version>
<dependencies>
<dependency>
<groupId>org.acme</groupId>
<artifactId>testing</artifactId>
<version>testing</version>
</dependency>
</dependencies>
</project>

Related

Why are duplicate dependencies in dependencyManagement not inherited?

If I add a duplicate dependency in dependencyManagement, which is already managed in parent pom, dependency management only considers this last declaration, anything declared in parent is ignored.
Are there any use-cases not inherit parent dependencyManagement?
In my hypothetical example I have org.jooq:jooq:3.16.9 which depends on io.r2dbc:r2dbc-spi:0.9.0.RELEASE.
Parent POM declares a newer version io.r2dbc:r2dbc-spi:0.9.1.RELEASE. If Child POMs would use jooq they would get 0.9.1.RELEASE of io.r2dbc:r2dbc-spi. This is an expected behavior. So far so good.
If now a Child POM decides to change only the scope and does not provide a version, Maven resolves the version of io.r2dbc:r2dbc-spi to 0.9.0.RELEASE, which is declared by org.jooq:jooq:3.16.9.
(Same behavior with scope and exclusions, even when I import parent instead of inheriting.)
I expected, that Maven would resolve io.r2dbc:r2dbc-spi to 0.9.1.RELEASE since it is declared in parent dependencyManagement.
Duplicate dependencies in dependencyManagement are re-declared and not inherited:
Finally, since d is specified in B's dependency management section, should d be a dependency (or transitive dependency) of a or c, version 1.0 will be chosen - again because dependency management takes precedence over dependency mediation and also because the current POM's declaration takes precedence over its parent's declaration.
POMs
(Actual artifacts are only used for illustration purpose, there might have been other better artifacts ...)
Parent POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>MavenParentTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-spi</artifactId>
<version>0.9.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.16.9</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version> <!-- just to fix plugins version -->
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Child POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>MavenChildTest</artifactId>
<parent>
<groupId>org.example</groupId>
<artifactId>MavenParentTest</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-spi</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
</dependency>
</dependencies>
</project>
Running: mvn dependency:tree -f child/pom.xml leads to following output:
[INFO] --- maven-dependency-plugin:3.3.0:tree (default-cli) # MavenChildTest ---
[INFO] org.example:MavenChildTest:jar:1.0-SNAPSHOT
[INFO] \- org.jooq:jooq:jar:3.16.9:compile
[INFO] +- io.r2dbc:r2dbc-spi:jar:0.9.0.RELEASE:runtime
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.3:runtime
[INFO] \- jakarta.xml.bind:jakarta.xml.bind-api:jar:3.0.0:compile
[INFO] \- com.sun.activation:jakarta.activation:jar:2.0.0:compile

How to skip failsafe execution for pom packaging?

I wanted to configure failsafe with failIfNoTests in a parent pom because we are currently upgrading Spring Boot in our microservices, and tests might not be properly detected if they are still using JUnit 4 (you need to migrate them or use junit-vintage).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>
The problem however is that this causes the plugin to also run in the build of the parent pom. I don’t want to put this in <pluginManagement> because I want to make sure that the plugin is running in child projects (otherwise they still have to declare the plugin and it might be forgotten).
Is there a way to prevent the failsafe plugin from running with pom packaging?
Note that I did the same with surefire, but there is no issue with that one as its goals are managed by Maven’s default lifecycle, which depends on the pom packaging. However for failsafe the goals are declared in spring-boot-starter-parent’s <pluginManagement> so it applies for all packaging types.
For the moment, I did it with a profile based on this question, but I find this quite dirty:
<profile>
<id>disable-integration-tests-for-pom-packaging</id>
<!-- this profile detects that we are not building an artifact, so we shouldn’t run failsafe -->
<activation>
<file>
<!-- can’t rely on ${project.*} for profile activation -->
<missing>${basedir}/src</missing>
</file>
</activation>
<properties>
<skipITs>true</skipITs>
</properties>
</profile>
Full poms
Parent:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- if changed, update spring-boot.version too! -->
<version>2.6.6</version>
<relativePath />
</parent>
<groupId>org.example</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
mvn verify output:
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< org.example:parent >-------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.2:integration-test (default) # parent ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.619 s
[INFO] Finished at: 2022-04-14T14:07:56+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.22.2:integration-test (default) on project parent: No tests to run! -> [Help 1]
microservice pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
<!-- just to be able to build since I can’t actually install the parent -->
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>microservice</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Build should succeed as long as there are integration tests (and of course all of them are succeeding).
If you want a plugin to not run in the parent, but run in the child, you can add something along the following in the <plugins> section of your parent POM:
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<inherited>false</inherited>
<phase>none</phase>
</execution>
</executions>
</plugin>
This is for the maven source plugin, but you can adapt it for the failsafe plugin as well.

Maven - copy all the dependencies of a project and and transitive dependencies

I’m new to maven. (I have searched for hours for the answer but without luck. mvn dependency:copy-dependencies do not solve my problem)
I need to copy all the dependencies of a project (in the form of jars) and if one of my jars depend on another artifact copy that artifact as well.
Example project1 pom.xml:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project1</groupId>
<artifactId> project1.utils</artifactId>
<version>1.0</version>
<name> project1. utils </name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>project2</groupId>
<artifactId>project2.artifact</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifestEntries>
<Build-Number>${buildNumber}</Build-Number>
<Revision>${Revision}</Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
“project1” have a dependency of project2.artifact.jar. When I use “mvn dependency:copy-dependencies”, I get project2.artifact.jar but I do not get project3.artifact.jar that is a dependency of “project2”.
I do not have the pom of project2, but it is installed in my local repository.
How can I get all the dependencies of project 1 including the second jar (“project3.artifact.jar”)?
Pom of project2 would look something like this, but I don't have it when I go to a client. So I install project2.artifact.jar, project3.artifact.jar manually using "mvn install".
Project2 pom.xml:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project2</groupId>
<artifactId>project2.artifact</artifactId>
<version>2.0</version>
<name>project2.artifact</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>project3</groupId>
<artifactId>project3.artifact</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifestEntries>
<Build-Number>${buildNumber}</Build-Number>
<Revision>${Revision}</Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Please use the latest version of dependency plugin:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:copy-dependencies
If not works please check:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:list
copy-dependency goal copies the same artifacts which is resolved and displayed by tree and list goals.
For testing I prepare project3 pom.xml:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project3</groupId>
<artifactId>project3.artifact</artifactId>
<version>3.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
I have such directory structure:
pr1
pom.xml - from question
pr2
pom.xml - from question
pr3
pom.xml - as shown above
Now I do:
cd pr3
mvn clean innstall
cd ../pr2
mvn clean innstall
mvn dependency:tree
dependency:tree output:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # project2.artifact ---
[INFO] project2:project2.artifact:jar:2.0
[INFO] \- project3:project3.artifact:jar:3.0:compile
So project2 depends on project3
next:
cd ../pr1
mvn clean install
mvn dependency:tree
dependency:tree in project1 output:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # project1.utils ---
[INFO] project1:project1.utils:jar:1.0
[INFO] \- project2:project2.artifact:jar:2.0:compile
[INFO] \- project3:project3.artifact:jar:3.0:compile
So it is also ok.
And now copy:
mvn dependency:copy-dependencies
With result:
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) # project1.utils ---
[INFO] Copying project3.artifact-3.0.jar to ...\pr1\target\dependency\project3.artifact-3.0.jar
[INFO] Copying project2.artifact-2.0.jar to ...\pr1\target\dependency\project2.artifact-2.0.jar
If you also want to copy project1 artifact add it to dependency in project1 pom.xml
...
<dependencies>
<dependency>
<groupId>project2</groupId>
<artifactId>project2.artifact</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>project1</groupId>
<artifactId>project1.utils</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
...
Now:
mvn clean dependency:copy-dependencies we have:
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) # project1.utils ---
[INFO] Copying project3.artifact-3.0.jar to ...\pr1\target\dependency\project3.artifact-3.0.jar
[INFO] Copying project2.artifact-2.0.jar to ...\pr1\target\dependency\project2.artifact-2.0.jar
[INFO] Copying project1.utils-1.0.jar to ...\pr1\target\dependency\project1.utils-1.0.jar

How should I configure pom.xml to keep A and B in my private local Maven repo cache while using Maven Central and java.net's Maven repositories?

How should I configure pom.xml to keep A and B in my private local Maven repo cache while using Maven Central and java.net's Maven repositories?
I've got two local private projects, call them A and B, but both depend on a few bug fixes in org.javolution:javolution-core-java:6.1.0-SNAPSHOT, which isn't in Maven Central. Both A and B depend on other artifacts which are in Maven Central. Project B depends on project A.
I'm used to using Maven with the local repository (cache) in ~/.m2 and Central, but it seems like I'm not configuring the project correctly for the java.net repository.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.redacted</groupId>
<artifactId>B</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>B</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.opera.link.api</groupId>
<artifactId>opera-link-client</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.javolution</groupId>
<artifactId>javolution-core-java</artifactId>
<version>6.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Java.net Maven Repository</id>
<url>https://maven.java.net/content/repositories/snapshots/</url>
</repository>
</repositories>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.redacted</groupId>
<artifactId>A</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>A</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.javolution</groupId>
<artifactId>javolution-core-java</artifactId>
<version>6.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Java.net Maven Repository</id>
<url>https://maven.java.net/content/repositories/snapshots/</url>
</repository>
</repositories>
</project>
Removing the <repositories> element from B produces the obvious result:
------------------------------------------------------------------------
Building B 1.0-SNAPSHOT
------------------------------------------------------------------------
The POM for org.javolution:javolution-core-java:jar:6.1.0-SNAPSHOT is missing, no dependency information available
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.547s
Finished at: Wed Jan 29 17:19:48 EST 2014
Final Memory: 3M/15M
------------------------------------------------------------------------
Adding the <repositories> element back in to B gives this on running:
------------------------------------------------------------------------
Building B 1.0-SNAPSHOT
------------------------------------------------------------------------
--- exec-maven-plugin:1.2.1:exec (default-cli) # B ---
java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - package com.redacted.A.posts does not exist
at com.redacted.B.App.<clinit>(App.java:30)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.219s
Finished at: Wed Jan 29 17:50:45 EST 2014
Final Memory: 4M/15M
------------------------------------------------------------------------
As I'm typing this, I'm realizing perhaps this might not be a Maven problem as much as a NetBeans problem. I clicked the "Re-Run Goals" button expecting a clean-and-build (as that's what I last executed), but doing a real clean-and-build seems to compile correctly, while "Re-Run Goals" just makes mvn run the exec goal. Is my pom.xml configured correctly?
Edit: I'm using NetBeans 7.4.
Your first error message means that the javolution-SNAPSHOT couldn't be found. You have to provide a jar with pom in your local repository or buy using the java.net-repository.
The second error message results from running project B by the Exec-Maven-Plugin. The strange message seems a little bit missleading.
I would recommend you:
First put your custom javolution-SNAPSHOT.jar into your local maven repository by using the maven install-goal
If in doubt, which libraries you need from java.net, put the repository location into Project A as well as Project B.
Next install Project A into your local maven repository by using the maven install-goal.
Next install Project B into your local maven repository.

Maven Jboss plugin configuration for a multi-module project having a child module as WAR

I am working on a maven multi-module project having the following folder structure.
+---parent_module
+---module1
+---module2
+---module_web
How do I configure 'jboss-as-maven-plugin' for a local and remote deploy? Note that I want to deploy the child module_web which is the WAR residing inside the parent_module. I ran command 'mvn clean install' and the build completed successfully and the module_web.war file was created.
Then I ran the mvn command 'mvn -e -X package jboss-as:deploy' from parent_module to deploy the WAR to the jboss container, I get the following error.
[INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:deploy
(default-cli) on project markodojo: Could not execute goal deploy on
C:\Mahesh\Git\markodojo\markodojo\target\markodojo_solution-1.0-SNAPSHOT.war.
Reason: I/O Error could not execute operation '{ [ERROR] "address" =>
[], [ERROR] "operation" => "read-attribute", [ERROR] "name" =>
"launch-type" [ERROR] }': java.net.ConnectException: JBAS012144: Could
not connect to remote://localhost:8080. The connection timed out
[ERROR] -> [Help 1]
Below are the snippets from the pom.xml files.
Parent module pom.xml
<groupId>com.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
<module>module_web</module>
</modules>
<properties>
.....
</properties>
<dependencyManagement>
.....
</dependencyManagement>
<build>
<directory>${project.basedir}/target</directory>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<!-- JBoss AS plugin to deploy war -->
<!-- To use, run: mvn package jboss-as:deploy -->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<!-- inherited>true</inherited-->
<configuration>
<jbossHome>C:\folderpath\jboss-as-7.1.1.Final</jbossHome>
<serverName>standalone</serverName>
<hostname>localhost</hostname>
<port>8080</port>
<filename>module_web-1.0-SNAPSHOT.war</filename>
</configuration>
</plugin>
other plugins...
<plugins>
</build>
module1 pom.xml
<parent>
<groupId>com.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module1</artifactId>
<packaging>jar</packaging>
<name>module1</name>
module2 pom.xml
<parent>
<groupId>com.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module2</artifactId>
<packaging>jar</packaging>
<name>module2</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
other dependencies ...
</dependencies>
module_web pom.xml
<parent>
<groupId>com.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module_web</artifactId>
<packaging>war</packaging>
<name>module_web</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module2</artifactId>
<version>${project.version}</version>
</dependency>
other dependencies ...
</dependencies>
Can anyone please let me know what am I doing wrong with the plugin configuration? It would be of great help if you share any tutorial or maven-jboss document which explains the steps to configure the maven-jboss plugin for a multi-module project having a child module as WAR.
Thanks.

Resources