tags:

views:

207

answers:

2

I would like to simplify my main build scripts, and I'd like to have the ability to reuse certain common ant tasks as a library, but I'd also like them to be easily available as a package.

For instance, I've got a task which sets up the Flex environment variables that I need to build a variety of projects. I can (And am currently) include those scripts by relative path from another location in source control. But what I want to do is make a single download-able package that I can grab via Ivy that contains all of these generic tasks.

A jar seems the most natural solution, since this is doable from java (Use the class loader to access the file inside the jar.), but I can't seem to find a "native" way in Ant to just get the xml file.

In short, I want to do:

<import file="some.jar!bootstrap.xml">

But that doesn't work.

Is there someway to do this? Any other suggestions for making a library of ant scripts would be much appreciated as well.

A: 

From what I understand you're trying to extract a file containing more ant tasks from your jar and then tell ant to execute the tasks in those extracted files. Since the files are static, you'd probably be better off creating actual java Task definitions in your jar and declaring them in your ant build file. However, if you don't want to do that, you can just use the Unzip ant task to extract the resource out of the jar and onto the file system and then use the Ant task to execute the extracted file.

Jherico
Thanks for the reply, I don't want to have to extract the file. I mean I could, but that would almost defeat the purpose of making the tasks shared, because there would be a bunch of boilerplate to extract the tasks. I'm looking for inline inclusion of the ant tasks, without the unzip, directly from the jar file.
Aaron H.
The `Ant` task in Ant very explicitly works on files, not on resources or streams. Your best bet is to either extract the file or create your own version of the Ant task which can work with resources.
Jherico
+1  A: 

IIRC there's ongoing work in Ant to support this but it's not supported in any published version.

Actually, further research showed that it's a feature planned (Or at least talked about) for 1.8.. Hopefully it will make it.
Aaron H.