Le 11/09/2011 17:37, Jason Pyeron a écrit :
-----Original Message-----
From: Guillaume Polet
Sent: Sunday, September 11, 2011 4:07
To: Maven Users List
Subject: [maven] Re: Auto building parent and sibling
projects as needed
The problem is that a child does not know where the sources
of its parents are located,
Is it not the point of<relativePath>../pom.xml</relativePath>?
No, this simply indicates where to look relatively to find a pom.xml if
it is not installed in your local repository (or a remote one where it
could be fetched from).
and therefore it is completely
unable to trigger its build. You probably have set up one or
more parent aggregator projects and you mapped this hierarchy
onto the file/directory structure but this is not mandatory
at all. You can very well use a parent just to define the
default version to use for dependencies, or the default
target of the compiler, other properties that are common
through all your projects and many more things.
You should probably read again the first two paragraphs here:
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project
_Inheritance_vs_Project_Aggregation
Read that before and again. See the bottom of the email and attachment (the
poms).
The first one explains the benefits of inheritance while the
second explain the aggregation.
Hope this helps you clear things out.
Still stuck at the same place, but thanks for confirming what I read.
Cheers,
Guillaume
Le 11/09/2011 06:21, Jason Pyeron a écrit :
I am trying to understand why maven's reactor would not add
a parent
and a parent's children to the build when it is detected that the
dependency is not in the repository.
Is there a use case to NOT auto build? Or is there a
technical hurdle
to overcome to accomplish this in the reactor design?
Could I be missing a concept on maven usage?
I have a project which has a very large set of parent/child/sibling
dependencies I am migrating from our ant build system. When an
engineer needs to make changes on their part it would be
best for them
to execute mvn from that parts directory.
Hard to say why your second build is failing. I just tried a similar
setup and it worked in all cases:
parent:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<name>parent</name>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>B</module>
<module>A</module>
</modules>
</project>
A:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>A</artifactId>
<name>A</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
B:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>B</artifactId>
<name>B</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>A</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
With the directory hierarchy:
* parent
* A
* B
and the results from the build:
D:\tmp\parent>mvn package
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] A
[INFO] B
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building parent 1.0.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building A 1.0.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building B 1.0.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.003s]
[INFO] A ................................................. SUCCESS [0.001s]
[INFO] B ................................................. SUCCESS [0.002s]
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 0.111s
[INFO] Finished at: Mon Sep 12 08:49:47 CEST 2011
[INFO] Final Memory: 2M/121M
[INFO]
------------------------------------------------------------------------
D:\tmp\parent>cd B
D:\tmp\parent\B>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building B 1.0.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 0.094s
[INFO] Finished at: Mon Sep 12 08:49:57 CEST 2011
[INFO] Final Memory: 2M/121M
[INFO]
------------------------------------------------------------------------
D:\tmp\parent\B>
Your log says the following:
--> cannot find the pom.xml from project A (This I don't understand why)
--> jar file of project A cannot be found
Try 'mvn install' so that the pom and the jar file is deployed locally
because it will not find the jar in the target directory.
Cheers,
Guillaume
jpyeron@black /projects/cascade/trunk/tmp/test
$ mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] A
[INFO] B
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building A 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ A ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Documents and Settings\All
Users\Desktop\projects\cascade\trunk\tmp\test\A\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ A ---
[INFO] No sources to compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building B 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ B ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Documents and Settings\All
Users\Desktop\projects\cascade\trunk\tmp\test\B\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ B ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.000s]
[INFO] A ................................................. SUCCESS [0.719s]
[INFO] B ................................................. SUCCESS [0.047s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.891s
[INFO] Finished at: Sun Sep 11 11:33:49 EDT 2011
[INFO] Final Memory: 3M/121M
[INFO] ------------------------------------------------------------------------
jpyeron@black /projects/cascade/trunk/tmp/test
$ cd B
jpyeron@black /projects/cascade/trunk/tmp/test/B
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building B 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for us.pdinc.foo.maven.test:A:jar:1.0.0 is missing, no
dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.234s
[INFO] Finished at: Sun Sep 11 11:34:03 EDT 2011
[INFO] Final Memory: 2M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project B: Could not resolve dependencies for
project us.pdinc.foo.maven.test:B:jar:1.0.0: Failure to find
us.pdinc.foo.maven.test:A:jar:1.0.0 in http://repo1.maven.org/maven2 was cached
in the local repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced -> [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
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- -
- Jason Pyeron PD Inc. http://www.pdinc.us -
- Principal Consultant 10 West 24th Street #100 -
- +1 (443) 269-1555 x333 Baltimore, Maryland 21218 -
- -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]