ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ot...@ivillage.com
Subject Re: javac include that avoids rebuilding everything?
Date Wed, 03 Oct 2001 04:20:44 GMT
I think the first problem is that your source dir and destination dir in the javac task are
different.
I'm not 100% sure about that.

In the case of the project for which I am using Ant, I copy all sources in a directory that
I call 'build/compile'
The equivalent would be:
cp -a MySourceDir/* build/compile/

I then have source dir and destinatin dir for the javac task set to the same thing: build/compile

That way, if there is a .java file build/compile/com/foo/bar/Barbie.java
the compiled class will end up being at build/compile/com/foo/bar/Barbie.class

That is the only way that I was able to prevent javac/jikes from recompiling over 1300 of
our .java files every time I use ant to compile things.

If there is a better way I'm all eyes!

Otis

On Tue, 02 October 2001, Scott Ellsworth wrote:

> 
> Howdy, all.
> 
> I note that the task for javac says:
> 
> "If you include part of your package-structure inside the srcdir-attribute 
> (or nested src-elements) Ant will start to recompile your sources every 
> time you call it."
> 
> This is exactly what ANT is doing to me at the moment, and I cannot figure 
> out how to rewrite my build.xml file to make it work.
> 
> My directory structure for this is:
> 
> -org
> --metagraph
> ---lib
> ---app
> ----experiment
> 
> My build.xml file is in foo/org/metagraph/app/experiment.  Up at the top, I 
> define <property name="src" value="."/>
> 
> I want to compile all of the files in experiment, using various libs in 
> lib.  The following javac task does it, but as the documentation warns, it 
> recompiles everything each time.
> 
>    <target name="compile-debug-old" depends="depend">
>      <!-- Compile the java code from ${src} into ${build} -->
>      <javac
>        srcdir="${src}"
>        destdir="${build-debug}"
>        classpath="${utilclasspath}"
>      />
>    </target>
> 
> I tried changing it to:
> 
>    <target name="compile-debug" depends="depend">
>      <!-- Compile the java code from ${src} into ${build} -->
>      <javac
>        srcdir="${src}/test"
>        includes="org/metagraph/app/import/**"
>        destdir="${build-debug}"
>        classpath="${utilclasspath}"
>      />
>    </target>
> 
> where test is a directory with nothing in it, but then it did not recompile 
> anything.
> 
> I must be missing something basic here.  For various reasons, the build.xml 
> file has to be in org.metagraph.app.experiment, and the build must be run 
> from there, but this should not be an insolvable problem, right?
> 
> The complete file which rebuilds the world, as the documentation warns, is 
> attached below.
> 
> <project name="experiment" default="dist" basedir=".">
> 
>    <!-- set global properties for this build -->
>    <property name="basemgdir" value="../../../.."/>
>    <property name="src" value="."/>
>    <property name="build" value="build"/>
>    <property name="build-debug" value="build/debug"/>
>    <property name="depcache-debug" value="${build}/debug-depcache"/>
>    <property name="build-release" value="build/release"/>
>    <property name="depcache-release" value="${build}/release-depcache"/>
>    <property name="libdir" value="${basemgdir}/org/metagraph/lib"/>
>    <property name="utilclasspath" 
> value="${libdir}/metagraph.jar:${libdir}/mysql.jar:${libdir}/log4j.jar:${libdir}/xerces.jar:${libdir}/jdom.jar"/>
>    <property name="dist"  value="dist"/>
>    <!-- property name="build.compiler" value="jikes"/ -->
> 
>    <target name="init">
>      <!-- Create the time stamp -->
>      <tstamp/>
>      <!-- Create the build directory structure used by compile -->
>      <mkdir dir="${build-debug}"/>
>      <mkdir dir="${depcache-debug}"/>
>      <mkdir dir="${build-release}"/>
>      <mkdir dir="${depcache-release}"/>
>      <!-- Create the dist structure used for results -->
>      <mkdir dir="${dist}"/>
>    </target>
> 
>    <target name="depend" depends="init">
>      <depend srcdir="${src}"
>        destdir="${build-debug}"
>        cache="${depcache-debug}"
>        closure="yes"
>      />
> 
>      <depend srcdir="${src}"
>        destdir="${build-release}"
>        cache="${depcache-release}"
>        closure="yes"
>      />
>    </target>
> 
>    <target name="compile-debug" depends="depend">
>      <!-- Compile the java code from ${src} into ${build} -->
>      <javac
>        debug="on"
>        optimize="off"
>        srcdir="${src}"
>        destdir="${build-debug}"
>        classpath="${utilclasspath}"
>      />
>    </target>
> 
>    <target name="compile-release" depends="depend">
>      <!-- Compile the java code from ${src} into ${build} -->
>      <javac
>        debug="off"
>        optimize="on"
>        srcdir="${src}"
>        destdir="${build-release}"
>        classpath="${libdir}/metagraph.jar:${libdir}/mysql.jar:${libdir}/log4j.jar:${libdir}/xerces.jar:${libdir}/jdom.jar"
>      />
>    </target>
> 
>    <target name="dist-debug" depends="compile-debug">
>      <!-- Put everything in ${build-debug} into the 
> expImport-${DSTAMP}-debug.jar file -->
>      <jar
>        jarfile="${dist}/expImport-${DSTAMP}-debug.jar"
>        basedir="${build-debug}"
>        compress="false"
>      />
>    </target>
> 
>    <target name="dist-release" depends="compile-release">
>      <!-- Put everything in ${build-release} into the 
> expImport-${DSTAMP}.jar file -->
>      <jar
>        jarfile="${dist}/expImport-${DSTAMP}.jar"
>        basedir="${build-release}"
>        compress="true"
>      />
>    </target>
> 
>    <target name="dist" depends="dist-debug,dist-release">
>    </target>
> 
>    <target name="clean">
>      <!-- Delete the ${build} and ${dist} directory trees -->
>      <delete dir="${build}"/>
>      <delete dir="${dist}"/>
>    </target>
> </project>
> 
> Scott
> Scott Ellsworth
> scott@alodar.com

_________________________________________________________________
iVillage.com: Solutions for Your Life 
Check out the most exciting women's community on the Web   
http://www.ivillage.com

Mime
View raw message