How to use the same target platform for multiple subprojects in Tycho

Is it possible to use the same .target file for each maven subproject?

Snippet from parent .pom file

<groupId>root.server</groupId> <artifactId>root.server</artifactId> 

A fragment from a .pom file for children

 <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 to run "mvn clean install" in a child project, I get an exception: Could not resolve target platform specification artifact . When I try to run "mvn clean install" on the parent of the child project, everything works fine.

Is there a way to reuse a single .target file for all projects (parent + subprojects)?

+4
source share
1 answer

This is possible and this is the preferred method.

You must create a child module specifically for your .target file (for example, called the target definition). This should be a project with a pom packaging type. You should also include the following snippet: this is the part that allows 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 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 a request for creating a packaging type for .target files to help in the future.

+10
source

All Articles