Maven Tycho:不是有效的OSGI版本



在我的项目中,我正在尝试使用maven/tycho导出eclipse rcp应用程序。

所有插件(和产品IT-seft)在"快照"发行配置中使用以下版本模式:

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

交货将使用以下模式

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

您会注意到," - "one_answers"之间只有区别。

对于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>

到目前为止,一切都很好。

当它是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>

parent pom.xml只是定义了其他几件事,例如P2存储库和Tycho-Maven-Plugin构建步骤。

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

问题当我编译快照时,一切都很好,但是一旦我用上述时间戳更改快照,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

我看了源代码,我注意到Tycho试图从Maven Artifact获取版本,而是从产品文件本身中获取版本。

使它起作用的唯一方法是删除pom.xml中的评论

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

是否有一种方法使Tycho与" - "而不是"。或告诉它从其他地方获取版本?

谢谢

tycho支持' - '仅用于快照识别到OSGI预选赛,在其他情况下,它应该以x.x.x.x.x格式。

您可以使用set-version MAVEN目标https://eclipse.org/tycho/sititedocs/tycho-release/tycho-versions-plugin/set-version-version-version-version-mojo.html在释放之前设置OSGI版本。

例如,您使用预定义的1.0.0-snapshot(1.0.0.qualifier)版本进行开发,并且在发布之前,您需要调用 mvn tycho-versions:set-version -DnewVersion=1.0.2.qualifier或者 mvn tycho-versions:set-version -DnewVersion=1.0.2.v123456

它将修改您的资源,之后您可以通过mvn package

构建使用更新版本的产品

您可以使用maven-bundle-plugin创建一个OSGI捆绑包。

我的应用程序使用了很多插件,但是我认为演示将显示其工作原理:

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

pro:它与Maven

非常好

con:这是一种首先的方法。您将需要在Maven中设置和导出软件包,然后重新创建清单。mf

没有解决方法可以使Tycho与" - "合作。而不是"。?

编辑:

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

最新更新