CFANT and ANT 1.7 on CF8

Monday, March 9, 2009

You probably know that CF ships with an undocumented tag for running ANT build files: CFANT. There's a writeup here. I tried getting it to work today and hit several snags. The steps I took to get it all working properly are these:
  1. First error: null pointer exception. This was b/c I stupidly did not include the anthome argument. However, as the link above states, it looks like this argument is required (probably so that the ant.home variable can be set internally, but it appears to be ignored when it comes to actually loading the ant jars
  2. Second error: I hit something like "attribute "else" is not supported on Condition tag". Since I was quite certain "else" was in fact a supported attribute, I immediately suspected an ant version problem. Maybe my ant home (which is the latest 1.7) was being ignored? So I did an <echoproperties/> in my build file, then hit snag #3
  3. optional task org.apache.tools.ant.taskdefs.optional.EchoProperties is not found (or something like that)
First, solving #2: the unsupported "else" Since echoproperties didn't work, I just did a normal echo on ${ant.home} and ${ant.version}. Sure enough, ant.version was 1.6. So this told me that CF was using the ant jar in its classpath. Makes sense, actually. So I stopped CF, dropped in the 1.7 jar, restarted CF, and that problem was solved. Next, solving #3: echoproperties not found I opened up ant.jar and drilled down and in fact the taskdefs/optional directory wasn't there. So where does this little bugger hide? It's in ant-nodeps.jar, which isn't bundled with CF. So I dropped that jar from my ant distribution into my cf lib directory (same lib directory where ant.jar lives), restarted CF, and that problem went away, too. With those problems solved, things *just worked*.

2 comments:

Jim Priest said...

Adding to my Ant wiki - wonder in which version of CF this was first introduced??

Marc Esher said...

I'd assume MX7