[英]Version number in .java and ant script
我正在使用Eclipse开发Java 1.4(无法升级)应用程序。 应用程序版本号放在我的类公共字符串之一中,并且必须在启动时记录。 生成后事件运行ant脚本,该脚本压缩已编译的项目并将文件复制到网络上可供其他人使用的位置。
效果很好,但现在我想做得更好。 我想将zip文件放在包含版本号的目录中。 在哪里最好保留版本号以使其可用于ant和java应用程序?
将版本号放在Ant build.xml
。 这可以通过Ant jar任务完成 ,如下所示:
<jar destfile="build/main/checksites.jar">
<fileset dir="build/main/classes" />
<manifest>
<attribute name="Implementation-Title" value="The name of the project" />
<attribute name="Implementation-Version" value="2.2.3" />
</manifest>
</jar>
有关MANIFEST.MF
键/值的详细信息 ,请参阅设置程序包版本信息 。
在下面的示例中,将project.version
作为项目属性给出,然后在Ant jar任务中使用该属性:
<property name="project.version">2.2.3</property>
<jar destfile="build/main/checksites.jar">
<fileset dir="build/main/classes" />
<manifest>
<attribute name="Implementation-Title" value="The name of the project" />
<attribute name="Implementation-Version" value="${project.version}" />
</manifest>
</jar>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.