[
https://issues.apache.org/jira/browse/MNG-6066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15380941#comment-15380941
]
Karl Heinz Marbaise commented on MNG-6066:
------------------------------------------
After I have taken a look at your example I have the following:
First you have defined the properties:
{code:xml}
<properties>
<!-- developers generate x.y.0-SNAPSHOT -->
<revision>${build}${sha1}</revision>
<build>0-SNAPSHOT</build>
<sha1/>
</properties>
{code}
Several times in your poms. In the parent and in {{sub-module-1}} and
{{sub-module-2}} which is bad and violation of DRY paradigm. You should define
those properties only once in your parent cause they will be inherited.
Furthermore to build only parts of a whole reactor you should never go into the
appropriate sub folder. You should simply use the following from the root of
your project instead:
{code}
mvn -pl sub-module-2/child-2-1 clean compile
{code}
Here is an excerpt from the {{mvn --help}} output:
{quote}
\-pl,\-\-projects <arg> Comma-delimited list of specified
reactor projects to build instead of all projects. A project can be
specified by [groupId]:artifactId or by its relative path.
{quote}
If you do the above you will see a build failure cause this module has a
dependency to {{child-1-2}} and {{child-1-2}} has a dependency to
{{child-1-1}}. But the given option has selected to build only a single module
without the needed dependencies.
To handle this you should use the {{\-\-also-make}}
{quote}
-am,--also-make If project list is specified, also
build projects required by the
list
-amd,--also-make-dependents If project list is specified, also
build projects that depend on
projects on the list
{quote}
So in consequence you need to give the following:
{code}
mvn -pl sub-module-2/child-2-1 clean compile -am
{code}
And this will become a successful build.
If you go into a sub folder Maven can't construct the whole reactor which
comprises in your cases of the appropriate modules and order the reactor to
calculate the correct build order to solve the dependencies between the modules
correctly.
> Continuous Delivery friendly versions break with multi-module projects
> ----------------------------------------------------------------------
>
> Key: MNG-6066
> URL: https://issues.apache.org/jira/browse/MNG-6066
> Project: Maven
> Issue Type: Bug
> Affects Versions: 3.3.9
> Reporter: G. Richard Bellamy
>
> When I have a multi-module maven project, and one of the sub-modules is a
> mult-module POM itself, the use of a continuous delivery friendly version in
> the parent <version/> breaks the build from within either {{sub-module-1}}
> or {{sub-module-2}}.
> Some Maven multi-module project like so:
> {noformat}
> parent
> + sub-module 1
> | + child 1-1
> | |
> | + child 1-2
> |
> + sub-module 2
> + child 2-1
> {noformat}
> In the example build below, I've set Maven to offline mode - this happens
> when online as well. Specifically, the problem is that Maven is looking for a
> parent POM with the version set to {{1.${revision\}}}, which is incorrect.
> I believe the problem stems from the fact that the value stored in the
> {{<parent/>}} includes the property, which isn't correctly parsed.
> {code}
> 2016-07-16 12:49:59
> rbellamy@terraspark i ~/Development/test-cd-ci-friendly-versions master % mvn
> -o -DskipTests compile
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Build Order:
> [INFO]
> [INFO] child-1-1
> [INFO] child-1-2
> [INFO] sub-module-1
> [INFO] child-2-1
> [INFO] sub-module-2
> [INFO] test-cd-ci-friendly-versions
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-1-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> child-1-1 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child-1-1 ---
> [INFO] Changes detected - recompiling the module!
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e.
> build is platform dependent!
> [INFO] Compiling 1 source file to
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-1/target/classes
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-1-2 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> child-1-2 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child-1-2 ---
> [INFO] Changes detected - recompiling the module!
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e.
> build is platform dependent!
> [INFO] Compiling 1 source file to
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-2/target/classes
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building sub-module-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-2-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> child-2-1 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child-2-1 ---
> [INFO] Changes detected - recompiling the module!
> [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e.
> build is platform dependent!
> [INFO] Compiling 1 source file to
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-2/child-2-1/target/classes
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building sub-module-2 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building test-cd-ci-friendly-versions 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Summary:
> [INFO]
> [INFO] child-1-1 .......................................... SUCCESS [ 0.756
> s]
> [INFO] child-1-2 .......................................... SUCCESS [ 0.111
> s]
> [INFO] sub-module-1 ....................................... SUCCESS [ 0.000
> s]
> [INFO] child-2-1 .......................................... SUCCESS [ 0.045
> s]
> [INFO] sub-module-2 ....................................... SUCCESS [ 0.001
> s]
> [INFO] test-cd-ci-friendly-versions ....................... SUCCESS [ 0.000
> s]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1.030 s
> [INFO] Finished at: 2016-07-16T12:50:08-07:00
> [INFO] Final Memory: 16M/305M
> [INFO]
> ------------------------------------------------------------------------
> 2016-07-16 12:50:08
> rbellamy@terraspark i ~/Development/test-cd-ci-friendly-versions master % cd
> sub-module-2
> 2016-07-16 12:50:23
> rbellamy@terraspark i ~/Development/test-cd-ci-friendly-versions/sub-module-2
> master % mvn -o -DskipTests compile
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Build Order:
> [INFO]
> [INFO] child-2-1
> [INFO] sub-module-2
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-2-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Summary:
> [INFO]
> [INFO] child-2-1 .......................................... FAILURE [ 0.091
> s]
> [INFO] sub-module-2 ....................................... SKIPPED
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 0.180 s
> [INFO] Finished at: 2016-07-16T12:50:29-07:00
> [INFO] Final Memory: 8M/309M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal on project child-2-1: Could not resolve
> dependencies for project com.terradatum:child-2-1:jar:1.0-SNAPSHOT: Failed to
> collect dependencies at com.terradatum:child-1-2:jar:1.0-SNAPSHOT: Failed to
> read artifact descriptor for com.terradatum:child-1-2:jar:1.0-SNAPSHOT:
> Cannot access nexus (https://nexus.terradatum.com/content/groups/public) in
> offline mode and the artifact com.terradatum:sub-module-1:pom:1.${revision}
> has not been downloaded from it before. -> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace of the errors, re-run Maven with the -e
> switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR]
> [ERROR] For more information about the errors and possible solutions, please
> read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
> zsh: exit 1 mvn -o -DskipTests compile
> {code}
> And here's a run with a top-level online install, followed by an attempt to
> build {{sub-module-2}}...
> {code}
> 2016-07-16 12:57:39
> rbellamy@terraspark i ~/Development/test-cd-ci-friendly-versions master % mvn
> -DskipTests install
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Build Order:
> [INFO]
> [INFO] child-1-1
> [INFO] child-1-2
> [INFO] sub-module-1
> [INFO] child-2-1
> [INFO] sub-module-2
> [INFO] test-cd-ci-friendly-versions
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-1-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> child-1-1 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child-1-1 ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @
> child-1-1 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-1/src/test/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
> child-1-1 ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ child-1-1 ---
> [INFO] Tests are skipped.
> [INFO]
> [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child-1-1 ---
> [INFO] Building jar:
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-1/target/child-1-1-1.0-SNAPSHOT.jar
> [INFO]
> [INFO] --- maven-install-plugin:2.4:install (default-install) @ child-1-1 ---
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-1/target/child-1-1-1.0-SNAPSHOT.jar
> to
> /Users/rbellamy/.m2/repository/com/terradatum/child-1-1/1.0-SNAPSHOT/child-1-1-1.0-SNAPSHOT.jar
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-1/pom.xml
> to
> /Users/rbellamy/.m2/repository/com/terradatum/child-1-1/1.0-SNAPSHOT/child-1-1-1.0-SNAPSHOT.pom
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-1-2 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> child-1-2 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child-1-2 ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @
> child-1-2 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-2/src/test/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
> child-1-2 ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ child-1-2 ---
> [INFO] Tests are skipped.
> [INFO]
> [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child-1-2 ---
> [INFO] Building jar:
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-2/target/child-1-2-1.0-SNAPSHOT.jar
> [INFO]
> [INFO] --- maven-install-plugin:2.4:install (default-install) @ child-1-2 ---
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-2/target/child-1-2-1.0-SNAPSHOT.jar
> to
> /Users/rbellamy/.m2/repository/com/terradatum/child-1-2/1.0-SNAPSHOT/child-1-2-1.0-SNAPSHOT.jar
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/child-1-2/pom.xml
> to
> /Users/rbellamy/.m2/repository/com/terradatum/child-1-2/1.0-SNAPSHOT/child-1-2-1.0-SNAPSHOT.pom
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building sub-module-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-install-plugin:2.4:install (default-install) @ sub-module-1
> ---
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-1/pom.xml
> to
> /Users/rbellamy/.m2/repository/com/terradatum/sub-module-1/1.0-SNAPSHOT/sub-module-1-1.0-SNAPSHOT.pom
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-2-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> child-2-1 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child-2-1 ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @
> child-2-1 ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-2/child-2-1/src/test/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
> child-2-1 ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ child-2-1 ---
> [INFO] Tests are skipped.
> [INFO]
> [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child-2-1 ---
> [INFO] Building jar:
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-2/child-2-1/target/child-2-1-1.0-SNAPSHOT.jar
> [INFO]
> [INFO] --- maven-install-plugin:2.4:install (default-install) @ child-2-1 ---
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-2/child-2-1/target/child-2-1-1.0-SNAPSHOT.jar
> to
> /Users/rbellamy/.m2/repository/com/terradatum/child-2-1/1.0-SNAPSHOT/child-2-1-1.0-SNAPSHOT.jar
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-2/child-2-1/pom.xml
> to
> /Users/rbellamy/.m2/repository/com/terradatum/child-2-1/1.0-SNAPSHOT/child-2-1-1.0-SNAPSHOT.pom
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building sub-module-2 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-install-plugin:2.4:install (default-install) @ sub-module-2
> ---
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/sub-module-2/pom.xml
> to
> /Users/rbellamy/.m2/repository/com/terradatum/sub-module-2/1.0-SNAPSHOT/sub-module-2-1.0-SNAPSHOT.pom
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building test-cd-ci-friendly-versions 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-install-plugin:2.4:install (default-install) @
> test-cd-ci-friendly-versions ---
> [INFO] Installing
> /Users/rbellamy/Development/test-cd-ci-friendly-versions/pom.xml to
> /Users/rbellamy/.m2/repository/com/terradatum/test-cd-ci-friendly-versions/1.0-SNAPSHOT/test-cd-ci-friendly-versions-1.0-SNAPSHOT.pom
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Summary:
> [INFO]
> [INFO] child-1-1 .......................................... SUCCESS [ 0.783
> s]
> [INFO] child-1-2 .......................................... SUCCESS [ 0.032
> s]
> [INFO] sub-module-1 ....................................... SUCCESS [ 0.004
> s]
> [INFO] child-2-1 .......................................... SUCCESS [ 0.025
> s]
> [INFO] sub-module-2 ....................................... SUCCESS [ 0.005
> s]
> [INFO] test-cd-ci-friendly-versions ....................... SUCCESS [ 0.004
> s]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 0.968 s
> [INFO] Finished at: 2016-07-16T13:03:55-07:00
> [INFO] Final Memory: 12M/309M
> [INFO]
> ------------------------------------------------------------------------
> 2016-07-16 13:03:55
> rbellamy@terraspark i ~/Development/test-cd-ci-friendly-versions master % cd
> sub-module-2
> 2016-07-16 13:04:00
> rbellamy@terraspark i ~/Development/test-cd-ci-friendly-versions/sub-module-2
> master % mvn -DskipTests compile
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Build Order:
> [INFO]
> [INFO] child-2-1
> [INFO] sub-module-2
> [INFO]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building child-2-1 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> Downloading:
> https://nexus.terradatum.com/content/groups/public/com/terradatum/sub-module-1/1.$%7Brevision%7D/sub-module-1-1.$%7Brevision%7D.pom
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Summary:
> [INFO]
> [INFO] child-2-1 .......................................... FAILURE [ 0.644
> s]
> [INFO] sub-module-2 ....................................... SKIPPED
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 0.733 s
> [INFO] Finished at: 2016-07-16T13:04:08-07:00
> [INFO] Final Memory: 14M/309M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal on project child-2-1: Could not resolve
> dependencies for project com.terradatum:child-2-1:jar:1.0-SNAPSHOT: Failed to
> collect dependencies at com.terradatum:child-1-2:jar:1.0-SNAPSHOT: Failed to
> read artifact descriptor for com.terradatum:child-1-2:jar:1.0-SNAPSHOT: Could
> not find artifact com.terradatum:sub-module-1:pom:1.${revision} in nexus
> (https://nexus.terradatum.com/content/groups/public) -> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace of the errors, re-run Maven with the -e
> switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR]
> [ERROR] For more information about the errors and possible solutions, please
> read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
> zsh: exit 1 mvn -DskipTests compile
> {code}
> Link to reproduction to be added shortly.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)