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 .target
file (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:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>targetFilename.target</file>
<type>target</type>
<classifier>targetFilename</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Now in your parent pom you can reference this module in the target-platform-configuration and your child modules will also use it:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<target>
<artifact>
<groupId>org.example</groupId>
<artifactId>target-definition</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>targetFilename</classifier>
</artifact>
</target>
</configuration>
</plugin>
There is also an enhancement request to create packaging type for .target files to help things in future.