We're optimizing our Maven configuration (from previously using ant) and I've just read the Maven by Example book from Sonatype. Duplicating configurations has gotten us in trouble in the past, so I absolutely want to avoid even the tiniest bit of this.
The above book mentions to use the built-in project.groupId and project.version properties from a parent module when referring to the other sibling submodules as dependencies:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>model</artifactId>
<version>${project.version}</version>
</dependency>
That works great, I love it. But this doesn't work in the tag of the submodule pom.xml's:
<parent>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<relativePath>../pom.xml</relativePath>
</parent>
I guess not a big deal, seems like I can create properties for these, but with many modules I'd really like to fully understand the best practices for these kinds of issues..
UPDATE The best way so far it seems to do this is the following. A bit ugly, but eliminates duplicate hard-coded values. parent pom.xml:
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<packaging>pom</packaging>
<version>${version}</version>
<properties>
<groupId>com.mycompany</groupId>
<artifactId>mycompany</artifactId>
<version>1.0</version>
</properties>
child pom.xml:
<parent>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>child</artifactId>