ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <>
Subject Re: How do to conditional javac executable fork?
Date Fri, 28 Apr 2006 11:32:21 GMT

You shouldn't need multiple javac tasks - you can do some work with 
condition's.  I have a similar need in a project I am working on where I 
want to be able to set some properties to default values if not set 
(either by the current ant task or the environment).  I am using ant 
contrib to some "creative" work...  However, if I were to use "stock" 
ant, I might do the following:

<!-- Substitute your property file name as the file attribute -->
<property file="mypropfile.props"/>

<dirname property="JRE_PARENT_DIR" file="${java.home}"/>

<condition property="JAVAC" value="${JRE_PARENT_DIR}/bin/javac">
                <isset property="JAVAC"/>

The above may look a little funny.  I ran a test an noted ${java.home} 
returns the jre directory from my system's JAVA_HOME.  So, above I 
compute the parent dir of this via dirname.  Then, in condition if the 
property JAVAC has not been set, I force its value to the location of 
javac.  This assumes, that in your property file you will use a property 
entitiled JAVAC...

In your execute you will need to use ${JAVAC}.

Hope that helps...


Robert Nicholson wrote:
> On Apr 27, 2006, at 10:58 PM, Stefan Bodewig wrote:
>> On Thu, 27 Apr 2006, Robert Nicholson <> wrote:
>>> If I write a javac task in Ant 1.5 that uses executable and I use a
>>> property to detemine the path of the executable. What will javac do
>>> if there's no property set?
>> If you mean you have something like executable="${prop}" then Ant will
>> try to execute an executable named ${prop} if the property named
>> "prop" isn't set.  Setting it to an empty string wouldn't help either.
> Basically I want the default compiler to be the one that's executing 
> Ant but the ability
> to override that thru a properties file. It sounds like I actually 
> have to have javac's conditional
> on prop so I need multiple javac tasks.
>>> Will it use the jvm that's running ant to do the compile?
>> Only if there is no executable attribute at all.
>> Stefan
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate
Chief Architect JavaPIM

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message