Ste*_*mis 5 svn jar manifest.mf manifest
我看到如何使用maven从subversion获取修订版号的问题?但是有没有任何标准(事实上或其他),在清单中使用的实际字段,版本#和存储库URL(即,显示它在主干上与分支)?我已经看到使用了实现版本,有和没有领先的"r"(用于修订版),我见过Implementation-Build:也用过.
编辑我删除了maven标签,不应该在那里.我的问题是关于罐子的内容,而不是工具本身.
不幸的是,jar 清单本身没有任何版本编号标准。
但实际上,还有另一种标准方法可以自动更新修订号。您可以使用svn:keywords以便在每次提交后获取文件中的当前修订号。有$Revision$
用于修订替换和$HeadURL$
存储库 URL 替换的属性。您只需将以下字符串放入文件中并将该文件置于版本控制之下:
$Revision$ $HeadURL$
Run Code Online (Sandbox Code Playgroud)
如果您使用 Maven 动态创建清单,我建议将以下内容放入version.properties
文件中:
revision=$Revision$
repourl=$HeadURL$
Run Code Online (Sandbox Code Playgroud)
然后包含在pom.xml
语句中(maven 应该启用属性插件):
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>version.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后您就可以将修订号和存储库 URL 添加到清单中:
<manifest>
<attribute name="Revision" value="${revision}" />
<attribute name="Repository URL" value="${repourl}" />
</manifest>
Run Code Online (Sandbox Code Playgroud)
另请注意,您需要显式启用svn:keywords
使用 subversion 属性,以便在文件中获取$Revision$
并替换为实际值。$HeadURL$
如果您决定使用version.properties
,您将需要运行以下命令:
svn propset svn:keywords Revision version.properties
svn propset svn:keywords HeadURL version.properties
Run Code Online (Sandbox Code Playgroud)