You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Richard Gaywood <ri...@gmail.com> on 2005/09/08 11:11:08 UTC

Force javac to overwrite class files?

Hi list! 

I'm modifiying a slightly complex existing[1] build script for our J2EE web 
services app. I currently have two compile targets which compile class files 
with or without Emma modification. [aside for those who haven't seen it: 
Emma is a code coverage calculation tool that works by modifying the .class 
directly before it runs]

So, during our nightly build-and-unit-test cycle, Anthill pulls down the 
source from (groan) Visual SourceSafe, Ant kicks off, compiles them, 
instruments the classfiles, runs unit tests. It should then recompile the 
code, skip the Emma instrumentation, compile a WAR, and deploy to a staging 
server. But, because the timestamps of the java files don't change, the 
second <javac> invocation (without the Emma instrumentation) doesn't compile 
anything -- which means Emma instrumented class files end up in the WAR, 
which doesn't work at all.

So, I tried inserting depends= to my clean task before each compile, but of 
course, Ant sees the multiple calls to the target and optimises them into 
one call!

I tried looking for a "force overwrite" mode in javac, but it doesn't have 
one I've seen. I also tried using <touch> to change the timestamp of the 
source files to force the recompile, but the files are read only so that 
doesn't work either.

Next plan is to rewrite my compile task as a macrodef so I can more directly 
control the flow of logic, so that I can call a clean macrodef multiple 
times. But that's going to entail a lot of knock-on changes elsewhere in the 
build system. Does anyone have any other ideas I've overlooked before I dive 
in and start pulling it to pieces?


[1] I wrote it, but too long ago, so it might as well have been written by 
someone else now!

Re: Force javac to overwrite class files?

Posted by Troy Daniels <tr...@baesystems.com>.
At 05:11 AM 9/8/2005, Richard Gaywood wrote:

>Hi list!
>
>I'm modifiying a slightly complex existing[1] build script for our J2EE web
>services app. I currently have two compile targets which compile class files
>with or without Emma modification. [aside for those who haven't seen it:
>Emma is a code coverage calculation tool that works by modifying the .class
>directly before it runs]

You could modify the build so that instead of compiling to ./classes (or 
whatever you actually compile to) both times, the first time compiles to 
./classes-emma and the second time compiles to ./classes.

Troy

>So, during our nightly build-and-unit-test cycle, Anthill pulls down the
>source from (groan) Visual SourceSafe, Ant kicks off, compiles them,
>instruments the classfiles, runs unit tests. It should then recompile the
>code, skip the Emma instrumentation, compile a WAR, and deploy to a staging
>server. But, because the timestamps of the java files don't change, the
>second <javac> invocation (without the Emma instrumentation) doesn't compile
>anything -- which means Emma instrumented class files end up in the WAR,
>which doesn't work at all.
>
>So, I tried inserting depends= to my clean task before each compile, but of
>course, Ant sees the multiple calls to the target and optimises them into
>one call!
>
>I tried looking for a "force overwrite" mode in javac, but it doesn't have
>one I've seen. I also tried using <touch> to change the timestamp of the
>source files to force the recompile, but the files are read only so that
>doesn't work either.
>
>Next plan is to rewrite my compile task as a macrodef so I can more directly
>control the flow of logic, so that I can call a clean macrodef multiple
>times. But that's going to entail a lot of knock-on changes elsewhere in the
>build system. Does anyone have any other ideas I've overlooked before I dive
>in and start pulling it to pieces?
>
>
>[1] I wrote it, but too long ago, so it might as well have been written by
>someone else now!

----------------------------------------
Troy Daniels
troy.daniels@baesystems.com
781-273-3388 x218


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Force javac to overwrite class files?

Posted by Nicolas Vervelle <ni...@steria.com>.
Hi,

Why don't you simply delete your .class files before the second call to 
javac ?

Richard Gaywood wrote:

>Hi list! 
>
>I'm modifiying a slightly complex existing[1] build script for our J2EE web 
>services app. I currently have two compile targets which compile class files 
>with or without Emma modification. [aside for those who haven't seen it: 
>Emma is a code coverage calculation tool that works by modifying the .class 
>directly before it runs]
>
>So, during our nightly build-and-unit-test cycle, Anthill pulls down the 
>source from (groan) Visual SourceSafe, Ant kicks off, compiles them, 
>instruments the classfiles, runs unit tests. It should then recompile the 
>code, skip the Emma instrumentation, compile a WAR, and deploy to a staging 
>server. But, because the timestamps of the java files don't change, the 
>second <javac> invocation (without the Emma instrumentation) doesn't compile 
>anything -- which means Emma instrumented class files end up in the WAR, 
>which doesn't work at all.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Force javac to overwrite class files?

Posted by Richard Gaywood <ri...@gmail.com>.
Well, those were blindingly obvious suggestions that'll teach me to try and 
write build scripts before my morning coffee. Thanks to Nicolas and Troy!