有什么方法可以在 netbeans 中为我的应用程序提供版本号。然后在我的代码中访问该版本号。
类似于我们在 .Net 中使用的程序集号。在 java 或 netbeans 中是否有类似的东西...?
定义一个Implementation-Version
在构建时的 Jar 清单中。通常使用某种形式的日期作为版本号。例如。14.07.28
可以使用代码在代码中检索该值。
String version = this.getClass().getPackage().getImplementationVersion();
<tstamp>
<format property="now" pattern="yy.MM.dd"/>
</tstamp>
...
<jar
destfile="build/dist/lib/${jar.name}"
update='true'
index='true' >
<manifest>
<attribute name="Created-By" value="${vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Vendor-Id" value="org.pscode"/>
<!-- This next property is retrieved in code above. -->
<attribute name="Implementation-Version" value="${now}"/>
</manifest>
<fileset dir="build/share">
<include name="${package.name}/*.class" />
<include name="${package.name}/*.png" />
</fileset>
</jar>
这来自我目前打开的项目的构建文件。相关属性是清单部分的最后一个属性。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)