使用Maven和mavenbundleplugin在JAR清单中添加SVN修订版时出现java错误
我正在尝试在我的项目清单中添加SVN修订号。为此,我使用Maven build number插件并在超级POM中添加了以下几行:
<!-- Gets the SVN revision number -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
</plugin>
<!-- Add the SVN revision number in the manifest (works on Hudson only) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
</plugin>
请注意配置:
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
我这样做是有意的,因为如果我有本地修改,“doCheck”将阻止我编译(我想在提交工作之前编译和测试)
“doUpdate”对我来说也是个问题,因为我不一定要从存储库更新代码。与上述原因相同,我希望在提交(并可能解决冲突)之前进行本地测试
我的问题是,在清单中,出现的是:
Implementation-Build: ${buildNumber}
因此,不解释变量。我错过了什么
谢谢
编辑: 事实上,问题在于maven bundle插件。我在projets中使用它来生成OSGi包
因此,项目的POM包装为:
<packaging>bundle</packaging>
而不是:
<packaging>jar</packaging>
我想这会扰乱Maven的生命周期。 当我删除maven bundle插件时,一切正常。但我不能删除它,因为我的应用程序是OSGi应用程序
# 1 楼答案
不要使用配置/归档,而是尝试使用配置/说明添加${buildNumber},如下所示:
有了你的方法和Maven 2,一切都成功了。我们切换到Maven 3,Maven bundle插件不满意(与您的行为相同)。这种方法奏效了
# 2 楼答案
你可以利用Maven Plugin Management
在超级pom中的
<pluginManagement/>
下添加插件定义,如下所示:然后,在您想要使用这些现在配置好的插件的项目中,您将以下内容添加到poms中:
那会帮你解决的
# 3 楼答案
问题是混合使用maven bundle插件和maven jar插件来操作jar清单
解决方案是:
在超级POM中:
就这样