1
votes

ANT beginner here. I have a package called Neo, and in its build.xml I'm having a problem. While unzipping the Neo jar into this expanded directory,

<unzip src="${output.dir}/Scala2.11/Neo.jar" dest="${standalone.jar.expanded.jars.dir}"/>

there is a file in the expanded directory called "targetFile" that gets overwritten during the above mentioned unzip step by another file named "targetFile" that exists in the Neo.jar under the path

src/services/targetFile

I need to make sure that this "targetFile" in the Neo.jar doesn't overwrite the "targetFile" that already exists in the expanded directory, but instead concatenates itself to the already-existing "targetFile". This is my approach so far:

<unzip src="${output.dir}/Scala2.11/Neo.jar" dest="${standalone.jar.expanded.jars.dir}">
  <patternset>
    <include name="src/services/targetFile"/>
  </patternset>
</unzip>

Once I've matched the file from patternset, how, syntactically, would I use ANT's Concat task when I don't know the path that "targetFile" exists in the expanded directory beforehand? Actually, looking at this again makes me think that now only "targetFile" will be unzipped due to the patternset, but essentially I need to unzip everything and just do something special for one of the files I'm unzipping.

1
How are these dependency jar files unzipped? Is that something you do explicitly in your build.xml? - VGR
Yes, the current ANT task I'm trying to do with the unzip/concatenation depends on a target that unzips these dependency jar files. - Trock Fuller
Updated my question to be more clear. - Trock Fuller

1 Answers

1
votes

You’ll need to exclude the src/services/targetFile entry when unzipping each .jar file, then separately concat that entry from each archive:

<unzip src="${output.dir}/Scala2.11/Neo.jar" dest="${standalone.jar.expanded.jars.dir}">
    <patternset excludes="src/services/targetFile"/>
</unzip>
<unzip src="path/to/lib01.jar" dest="${standalone.jar.expanded.jars.dir}">
    <patternset excludes="src/services/targetFile"/>
</unzip>
<unzip src="path/to/lib02.jar" dest="${standalone.jar.expanded.jars.dir}">
    <patternset excludes="src/services/targetFile"/>
</unzip>
<unzip src="path/to/lib03.jar" dest="${standalone.jar.expanded.jars.dir}">
    <patternset excludes="src/services/targetFile"/>
</unzip>
<unzip src="path/to/lib04.jar" dest="${standalone.jar.expanded.jars.dir}">
    <patternset excludes="src/services/targetFile"/>
</unzip>

<concat destfile="${standalone.jar.expanded.jars.dir}/src/services/targetFile">
    <zipentry zipfile="${output.dir}/Scala2.11/Neo.jar" name="src/services/targetFile"/>
    <zipentry zipfile="path/to/lib01.jar" name="src/services/targetFile"/>
    <zipentry zipfile="path/to/lib02.jar" name="src/services/targetFile"/>
    <zipentry zipfile="path/to/lib03.jar" name="src/services/targetFile"/>
    <zipentry zipfile="path/to/lib04.jar" name="src/services/targetFile"/>
</concat>