In my Ant build file, I’m using an encrypted property which I’m reading off a text file. I need to decrypt this in sort of a bootstrap target during my build process. How do I do this?
As an example, here are the contents of the files.
myFile.txt:
ENCRYPTED=encryptedtext
build.xml:
<project name="myProject" default="all">
<property file="myFile.txt">
<!--Specify bootstrap target here to perform the decryption task-->
<target name="myTarget">
<!--Use the decrypted property here-->
I get that one way to do this is to setup a target to perform the decryption, and add it as a depends in all the necessary targets. I don’t want to do that. I’m interested in alternatives that make the process as clean as possible. This also means I’ve already considered solutions that go “Why don’t you perform the decryption elsewhere and read it off from there?” and I’m not interested in them.
Thank you.
In my opinion, contrary to your stated goal, I think the cleanest way to setup your requirements is to use the
dependsstructure that ant provides. It was developed for just this purpose.If you want to ensure that this decryption is run every time you run your ant process, and you still want to resist the urge to use the
dependstool, you have the option of putting your decryption process in your ant.bat, before the call to ant proper, or wrap the ant.bat in your own decryptAndCallAnt.bat.