java Apache Ant 有没有办法在构建后更新 jar 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2721888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:30:53  来源:igfitidea点击:

Is there a way with Apache Ant to update a jar file after it's been built?

javaantjar

提问by justkt

Is there a way to update a jar file in Ant?

有没有办法在 Ant 中更新 jar 文件?

EDIT: For example, if I wanted to add some additional files to an already existing JAR file?

编辑:例如,如果我想向已经存在的 JAR 文件添加一些额外的文件?

回答by justkt

Sure, that's totally possible. The Ant Jar taskcan do anything the jarcommand line can do. You do it with the updateflag set to true instead of false.

当然,这完全有可能。Ant Jar 任务可以执行jar命令行可以执行的任何操作。您可以将update标志设置为 true 而不是 false。

  <jar destfile="/x/y/z/file.jar"
       basedir="/a/b/c/"
       update="true"
  />

Where the destination jar is already in existence at that path.

目标 jar 已经存在于该路径中。

EDIT: To set a path

编辑:设置路径

  <jar destfile="/x/y/z/file.jar"
       update="true">
      <zipfileset dir="/a/b/c"/ prefix="x/y/z" />
  </jar>

回答by C. Ross

You should be able to do this with the Jar Taskif you set updateto true.

你应该能够做到这一点与jar任务,如果你设置updatetrue

<jar update="true" jarfile="${jarfile}" >
    <!-- ... -->
</jar>