gpt4 book ai didi

java - Ant : What is the simplest way to add version number to built jar?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:29:21 25 4
gpt4 key购买 nike

<?xml version="1.0" encoding="UTF-8"?>
<project name="myPlugin" default="all">
<target name="artifact.myPlugin:jar" depends="init.artifacts, compile.module.myPlugin" description="Build &#39;myPlugin:jar&#39; artifact">
<mkdir dir="${artifact.output.myplugin:jar}" />
<jar destfile="${temp.jar.path.myPlugin.jar}" duplicate="preserve" filesetmanifest="mergewithoutmain">
<zipfileset file="${basedir}/META-INF/MANIFEST.MF" prefix="META-INF" />
<zipfileset dir="${myPlugin.output.dir}" />
</jar>

<!--How would I add a version number to this that reflects my projects version -->
<copy file="${temp.jar.path.myPlugin.jar}" tofile="${artifact.output.myPlugin:jar}/plugin.company.jar" />
</target>

人们这样做的典型方式是什么?

示例(从上面提取)

<copy file="${temp.jar.path.myPlugin.jar}" tofile="${artifact.output.myPlugin:jar}/plugin.company{version}.jar" />

最佳答案

最简单的解决方案是使用 ANT buildnumber任务。

<project name="myPlugin" default="all">

<property name="version" value="1.0"/>

<target...
<buildnumber/>

<jar destfile="/path/to/jar/myjar-${version}.${build.number}.jar" ...
...
</jar>
</target>

</project>

每个构建都会生成一个唯一的版本号:

  • myjar-1.0.0
  • myjar-1.0.1
  • myjar-1.0.2
  • ..

关于java - Ant : What is the simplest way to add version number to built jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14759755/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com