ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeff <...@houseofdistraction.com>
Subject dependencies in Ant?
Date Tue, 10 Oct 2000 17:21:57 GMT
I have been evaluating Ant to decide if we should use it but I can't
find anything in the docs or example build files that addresses the
following situation.

Consider these files all in the same directory:

---------
A.java
---------
public class A
{
    B b;

    public A()
    {
        b = new B( 3 );
    }
}

---------
B.java
---------
public class B
{
    int x;
    public B( int x )
    {
        this.x = x;
    }
}

---------
build.xml
---------
<?xml version="1.0"?>
<project name="test" default="compile" basedir=".">
  <target name="compile">
    <javac srcdir="." classpath="." destdir="." />
  </target>
</project>



I type "ant", it builds A.class and B.class, everything is happy.  Now I
change B

---------
B.java
---------
public class B
{
    Integer x;
    public B( Integer x )
    {
        this.x = x;
    }
}

I type "ant", it builds B, it says everything is happy but we know
better.  If I were to touch A.java and invoke Ant again it would give me
the bad news.

I would like to set up a build file so that the builds are always
automatically correct.   This is the best I could figure out for this
example:

---------
build.xml
---------
<?xml version="1.0"?>
<project name="test" default="compile" basedir=".">
  <target name="compile" depends="nuke-A">
    <javac srcdir="." classpath="." destdir="." />
  </target>
  <target name="nuke-A">
    <delete file="A.class" />
  </target>
</project>


This technique works but it has a two obvious problems:
	1. Files with dependencies are always recompiled.  In a large
           project this would be most of the files.
	2. It is tedious to set up and maintain.

Now, I could imagine addressing problem #2 by periodically using jikes
+M and post-processing the resulting .u files into a new build.xml but I
can't see any way to address problem #1 using Ant.  How do people deal
with this in real projects?

Mime
View raw message