1
votes

Using ANT, I'm trying to create a zip file for my build for an update to a released version. To get the list of changed files (this includes .jar files with version strings embedded in the file name), I've done the following:

  1. Copy the base set of files to a temp location with the version strings stripped out of the file names. I.e. foo_1.0.0.jar -> foo.jar
  2. Copy the updated set of files to a temp location with the version strings stripped out of the file names. I.e. foo_1.0.1.jar -> foo.jar
  3. Create a fileset using the "different" selector to compare the two directories with version numbers removed.

I now want to create a fileset that contains the changed files from step 3, but with the full file names from the original updated set. So the fileset I seek would find that foo.jar has changed, and include "foo_1.0.1.jar".

However, I'm struggling to figure out how to match the diff'ed fileset up with the real file set including version numbers. How would one do this in ANT?

1
Not clear to me why you're going to such effort. I focus on being able to reproduce any release from source code (using tagging). I also couple this approach with a binary artifact repository (Nexus) to keep a copy of the actual binaries I've released in the past. I'm guessing you're trying to manage incremental change in the released binaries. My advise is don't. Manage change in the source code instead, better tooling!Mark O'Connor
We release our code in two versions: plain zips and using an actual installer. This is needed for creating a plain zip of a set of fixes we're sending to customers, and it needs to be as small as possible. :) Totally agree on managing change in the source code, but for now I've got to work within the existing process.Mark Guertin

1 Answers

0
votes

And I found how to do this, (as Mark pointed out) somewhat complicated issue. My issue was not using the right base for creating the file set. To do so, I did the following.

"update.offering" = Location of the updated code "${temp.dir}/diffFiles" = Location I copied the files found to have changed from the base version, minus version strings in the file name

<copy todir="${temp.dir}/outFiles" includeemptydirs="false">
        <fileset dir="${update.offering}" id="final.set">
            <present present="both" targetdir="${temp.dir}/diffFiles">
                <firstmatchmapper>
                    <regexpmapper from="(.*)(_[0-9]\..*)(\..*)" to="\1\3"/>
                    <mapper type="glob" from="*.*" to="*.*"/>
                    <mapper type="glob" from="*" to="*"/>
                </firstmatchmapper>
            </present>
        </fileset>
    </copy>

What I needed to do was use the location of the updated files as the basis for the new fileset, then match the files in the target directory using a regular expression mapper that allowed me to match the file name excluding the version string. I've also included two glob mappers to make sure I got files without a version string in the name that were different.