aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Compilation error while using Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Compilation error while using Ant" Watch "Compilation error while using Ant" New topic
Author

Compilation error while using Ant

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Hi,
I am building around 5K files using Ant.At times , when i update(add some constants) a file having constants (static final variable) & start building , the file with constants is not getting compiled.
And i get an error like ... var ABC (added constant) is undefined.
What could be the issue?
Thanks & Regards
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Ant will compile only .java files that have changed (actually, only the .java files whose timestamps are more recent that the timestamps on the corresponding .class files) With constants, this can be very tricky. If you change the file containing the constant, it will be recompiled but the files that use the constant are not recompiled. At least not unless you specify such dependencies (I think there is a way to do this in Ant, I haven't used it). The workaround I use is to always call the 'clean' task first - then I'm sure to have everything compiled properly.

In you case, it might be that the .java file referencing the new constant is being compiled first and the compiler is still referencing the old .class file (that is just a guess). But calling 'clean' first should solve this also.


JBoss In Action
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks a lot.Clean build is solving the problem.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Compilation error while using Ant