• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I conditionally include this javac command?

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic