Is there a way to apply a patch file before including a file in an archiving task?

I have an archiving task which selects a file like this:

into(‘META-INF’) {

from ‘deployment’, {

include ‘applicationContext.xml’

rename { fn -> 'jboss-spring.xml" }

}

}

Before this file is included in the archive, I’d like to apply a patch file to it, ideally something like this:

into(‘META-INF’) {

from ‘deployment’, {

include ‘applicationContext.xml’

rename { fn -> ‘jboss-spring.xml’ }

patch ‘local/applicationContext.xml.patch’

}

}

This, of course, doesn’t work - but what I want it to do is to apply the patch found in /local/applicationContext.xml.patch to the included file before putting it in the archive.

I could manually copy the input file to a temp location, apply the patch file to the copy (using ant.patch or something else) and then include the patched copy instead, but I’m wondering if there’s a “better” (shorter and more idiomatic) way of doing this.

After experimenting for a while with manual copying etc, I’ve also found that ant.patch seems to rely on svn for applying the patch. This is unfortunate - we use git in this project, and it seems silly to require all developers to install a second versioning system just to be able to apply patch files…

Nevermind - this was a misunderstanding on my part. Ant, and therefore Gradle using ant.patch, relies on the “patch” cmd utility, which can be installed on Windows from e.g. GnuWin32. I was misled because even though it works from the command line, I’m having problems getting it to work from Eclipse: http://stackoverflow.com/questions/17067581/ant-from-within-eclipse-cant-find-executable-even-though-its-in-my-path