English 中文(简体)
将档案从仓库中删除的任务
原标题:ant task to remove files from a jar

如何写下从先前汇编的JAR中删除档案的次要任务?

我要说的是,我的联合调查组的档案是:

aaa/bbb/ccc/Class1
aaa/bbb/ccc/Class2
aaa/bbb/def/Class3
aaa/bbb/def/Class4

......和我想到一份没有<代码>aaa.bbb.def包的JAR档案版本,我需要用ant将其删除,因此,我最后要提交一份联合报告,其中载有:

aaa/bbb/ccc/Class1
aaa/bbb/ccc/Class2

感谢!

最佳回答

您是否使用<代码>zipfileset 任务?

<jar destfile="stripped.jar">
  <zipfileset src="full.jar" excludes="files/to/exclude/**/*.file" />
</jar>

Example

<property name="library.dir" value="dist" />
<property name="library.file" value="YourJavaArchive.jar" />
<property name="library.path" value="${library.dir}/${library.file}" />
<property name="library.path.new" value="${library.dir}/new-${library.file}" />

<target name="purge-superfluous">
  <echo>Removing superfluous files from Java archive.</echo>

  <jar destfile="${library.path.new}">
    <zipfileset src="${library.path}" excludes="**/ComicSans.ttf" />
  </jar>

  <delete file="${library.path}" />
  <move file="${library.path.new}" tofile="${library.path}" />
</target>
问题回答

你们必须 un笑。

<unzip src="myjar.jar" dest="/classes/">
<jar destfile="newjar.jar"
    basedir="/classes/"
    includes="**/*"
    excludes="**/def/*"
/>    

对我来说,答案没有多大增加——

<zip destfile="tmp.jar">
  <zipfileset src="src.jar">
    <exclude name="**/*.class" />
  </zipfileset>
</zip>
<move file="tmp.jar" tofile="src.jar" />

这使用单一通行证,给建筑增加太多时间

资料来源:rel=“nofollow noreferer”>http://ant.1045680.n5.nabble.com/Remove-entru- from-ZIP-file-using-ANT-td1353728.html

如果能够提供像关于六氯环己烷的“齐p”这样的“杰尔-书”能够存档程序,那么这项任务可以完成。

<exec executable="zip">
  <arg value="-d" />
  <arg value="myJarCopyToStrip.jar" />
  <arg value="aaa/bbb/def/*" />
  <arg value="aaa/bbb/def" />
</exec>

Subtree deletion depends on the capabilities of the used archiver.
The "os" attribute of the Ant "exec" task allows to use different archivers on different OS s.

我来到这里,希望把ant作为在格拉斯一带的一些短程。

别的人在无选择的情况下也处于同一个船上。

例如:

task antUnzip() << {
  ant.jar(destfile: "stripped.jar") {
    zipfileset(src: "full.jar", excludes: "files/to/exclude/**/*.file") {}
  }
}

我不相信你的要求是否得到直接解决。 我建议将杰尔扩大到一些温室,然后删除不想要的班级档案。 最后,创立了一个新监狱,拥有必要的班级档案。

ache 参考手册:





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签