Search code examples
eclipsemaventycho

Performing substitutions in Eclipse product configuration file with tycho


I have a Eclipse RCP product which I build with Tycho. After some smaller issues, this is working pretty fine and I have both CI and releases as wanted.

The product in question is provided both as an installable stand-alone RCP application and as an update site so the functionality can be installed in a vanilla Eclipse installation. This works fine as well.

The product have a main feature - which is used on the update site - and I would very much like the feature and the product to have the same version number. As it is today, this version number is mentioned is many places and I would really like to reduce this to just one. I currently have the version number in

  • the feature.xml of the main feature
  • the pom.xml of the same feature
  • the .product file for the product configuration file
  • the pom.xml of the project with the .product file
  • the categories.xml file of the update site
  • the about.mappings file

I have tried to use maven resource filters and that works for the POM files and about.mappings, but not for the rest. This is my current pom.xml for the main feature:

<?xml version="1.0" encoding="UTF-8"?>
<project ...>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>...main.feature</artifactId>
    <version>${product.version}-SNAPSHOT</version>
    <packaging>eclipse-feature</packaging>

    <parent>
        <groupId>...</groupId>
        <artifactId>...parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../...parent</relativePath>
    </parent>

    <build>
        <!-- Substitutions: product.version -->
        <resources>
            <resource>
                <directory>.</directory>
                <includes>
                    <include>feature.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>

When running this configuration, I get the following exception from Tycho (or an exception that looks very similar to it):

[ERROR] Internal error: java.lang.IllegalArgumentException -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.IllegalArgumentException
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
Caused by: java.lang.IllegalArgumentException
        at org.eclipse.equinox.internal.p2.metadata.VersionParser.parse(VersionParser.java:93)
        at org.eclipse.equinox.p2.metadata.Version.create(Version.java:79)
        at org.eclipse.tycho.p2.impl.publisher.FeatureDependenciesAction.getVersion(FeatureDependenciesAction.java:126)
        at org.eclipse.tycho.p2.impl.publisher.AbstractDependenciesAction.perform(AbstractDependenciesAction.java:79)
        ... 11 more

(I have cut some lines...)

Basically, the embedded maven process seems to not perform the resource filtering at all for this type of packaging. Or??

I have tried many different things, but I cannot get it to work. My best guess is that I have to configure the lifecycle, but how...

Can anybody help me with this?


Solution

  • this is a known bug:

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=362252