You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Scott Ellsworth <sc...@alodar.com> on 2001/12/21 02:10:46 UTC

How to set a javac parameter only if a property exists

Howdy, all.

The problem: when build.compiler is set to jikes, and there is a 
nonexistent directory in the extensions path, jikes barfs.  MacOS X 
has several directories in the extensions path that do not exist.

The potential hope:
If is set build.compiler to jikes, and then find a way to add the 
parameter extdirs="" to my javac target, then I am told that it works.

The workaround:
If I set build.compiler to jikes, then I will set build.extdirs to "" 
at the same time.  A manual step, but one I can live with.

The icky part I do not know how to handle:
How do I set the parameter only if the property has a value?  The 
rest of the time, it is fine as it is.

Here is my task:
<target name="compile-release" depends="depend-release" 
description="Compile java files into optimized class files">
     <javac
       debug="off"
       optimize="on"
       srcdir="${build-source}"
       destdir="${build-release}"
       classpath="${utilclasspath}"
       excludes="${excludedFiles}"
       includes="${includedFiles}"
     />
   </target>

I could clearly add extdirs=${build.extdirs} right after the includes 
line, but that is really tacky, because then I will need to define it.

I would much rather say something like

if ${build.extdirs} exists, set extdirs=${build.extdirs} endif

so if the property does not exist, I could just get the default 
behavior, and only if I decided to set the property will I see 
changes.

How are other people handling this?

Scott

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>