I’m looking for the most declarative / idiomatic / elegant way to achieve the following:
I have a directory of source files that contains (among others) some XML files with tokens to replace. I also have a set of property files which contain the values for these tokens, each file in a different language. I need to generate a zip archive per language (with the language in the archive and base directory name) of the said source directory, where the XML files have the tokens replaced by the values of one property file.
The property files themselves are also generated during the build, by one single generation task. Ideally that dependency should be inferred by task input/output.
Do you have any ideas on what would be the best way to set up the necessary archive tasks, which all have the same configuration pattern? The set of languages rarely changes, but it looks a bit smelly to list them explicitly in the build. But listing the property files can only be done in execution phase, as the build generates them. OTOH I can’t see a way to not have a task per destination archive, and AFAIK tasks can’t be added in execution phase.
Also, the property file would be an input to the archive task, but of course not as archive content. I should be able to register it directly with the task’s ‘TaskInput’ object, using the ‘file()’ method , right? Or would that interfere with the way the archive/copy tasks use it’s input objects? Would it be better to subclass the Zip task and define a specific property (which would be a code smell as well, as it would make it difficult to change the archive format).
In case it makes any difference: the copy filter itself is a closure which uses a custom class, as the ant filters don’t work for the token format.
I know how to implement such a task in general, this question is really about finding the way that’s easiest to comprehend and maintain in a long-term project build.
Thanks for any advice / ideas.