Jared
Jared

Reputation: 6070

Where can I find tutorials about ant properties?

I'm trying to learn some ant for a Struts 1.x project that I was thrown onto. Mainly I'm trying to find a good referent for the inherent variables/properties of ant...beginners tutorial. Any GOOD reference really.

A couple lines of the ant file that I've been trying to figure out just for example...

<available file=${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>

and

<replace file="${temp.sun.web}">
    <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
    <replacevalue<![CDATA[<!-- <!DOCTYPE]]></replacevalue> //in ant is <!-- the comment out flag?
</replace>

I did do some searching and only could find ant build examples without explanation, but if it is covered and I just didn't find it a link will suffice. No reason to make someone reexplain it....I just couldn't find it.

Upvotes: 1

Views: 238

Answers (3)

bithead61
bithead61

Reputation: 196

(Shameless bid for reputation)

The example doesn't use a built-in property. Most Ant targets won't, because after properties are first set they are immutable. Instead, Ant scripts usually define their own properties. The Ant manual lists the properties that Ant predefines.

If you want to get into the guts of Ant, I recommend the Manning "Ant in Action" book.

Upvotes: 2

David W.
David W.

Reputation: 107080

The Ant Manual is your friend. There's a link Ant tasks on the left side of the page. Click on that link, and then the List of Tasks link. That will list all of the Ant tasks on the left and their explanation on the right. There, you'll see the available task and the replace task.

Unfortunately, the Ant manual uses Frames (bad Ant Manual! Bad Ant Manual!), so I can't supply a link that will list both the

Upvotes: 2

Spike Gronim
Spike Gronim

Reputation: 6182

Your first code block refers to the "available" ant task. It sets the property sun.web.present if the given file exists.

In your second code block, "<!--" starts an XML comment ("-->" closes one). This is true for all XML, not just ant build.xml files. In this case it is using the "replace" ant task to replace "<!DOCTYPE" with "<!-- <!DOCTYPE" within the file named by temp.sun.web.

In general an ant build file has targets like "build" or "clean". These depend on each other so that "test" runs "build" first. The targets are implemented by "tasks", where each XML tag refers to a task. You can read their manual and refer to the per-task docs for how each task works.

Upvotes: 3

Related Questions