Search code examples
tycho

How To Build Child Modules In Tycho


I have a multi-module Tycho build with a target definition file. The target definition is defined in it's own project (ID: org.acme.project.target, packaging type: pom) like this:

<build>
    <plugins>
        <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>platform_rcp.target</file>
                                <type>target</type>
                                <classifier>platform_rcp</classifier>
                            </artifact>
                        </artifacts>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

And the Maven parent refers to this target platform like this:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <configuration>
        <resolver>p2</resolver>
        <target>
            <artifact>
                <groupId>${project.groupId}</groupId>
                <artifactId>org.acme.project.target</artifactId>
                <version>${project.version}</version>
                <classifier>platform_rcp</classifier>
            </artifact>
        </target>
    </configuration>
</plugin>

This setup works as long as I build the parent project. When I build one of the child modules, even if this project duplicates the reference to the target platform OR even when I build the parent with mvn install -pl org.acme.project I get the following exception:

[ERROR] Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact myGroup:org.acme.project.target:target:platform_rcp:2.3.0-SNAPSHOT -> [Help 1]
 org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact myGroup:org.acme.project.target:target:platform_rcp:2.3.0-SNAPSHOT
 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121)
 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
 at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:483)

Even the Tycho example doesn't work for me, but brings the same error message (Could not resolve target platform specification artifact example.group:mars:target:1.0.0-SNAPSHOT).

I thought this question was similar, but my setup is exactly what is said to work in the answer.

What did I do wrong?

(The actual problem in question is that Eclipse Mars can't run integration tests, so I can only use Tycho to run them, which needs a long time when Tycho builds all modules.)


Solution

  • even when I build the parent with mvn install -pl org.acme.project I get the following exception:

    Have you tried prepending the target platform project to the list of -pl arguments: mvn install -pl :mars,org.acme.project

    I use this all the time.