ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicolas.verve...@steria.com
Subject RE <javac> rebuilds even if source not changed
Date Mon, 28 Apr 2008 08:13:40 GMT
Hi,

Maybe try putting your javafile elsewhere :
* in a src/ dir (so that javac destdir is not a subdirectory of srcdir, 
which probably confuses javac)
* by respecting the package / directory structure : it should be in 
my/class/ package hierarchy

My 2 cts
Nico


Jean-Rene David <jrdavid@magma.ca> wrote on 27/04/2008 04:33:19:

> Hello,
> 
> If a class is in a package, the <javac> target
> always rebuilds it even if the source hasn't
> changed. Here's a test case:
> 
> $ ant -version
> Apache Ant version 1.7.0 compiled on December 13 2006
> 
> $ ls
> build.xml
> Welcome.java
> 
> $ cat Welcome.java
> package My.Class;
> public class Welcome
> {
>    public static void main(String[] args)
>    {
>       System.out.println("Hello World!");
>    }
> }
> 
> $ cat build.xml
> <?xml version="1.0"?>
> <project name="test" default="build" basedir=".">
>    <target name="build">
>       <mkdir dir="foo" />
>       <javac srcdir="." destdir="foo" />
>    </target>
>    <target name="clean">
>       <delete dir="foo" />
>    </target>
> </project>
> 
> $ ant
> Buildfile: build.xml
> 
> build:
>     [mkdir] Created dir: /tmp/testcase/foo
>     [javac] Compiling 1 source file to /tmp/testcase/foo
> 
> BUILD SUCCESSFUL
> Total time: 1 second
> 
> Now I just run it again:
> 
> $ ant
> Buildfile: build.xml
> 
> build:
>     [javac] Compiling 1 source file to /tmp/testcase/foo
> 
> BUILD SUCCESSFUL
> Total time: 0 seconds
> 
> And it recompiles but shouldn't.
> 
> My class is part of the My.Class package, so javac
> put it in: foo/My/Class:
> 
> $ find 
> .
> ./Welcome.java
> ./build.xml
> ./foo
> ./foo/My
> ./foo/My/Class
> ./foo/My/Class/Welcome.class
> 
> But the <javac> task doesn't recurse the hierarchy
> to find the class file. It only looks in the
> "destdir" itself. So if I just:
> 
> $ touch foo/Welcome.class
> 
> Then <javac> doesn't rebuild the file:
> 
> $ ant
> Buildfile: build.xml
> 
> build:
> 
> BUILD SUCCESSFUL
> Total time: 0 seconds
> 
> What idiom am I missing?
> 
> Thanks for any input,
> 
> -- 
> JR
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 







Ce message est à l'attention exclusive des destinataires désignés. Il peut 
contenir des informations confidentielles. Si vous n'êtes pas destinataire 
du message, merci d'en avertir immédiatement l'expéditeur et de détruire 
ce message. Le contenu de ce message ne pourrait engager la responsabilité 
de Steria que s'il a été émis par une personne dûment habilitée agissant 
dans le strict cadre de ses fonctions et à des fins non étrangères à ses 
attributions. Bien que les meilleurs efforts soient faits pour maintenir 
cette transmission exempte de tout virus, l'expéditeur ne donne aucune 
garantie à cet égard et sa responsabilité ne saurait être engagée pour 
tout dommage résultant d'un virus transmis.


This message is intended exclusively for the designated addressee. It may 
contain confidential material. If you are not the correct addressee, 
please notify the sender immediately and destroy the message. The content 
of this message will engage the responsibility of Steria only if it has 
been sent by an authorized person acting in the strict scope of his 
functions and for purposes that are related to his competence. Although 
reasonable efforts have been made to keep this transmission free from 
viruses, the sender will not be liable for damages caused by a transmitted 
virus.



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message