Fedora, Ant, and Optional Tasks

I've tried to be good.

I've tried a number of times to use the version of ant that Fedora packages up into an RPM from the JPackage repos rather than caving to the temptation to install it myself manually. I also like to use optional tasks like ReplaceRegExp in my scripts to do all sorts of cool things. Of course, I see most of the installation instructions that refer to ant via RPM mention that I need to yum install ant-apache-regexp to get my optional task jars installed for this very nice task. Every time I've tried this, ant yells at me saying that it can't find the taskdef class for ReplaceRegExp.

Huh? But I installed the proper, RPMs...didn't I?

Usually at this point, I fall back to what works and just install ant by hand.

However, I've finally realized why I've had so much trouble with this. There is one additional RPM that should be installed to get the classes that define all the optional tasks for ant called ant-nodeps. Before getting into some background, the way to fix this issue is to yum install ant-nodeps as well as the optional task jars you need.

Tasks are defined in ant via a small class that extends org.apache.tools.ant.Task or some similar class. The Apache team moved to a more separated architecture for the "sanctioned" optional tasks that are provided with the project. All of the optional tasks are now housed in a jar called ant-nodeps.jar in the lib directory under $ANT_HOME. In conjunction with this jar, there are jars that are specific to each of the tasks, such as ant-apache-regexp.jar.

But the separation is fairly hidden on Windows. Basically, when you download the ant distribution and extract it, you get everything. On Linux, the JPackage and Fedora projects split up the components of ant into separate RPMS. I can't say for sure, but it seems this is done because some of the task dependencies in ant are proprietary. Both JPackage and Fedora go to great pains to make sure that they quarantine themselves from proprietary bits, and so they have to split this stuff up a bit more to achieve that.

This being said, RPMs have a mechanism to specify dependencies. Ideally, all of the optional task jars would include ant-nodeps as a dependency. Even if that RPM had proprietary components (which I don't believe it does), the dependency would be noted and the user expected to satisfy this dependency some other way.

I've opened up a bug for this issue.

Comments

Unknown said…
This saved my day! Thank you!
Tony Watkins said…
For Fedora 11 make sure to "yum install ant-commons-net" otherwise builds fail when trying to find
org.apache.tools.ant.taskdefs.optional.net.FTP

Hope that helps someone as I've been looking for quite a while - the commons-net within the shared java folder isn't picked up for some reason.
Thank you!!! I figured out I need some optionals but never would've guessed the correct YUM package if it weren't for you :)

Popular posts from this blog

Ghetto Cloud Foundry Home Lab

Using Snapshot Isolation with SQL Server and Hibernate