aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How do I conditionally include this javac command? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How do I conditionally include this javac command?" Watch "How do I conditionally include this javac command?" New topic
Author

How do I conditionally include this javac command?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Ant 1.8. I have a target that builds a JAR file (amongst a couple of other things). This is the meat of what I'm using ...



My question is, I only want to run the second "javac" command if the "srcDir" exists. How can i modify the above to achieve that? Thanks, - Dave
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Use the <available> task to check for the existence of the directory, that task will set a property if it exists. Then place the <javac> within a target that uses an "if" that reference the property.

You should also split up the tasks you posted into three separate targets with appropriate dependencies.


JBoss In Action
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do I conditionally include this javac command?