Justin Koke

Using XMLTask for Maven and Ant

Justin Koke talks about Crowd
February 15, 2007

I just thought I should share this great little gem I stumbled across last week when I was faced with this Crowd Issue.

After a few quick searches on Google I came across this great little Ant library, XMLTask. After downloading the jar and having a quick read of the great example docs, I had resolved my issue in 5 minutes,"how awesome is that!" (as Justen would say ;) )

Here is a quick example of what I did:

<!-- This will set Tomcat's HTTP Connector and SHUTDOWN ports -->
<echo> Changing Tomcat's connector port to ${crowd.tomcat.connector.port} </echo>
<xmltask source="${tomcat}/conf/server.xml" dest="${tomcat}/conf/server.xml">
  <replace path="/Server/Service/Connector/@port" withText="${crowd.tomcat.connector.port}" />
</xmltask>

<echo> Changing Tomcat's shutdown port to ${crowd.tomcat.shutdown.port} </echo>
<xmltask source="${tomcat}/conf/server.xml" dest="${tomcat}/conf/server.xml">
  <replace path="/Server/@port" withText="${crowd.tomcat.shutdown.port}" />
</xmltask>

So with two very simple commands a had XML/XPath manipulation of Tomcat's server.xml file.

So if you need some XML support for an Ant script you are writing or even a Maven 2 Ant Plugin, I would definitely suggest XMLTask.


Tags: ant, crowd, maven, maven2, xml, xpath

Post a comment

If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.





Remember personal info?

Type the characters you see in the picture above.