|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
<javac> rebuilds even if source not changedHello,
When 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> </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 the source file hasn't changed. 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@... For additional commands, e-mail: user-help@... |
|
|
Re: <javac> rebuilds even if source not changedJean-Rene David wrote:
> Hello, > > When 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> > </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 the source file hasn't > changed. > > 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 you must move the class under the package name it is in. Without that not only does ant not do any dependency checking (is it expected to remember where every .class file comes from?) and sun's javac compiler wont build files in the correct order. -- Steve Loughran http://www.1060.org/blogxter/publish/5 Author: Ant in Action http://antbook.org/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: <javac> rebuilds even if source not changed* Steve Loughran [2008.04.28 06:00]:
> Jean-Rene David wrote: >> [...] >> 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 > > you must move the class under the package name it is in. Of course. It works now. Thanks. For posterity: $ find . ./build.xml ./src ./src/My ./src/My/Class ./src/My/Class/Welcome.java $ ant Buildfile: build.xml build: [mkdir] Created dir: /data/home/jrdavid/work/java-practice/build [javac] Compiling 1 source file to /data/home/jrdavid/work/java-practice/build BUILD SUCCESSFUL Total time: 0 seconds $ ant Buildfile: build.xml build: BUILD SUCCESSFUL Total time: 0 seconds -- JR --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free Forum Powered by Nabble | Forum Help |