ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Conditional compilation
Date Thu, 13 Jun 2002 12:43:09 GMT
----- Original Message -----
From: <kynn@panix.com>

> The best I can come up with in this case is something like this:
>
>   <target name="jar" depends="init,compile">
>     <jar jarfile="MyProject-${DSTAMP}.jar" manifest="Manifest">
>       <!-- basedir="${build}" -->
>       <fileset dir="${build}"/>
>       <fileset dir="${sourcedir}"
>                includes="${withsource}"/>
>     </jar>
>   </target>
>
> and run with
>
>   % ant -Dwithsource='**/*.java'

Better yet:

<fileset dir="${sourcedir}">
  <include name="**/*.java" if="withsource"/>
</fileset>

Patternsets support if/unless attributes.
    http://jakarta.apache.org/ant/manual/CoreTypes/patternset.html

You might have to have an <exclude name="**/**" unless="withsource"/> or
something like that also - I'm not sure off the top of my head.

> The second question relates to my other questions so far.  It has to
> do with making a command-line flag imply another.  Again, in the case
> of make, if I wanted the flag DEBUG to imply the WITH_SOURCE flag, I
> would simply add this to my makefile:

> How can I do a similar thing with ant?

<condition property="withsource">
  <isset property="debug"/>
</condition>

should do the trick.

    Erik



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message