0

Is there a way of doing the same task as in this question's answer

Ant unzip/unwar with the same directory name as the file name

but for multiple .war files, without using ant-contrib? I need to extract the binaries for a number of .war files that are built on another server and copied to the machine running ant, so that I can run findbugs on them. The reasons are obscure and political, and I have no control over them, but one thing I am not able to do is use ant-contrib. I have no control over the server running ant, and have to get many approvals to ask for software to be installed.

I understand that this code will build a file set, but assumes only one file will be found and extracts the first name in the set. Is there a non-ant-contrib way of iterating over the set, or possibly modifying the names in the set and passing that to a "mkdir" type command? I would still need to access each .war file name to pass to "unwar". I am an Ant beginner, but have programmed other scripting languages, and if need be I can probably cobble something together in "sh" but I'd prefer to leverage as much as possible from the Ant toolset.

Community
  • 1
  • 1

1 Answers1

0

ANT is not a programming language and therefore has no native looping mechanism. This is why extensions like ant-contrib are popular. Personally I would highly recommend installing the groovy extension.

In the absence of external plugins, a trick that can used is a XSLT transformation which generates an ANT file that is dynamically executed. Examples are given in the following answers:

Finally have you considered Javascript? The required jars come bundled in the latest JVMs. See:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185