Reputation: 549
my whole pom construct follow as:
simple-parent2-|
|-pom.xml
|-simple-model2-|
pom.xml
|-simple-weather2-|
pom.xml
simple-weather2 is depend on simple-model2
so ,the simple-parent2 pom.xml follow as:
<?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>kursk.practice.ch07</groupId>
<artifactId>simple-parent2</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<name>simple-parent2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>simple-model2</module>
<module>simple-weather2</module>
<!--
<module>simple-persist2</module>
<module>simple-webapp2</module>
<module>simple-command2</module>
-->
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
the simple-model2 pom.xml follow as :
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-parent2</artifactId>
<version>1.1</version>
</parent>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-model2</artifactId>
<version>1.1</version>
<packaging>jar</packaging>
<name>simple-model2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
</dependencies>
</project>
the simple-weather2 pom.xml follow as, the simple-model2 is one of dependencies.
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-parent2</artifactId>
<version>1.1</version>
</parent>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-weather2</artifactId>
<version>1.1</version>
<name>simple-weather2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>kursk.practice.ch07</groupId>
<artifactId>simple-model2</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
first, I install simple-model2 ,it's success!
kursk@KURSK-PC /D/CodeSpace/maven/simple-parent2/simple-model2
$ mvn install
.....
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.445s
[INFO] Finished at: Sat Mar 08 16:22:16 CST 2014
[INFO] Final Memory: 8M/122M
[INFO] ------------------------------------------------------------------------
second, I exec denpendency:tree on simple-weather2 folder,but maven report fail to collect simple-model2 and simple-parent2!
kursk@KURSK-PC /D/CodeSpace/maven/simple-parent2/simple-weather2
$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple-weather2 1.1
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.411s
[INFO] Finished at: Sat Mar 08 16:27:19 CST 2014
[INFO] Final Memory: 7M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project simple-weather2: Could not resolve dependencies for project kursk.practice.ch07:simple-weather2:jar:1.1: Failed to collect de
pendencies at kursk.practice.ch07:simple-model2:jar:1.1: Failed to read artifact descriptor for kursk.practice.ch07:simple-model2:jar:1.1: Failure to find kursk.practi
ce.ch07:simple-parent2:pom:1.1 in http://dev.joget.org/archiva/repository/internal/ was cached in the local repository, resolution will not be reattempted until the up
date interval of joget-internal 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
but I can find them in my repository in local repository
kursk@KURSK-PC /C/Users/kursk/.m2/repository/kursk/practice/ch07
$ ls -l
total 0
drwxr-xr-x 4 kursk Administ 0 Mar 8 15:06 simple-model2
drwxr-xr-x 3 kursk Administ 0 Mar 8 15:07 simple-parent2
what's wrong in my steps?why maven can't find internal dependency project?
Upvotes: 0
Views: 1000
Reputation: 549
sorry,it's my fault,I didn't read carafully. now, I see.
I didn't exec "mvn clean install" from simple-parent2 project, so simple-parent2 and simple-model2 jar file didn't locate in local cache.
after exec "mvn clean install" from simple-parent2 project ,exec "mvn dependency:tree" from simple-weather2 project is work!
so,follow text is extracted from 《maven-definitive-guide》
When Maven is executed against a project with submodules, Maven first loads the parent POM and locates all of the submodule POMs. Maven then puts all of these project POMs into something called the Maven Reactor which analyzes the dependencies between modules. The Reactor takes care of ordering components to ensure that interdependent modules are compiled and installed in the proper order.
Note: The Reactor preserves the order of modules as defined in the POM unless changes need to be made. A helpful mental model for this is to picture that modules with dependencies on sibling projects are "pushed down" the list until the dependency ordering is satisfied. On rare occasions, it may be handy to rearrange the module order of your build -- for example if you want a frequently unstable module towards the beginning of the build. 100
Upvotes: 1