ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: failure to re-build dependent targets ??
Date Sun, 10 Dec 2000 23:29:39 GMT
Hi John,

The "depends" attribute on a <target> doesn't associate a dependency
between a source-file and its object -- it associates a dependency on the
<target> with other <target>(s). The <javac> task does the association
between a .java file and its .class file.

In your case, if you just have a couple of .java files in your base
directory, which get built into that same directory, you would just need
(target's name can be anything):

  <target name="compile">
    <javac srcdir="${basedir}" destdir="${basedir}"/>

The <javac> task will include both "srcdir" and "destdir" in the
compile-time classspath, and, unless otherwise specified, will pick up all
.java files in "srcdir". Note: If "basedir" is the top-level dir of a tree
with other .java files in it, though, then you will need to be more
specific as to which files to include, since (I believe) it will recurse
through "srcdir", looking for .java files (to only include the .java files
that live in "basedir" itself, include the "includes" attribute:

Hope this helps,

--- John Festa <> wrote:
> I'm a novice Ant user, so thanks in advance for your patience if I'm
> missing
> something obvious here.
> In this example, the build file, Java sources, and Java class files all
> reside in the same directory. Both Java classes are members of the
> 'global'
> Java package. If I modify '' -- for example, change a method
> signature, and then run 'ant Caller.class', Ant properly detects the
> change
> to '' and rebuilds it, but does *not* rebuild 'Caller.class'
> which depends on it. Is this expected behavior or am I doing something
> wrong?
> <project    name="AntTest" default="Caller.class" basedir="." >
>     <target name="CallMe.class" depends="" >
>         <javac  srcdir="${basedir}" destdir="${basedir}"
> classpath="${basedir}" >
>             <include name="" />
>         </javac>
>     </target>
>     <target name="Caller.class" depends=",CallMe.class" >
>         <javac  srcdir="${basedir}" destdir="${basedir}"
> classpath="${basedir}" >
>             <include name="" />
>         </javac>
>     </target>
>     <target name="" />
>     <target name="" />
> </project>


Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.

View raw message