I created my project with structure same as in next snippet of code.
|-- modP
| |-- pom.xml
| |-- src
| | |-- main
| | `-- java
| | `-- com
| | `-- myorg
| | `-- myapp
| | `-- modP
| | `-- AppP.java
|-- modC1
| |-- pom.xml
| |-- src
| | |-- main
| | `-- java
| | `-- com
| | `-- myorg
| | `-- myapp
| | `-- modC
| | `-- AppM.java
|-- modC2
| |-- pom.xml
| |-- src
|-- main
`-- java
`-- com
`-- myorg
`-- myapp
`-- modC2
`-- AppN.java
My pom.xml for modP is:
<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>com.myorg.myapp</groupId>
<artifactId>modP</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>modP</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
My pom.xml for C1 is :
<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">
<parent>
<artifactId>modP</artifactId>
<groupId>com.myorg.myapp</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>.../modP/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myorg.myapp</groupId>
<artifactId>modC1</artifactId>
<packaging>jar</packaging>
<name>modC1</name>
<url>http://maven.apache.org</url>
</project>
And pom.xml for C2 is:
<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">
<parent>
<artifactId>modP</artifactId>
<groupId>com.myorg.myapp</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>.../modP/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myorg.myapp</groupId>
<artifactId>modC2</artifactId>
<packaging>jar</packaging>
<name>modC2</name>
<url>http://maven.apache.org</url>
</project>
My question is can I using such configuration reference AppP.java from ModP in AppC1.java and AppC2.java in ModC1 and ModC2.
I tried this and it looks like this doesn’t works. Did I misunderstood meaning of parent tag in pom.xml? What I need to do in maven for such function?
I read a lot of documentation, but now I’m even more confused than before reading. 🙁
Every answer will be highly appreciated.
Thanks
Since ModP is a pom (packaging) project, it should not contain any Java code.