Is there a way with Apache Ant to update a jar fil

2019-04-22 20:21发布

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

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

标签: java ant jar
2条回答
劳资没心,怎么记你
2楼-- · 2019-04-22 20:43

You should be able to do this with the Jar Task if you set update to true.

<jar update="true" jarfile="${jarfile}" >
    <!-- ... -->
</jar>
查看更多
Anthone
3楼-- · 2019-04-22 20:44

Sure, that's totally possible. The Ant Jar task can do anything the jar command line can do. You do it with the update flag set to true instead of 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.

EDIT: To set a path

  <jar destfile="/x/y/z/file.jar"
       update="true">
      <zipfileset dir="/a/b/c"/ prefix="x/y/z" />
  </jar>
查看更多
登录 后发表回答