Maven Tycho:不是一个有效的OSGi版本

时间:2023-01-12 13:58:08

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

在我的项目中,我尝试使用Maven/Tycho导出一个Eclipse RCP应用程序。

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

对于RCP插件,我必须通过使用以下maven插件禁用tycho执行的检查来验证版本

<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

当涉及到RCP应用程序的产品时,我有以下pom。xml文件

<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.

父砰的一声。xml仅仅定义了更多的东西,比如P2存储库和tycho-maven-plugin构建步骤。

<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:

当我编译快照时,所有的问题都很正常,但是当我使用TIMESTAMP修改快照时,Maven Tycho抱怨给我以下的堆栈跟踪:

[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.

我查看了源代码,注意到Tycho试图从Maven工件获得版本,而不是从产品文件本身获得版本。

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

使其工作的唯一方法是删除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

谢谢

2 个解决方案

#1


4  

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

Tycho只支持对OSGI限定符的快照识别,在其他情况下,它应该在x.x.x. x中。x格式。

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.

您可以使用set-version maven目标https://eclipse.org/tycho/sitedocs/tycho-release/tycho-versions-plugin/set-version-mojo.html在发布之前设置OSGI版本。

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

例如,您使用预定义的1.0.0快照(1.0.0.qualifier)版本进行开发,在发布之前,您需要调用mvn tycho版本:set-version -DnewVersion=1.0.2。限定符或mvn版本:set-version -DnewVersion=1.0.2.v123456

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

它将修改您的源代码,之后您可以使用mvn包构建更新的版本的产品

#2


0  

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

您可以使用maven-bundl -plugin创建一个OSGI包。

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

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

Pro: It works really well with maven

教授:它和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

弊:这是一个maven的第一种方式。您将需要在maven中设置导入和导出包,然后重新创建MANIFEST.MF

#1


4  

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

Tycho只支持对OSGI限定符的快照识别,在其他情况下,它应该在x.x.x. x中。x格式。

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.

您可以使用set-version maven目标https://eclipse.org/tycho/sitedocs/tycho-release/tycho-versions-plugin/set-version-mojo.html在发布之前设置OSGI版本。

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

例如,您使用预定义的1.0.0快照(1.0.0.qualifier)版本进行开发,在发布之前,您需要调用mvn tycho版本:set-version -DnewVersion=1.0.2。限定符或mvn版本:set-version -DnewVersion=1.0.2.v123456

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

它将修改您的源代码,之后您可以使用mvn包构建更新的版本的产品

#2


0  

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

您可以使用maven-bundl -plugin创建一个OSGI包。

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

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

Pro: It works really well with maven

教授:它和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

弊:这是一个maven的第一种方式。您将需要在maven中设置导入和导出包,然后重新创建MANIFEST.MF