Sounds like he's looking for the <depend> task.
Diane
--- James Duncan Davidson <[EMAIL PROTECTED]> wrote:
> ------ Forwarded Message
> From: Mike <[EMAIL PROTECTED]>
> Date: Wed, 24 Jan 2001 16:38:18 -0500
> To: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED],
> [EMAIL PROTECTED]
> Subject: Suggested Ant dependency feature
>
> I used to use a Makefile in combination with a shell-script that would
> look at the previously generated .class files and turn them into
> depencies on the .java files, like so:
>
> SRC=com/myself/app/Test.java
>
> something.jar: $(SRC)
> rm -rf tmp
> mkdir tmp
> jikes +E +F -d tmp $(SRC)
> cd tmp;jar cfM ../$@ .
> javadeps tmp Makefile
>
> ## dependencies:
> something.jar: \
> com/myself/app/Test.java \
> com/myself/io/SomethingSpecial.java
>
>
> The shell-script 'javadeps' peruses the tmp directory and searches for
> all .class files. Each one it finds it tries to find a corresponding
> .java file. If found (not found in case of inner classes), it puts it
> in the Makefile.
> This works absolutely perfect! It is always aware of other java files I
> 'import' without me having to list them manually, which would be
> certainly very error prone, since you're bound to forget them. I also
> only specify the application's entry point. The compiler will
> automatically compile all the other .java files precisely, no more .java
> files are compiled and included in my .jar file then are necessary.
>
> Ok, now using *Ant*:
>
>
> <project name="something" default="all" basedir="."> <target
> name="all" depends="init,compile_classes" /> <target name="init">
> <property name="build.compiler" value="jikes"/> </target>
> <target name="compile_classes" depends="init"> <mkdir dir="tmp"/>
> <javac srcdir="."
> destdir="tmp"
> classpath=""
> includes="com/myself/app/Test.java"/>
> <jar jarfile="something.jar" basedir="tmp"/> </target>
> </project>
>
> This generates the something.jar ok.
> Now, here's the problem:
> If I modify com/myself/io/SomethingSpecial.java and run *Ant* again, it
> doesn't compile! It doesn't look into the tmp folder and doesn't see
> that there is a dependency on the com/myself/io/SomethingSpecial.java
> file. If I modify the Test.java file it's ok, it'll recompile but not
> if I touch other files that aren't listed.
>
> Listing it in the 'includes' attribute is unacceptible, because there
> are like 40 files in it. Listing the .java file explicitly is also
> unacceptible because how do I know I didn't forget anything. Deleting
> tmp before the compile is not great because it then always compiles
> everything.
>
> So I suggest *Ant* gets a new feature where you can make it scan the tmp
> folder for other previously generated .class files that weren't listed
> and tries to match them up to the source.
>
>
> In the meantime I found a workaround:
>
> I have a bash script with the following:
>
> dir=$1 target=$2
>
> if [ ! $dir ] || [ ! $target ]
> then
> echo Usage: antdep \<classdir\> \<target>\
> exit
> fi
>
> here=`pwd`
>
> cd $dir
> files=`find . -name "*.class"`
> cd $here
> for a in $files
> do
> if [ ${a/.class/.java} -nt $dir/$a ]
> then
> echo ${a/.class/.java} is newer than $dir/$a, removing
> $dir/$target
> rm -f $dir/$target
> exit
> fi
> done
>
>
> In build.xml I add:
>
> <target name="deps">
> <exec dir="." command="./antdep tmp com/myself/app/Test.class"/>
> </target>
>
>
> I make the deps target a dependency. So, now everytime I run 'ant', the
> script ends up deleting my .class file if any of my .java files in
> question are newer than the .class file in tmp.
> So, I'm hoping Ant will have this feature built in the next release?
>
>
> -regards,
>
> -Mike-
>
>
>
> ------ End of Forwarded Message
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
=====
([EMAIL PROTECTED])
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/