Maven Tycho: Not a valid OSGi version
Asked Answered
A

3

12

in my project I'm trying to export a Eclipse RCP application using Maven/Tycho.

All the plugins (and the product it-self) use the following version pattern when in "SNAPSHOT" release configuration:

OSGI: x.y.z.qualifier
MVN:  x.y.z-SNAPSHOT

the delivery will use the following pattern

OSGI: x.y.z.vyyyyMMddHHmm
MVN:  x.y.z-vyyyyMMddHHmm

As you can notice, there is only a difference between "-" and "."

For RCP Plugins I had to disable the checking that tycho performs to validate the version, by using the following maven plugin

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-packaging-plugin</artifactId>
            <version>0.22.0</version>
            <configuration>
                <strictVersions>false</strictVersions>
            </configuration>
        </plugin>
    </plugins>
</build>

So far, everything is fine.

When it comes the product of the RCP application, I have the following pom.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>XXXXXX.user-interfaces</groupId>
        <artifactId>user-interfaces-parent-pom</artifactId>
        <version>0.2.0-v201505041341</version>
        <relativePath>../../poms/parent-pom</relativePath>
    </parent>


    <artifactId>XXXXXX.product</artifactId>
    <name>XXXXXX.product</name>
    <packaging>eclipse-repository</packaging>

    <!-- Make OSGi happy -->
    <!-- version>0.2.0.v201505041341</version-->

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-director-plugin</artifactId>
                <version>${tycho.version}</version>
                <executions>
                    <execution>
                        <id>create-product-distributions</id>
                        <goals>
                            <goal>materialize-products</goal>
                            <goal>archive-products</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

The parent pom.xml just defines a couple of more things like the P2 repository and the tycho-maven-plugin build step.

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

The problem When I compile snapshot, everything works fine, but as soon as I change the SNAPSHOT with the TIMESTAMP as explained above, Maven Tycho complains giving me the following stack-trace:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.22.0:build-qualifier-aggregator (default-build-qualifier-aggregator) on project XXXXXX.product: Not a valid OSGi version 0.2.0-v201505041341 for project MavenProject: XXXXX.user-interfaces:XXXXXX.product:0.2.0-v201505041341 @ /local/XXXXX/pom.xml -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.22.0:build-qualifier-aggregator (default-build-qualifier-aggregator) on project XXXXXX.product: Not a valid OSGi version 0.2.0-v201505041341 for project MavenProject: XXXXXX.user-interfaces:XXXXXX.product:0.2.0-v201505041341 @ /local/XXXXXXX/pom.xml
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Not a valid OSGi version 0.2.0-v201505041341 for project MavenProject: XXXXXXX.user-interfaces:XXXXXX.product:0.2.0-v201505041341 @ /local/XXXXXX/pom.xml
    at org.eclipse.tycho.buildversion.BuildQualifierMojo.getParsedOSGiVersion(BuildQualifierMojo.java:177)
    at org.eclipse.tycho.buildversion.BuildQualifierMojo.calculateQualifiedVersion(BuildQualifierMojo.java:143)
    at org.eclipse.tycho.buildversion.BuildQualifierMojo.execute(BuildQualifierMojo.java:134)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more

I had a look at the source code and I have noticed that Tycho tries to get the version from the Maven artifact, instead that from the product file itself.

The only way to make it work is to remove the comment in the pom.xml

<!-- Make OSGi happy -->
<version>0.2.0.v201505041341</version>

Is there a way to make Tycho working with the "-" instead of the "." or telling it to get the version from somewhere else?

Thanks

Axon answered 4/5, 2015 at 15:55 Comment(4)
I gave up building eclipse plugins with tyco and started to use a pure OSGI-build for my eclipse plugins. This worked well for building and releasing.Alveraalverez
@ChristianKuetbach what do you mean for a "pure OSGI-build"? have you used maven as well?Axon
Yes, but not with tyco. I was not able to use the maven release plugin and tyco at the same time, because during the release phase there was the wrong combination of versions (maven used the released version and tycho still the SNAPSHOT)Alveraalverez
Do you have any example somewhere?Axon
R
5

Tycho supports '-' only for SNAPSHOT recognition to OSGI qualifier, in other case it should be in x.x.x.x format.

You can use use set-version maven goal https://eclipse.org/tycho/sitedocs/tycho-release/tycho-versions-plugin/set-version-mojo.html to setup OSGI version before release.

For example, You use predefined 1.0.0-SNAPSHOT (1.0.0.qualifier) version for development and before release You need invoke mvn tycho-versions:set-version -DnewVersion=1.0.2.qualifier or mvn tycho-versions:set-version -DnewVersion=1.0.2.v123456

It will modify your sources, after that You can build product with updated version by mvn package

Roberson answered 14/5, 2015 at 15:42 Comment(1)
Hi, thank you for this input. Unfortunately it works but putting the "." instead of the "-". It's weird that in SNAPSHOT/qualifier tycho digests the "-" and not during the release.Axon
A
0

You can create an OSGI bundle with the maven-bundle-plugin.

My application uses a lot of plugins, but I think the demo will show how it works:

http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html

Pro: It works really well with maven

Con: It is a maven first way. You will need to setup import and exporting packages within maven and then recreate the MANIFEST.MF

Alveraalverez answered 15/5, 2015 at 11:10 Comment(0)
C
0

there is no workaround to make Tycho working with the "-" instead of the "." ?

Edited:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-p2-plugin</artifactId>
  <version>${parent.tycho.version}</version>
  <executions>
   <execution>
   <!-- Do not attach metadata before the source-feature execution -->
   <id>default-p2-metadata-default</id>
   <configuration>
    <attachP2Metadata>false</attachP2Metadata>
   </configuration>
  </execution>
 </executions>
</plugin>
Conto answered 28/4, 2021 at 12:11 Comment(1)
Not that I'm aware ofAxon

© 2022 - 2024 — McMap. All rights reserved.