Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compilation error while using Ant

 
Max White
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Max White
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.Clean build is solving the problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic