I havent used Maven extensively
Presently have 5 different maven projects , Each has a different pom.xml. As of now there is dependency relationship between them , each one points to other in < dependency > if needed.
Presently the thing we dont like are
- When we release a child projectA , then we need to manually modify all projects having projectA as a dependency to use new version. Saw Maven has a version plugin , not sure how that will help.
- As a solution I want to have a cleaner organization between poms , and possible avoid above issue.
What i thought is ( may be incorrect )
Where fat arrow represents Parent Child relationship and a thin arrow represents sub-module. But this does not seem to be working, see code and errors below
Child Project 2 pom
<groupId>ChildProject2</groupId>
<artifactId>ChildProject2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>Parent</groupId>
<artifactId>Parent</artifactId>
<version>${parent.version}</version>
<relativePath>../Parent/pom.xml</relativePath>
</parent>
<dependencies> ... </dependencies>
ChildProject2 - Error Project build error: Non-resolvable parent POM: Failure to transfer Parent:Parent:pom:${parent.version} from 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. Original error: Could not transfer artifact Parent:Parent:pom:${parent.version} from/to central (http://repo1.maven.org/maven2): Illegal character in path at index 45: http://repo1.maven.org/maven2/Parent/Parent/${parent.version}/Parent-${parent.version}.pom and 'parent.relativePath' points at wrong local POM
Parent pom
<groupId>Parent</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<parent.version>0.0.1-SNAPSHOT</parent.version>
</properties>
<modules>
<module>../ChildProject2</module>
<module>../ChildProject1</module>
</modules>
<dependencies> ... </dependencies>
GrandParent2 pom
<groupId>GrandParent2</groupId>
<artifactId>GrandParent2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<grandparent2.version>0.0.1-SNAPSHOT</grandparent2.version>
</properties>
<modules>
<module>../Parent</module>
</modules>
<dependencies>... </dependencies>
ParentMain.java
public class ParentMain {
public static void main(String[] args) {
DocumentFactory df = new DocumentFactory();
ChildProject1Main cp1 = new ChildProject1Main();
ChildProject2Main cp2 = new ChildProject2Main();
}
}
ParentMain - Errors
- ChildProject1Main cannot be resolved to a type
- ChildProject1Main cannot be resolved to a type
I am currently using Maven Version 2.2.1 (open to upgrading if this can be solved using upgraded maven version) One of the comments below says can solve this using " CI tools out there such as Jenkins and TeamCity" .. any pointer (examples) how to solve this using Maven ( and or Hudson )??
What am i doing wrong , how to get best design for such project dependencies