Is it possible to use the same .target file for every maven subproject?
Snippet from the parent .pom file
<groupId>root.server</groupId>
<artifactId>root.server</artifactId>
Snippet from child .pom file
<groupId>child.project</groupId>
<artifactId>child.project.parent</artifactId>
<target>
<artifact>
<groupId>root.server</groupId>
<artifactId>root.server</artifactId>
<version>${project.version}</version>
<classifier>targetfile</classifier>
</artifact>
</target>
When I try a “mvn clean install” in the child project I get an exception: Could not resolve target platform specification artifact. When I try a “mvn clean install” in the parent of the child project everything works fine.
Is there a way to reuse one .target file for all projects (parent + subprojects) ?
It is possible and it is the preferred method.
You should create a child module specifically for your
.targetfile (e.g. called target-definition). This should be a project with the pom packaging type. You should also include the following snippet – this is the piece which permits other modules to access the .target file:Now in your parent pom you can reference this module in the target-platform-configuration and your child modules will also use it:
There is also an enhancement request to create packaging type for .target files to help things in future.