Maven - reactors (aggregation)
I have a maven project with the following directory structure:
trunk
| pom.xml
| coreutils
| | pom.xml
| | src
| budgetCap
| | pom.xml
| | src
Trunk / pom.xml content:
<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
hxttp://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Ant2Maven</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Parent Pom</name>
<modules>
<module>coreutils</module>
<module>budgetCap</module>
</modules>
In this structure, "budgetCap" depends on "coreutils", i.e. pom.xml "budgetCap" contains a dependency on "coreutils"
Now I have two methods to create this project
First method Aggregation using a reactor
I will be inside trunk
So first of all I am doing mvn clean
shakim:trunk shakim.md$ mvn clean
Maven removes the target folder of the two modules in the following order:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] coreutils
[INFO] budgetCap Maven Webapp
[INFO] Parent Pom
Now when I do mvn install
shakim:trunk shakim.md$ mvn install
Maven starts creating modules in the following order:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] coreutils
[INFO] budgetCap Maven Webapp
[INFO] Parent Pom
In this order, coreutils is successfully installed into the local repository. But budgetCap crashes on compilation giving an error that maven cannot find the class that coreutils should have created
the error message looks like this:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building budgetCap Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ budgetCap ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ budgetCap ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 65 source files to /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING]/Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/SingletonAggregator.java: /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/SingletonAggregator.java uses unchecked or unsafe operations.
[WARNING]/Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/SingletonAggregator.java: Recompile with -Xlint:unchecked for details.
[INFO] 2 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/BudgetCapServer.java:[41,34] package com.adiquity.request.utils does not exist
[ERROR] /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/utils/Utils.java:[9,34] package com.adiquity.request.utils does not exist
[ERROR] /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/log/data/parser/ConversionParser.java:[16,34] package com.adiquity.request.utils does not exist
In short, this package com.adiquity.request.utils is actually present in coreutils , which should successfully find this budgetCap module , but it is not.
Method two
Go inside coreutils and do
shakim:coreutils shakim.md$ mvn clean install
Go inside budgetCap and do
shakim:budgetCap shakim.md$ mvn clean install
budgetCap compiles successfully without reporting any errors.
My question is I want to use Reactors in Maven and I can't figure out why the build doesn't work using the 1st method whereas the 2nd build method completes smoothly ??
I'm not sure how to use reactors, we need to include anything in the pom of coreutils and budgetCap meaning the pom of trunk is the parent.
Note. I don't want to use inheritance in this project
source to share
No one has answered this question yet
Check out similar questions: