You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ky...@panix.com on 2002/06/12 23:50:38 UTC

Conditional compilation




Hi!  I want to be able to invoke 'ant -DDEBUG=1' whenever I want my
project to be compiled with javac's -g flag.  How do I write the build
file for this?  One klunky way would be something like

  <target name="compile" unless="DEBUG>
    <javac debug="off"/>
  </target>

  <target name="compilewithdebug" if="DEBUG>
    <javac debug="on"/>
  </target>

  <target name="dist" depends="compile,compilewithdebug"/>

But that's a lot of machinery for a simple conditional!  (Not to
mention that it is ugly.)  Is this the only way?

Thanks!

kynn


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


Re: Conditional compilation

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
You're bound to get a flood of replies to this:

<property name="build.debug" value="true"/>
<javac debug="${build.debug}">

then run with: ant -Dbuild.debug=false to turn it off.

So yes, there is a vastly better way!

    Erik

----- Original Message -----
From: <ky...@panix.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Wednesday, June 12, 2002 5:50 PM
Subject: Conditional compilation


>
>
>
>
> Hi!  I want to be able to invoke 'ant -DDEBUG=1' whenever I want my
> project to be compiled with javac's -g flag.  How do I write the build
> file for this?  One klunky way would be something like
>
>   <target name="compile" unless="DEBUG>
>     <javac debug="off"/>
>   </target>
>
>   <target name="compilewithdebug" if="DEBUG>
>     <javac debug="on"/>
>   </target>
>
>   <target name="dist" depends="compile,compilewithdebug"/>
>
> But that's a lot of machinery for a simple conditional!  (Not to
> mention that it is ugly.)  Is this the only way?
>
> Thanks!
>
> kynn
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


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