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