ANT:将版本号添加到构建的 jar 的最简单方法是什么? [英] ANT : What is the simplest way to add version number to built jar?

查看:23
本文介绍了ANT:将版本号添加到构建的 jar 的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?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>

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

What is the typcial way that people do this?

示例(从上方拉出)

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

推荐答案

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

The simplest solution is to use the ANT buildnumber task.

<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>

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

Each build will generate a unique release number:

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

这篇关于ANT:将版本号添加到构建的 jar 的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆