This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.