|Override workspace/project compiler settings for a specific file [message #1103444]
||Fri, 06 September 2013 15:58
| J. Zufallig
Registered: May 2013
Most of our project is written in Java 7, and so our Eclipse users have their Java Compliance level set to 1.7. All is well.|
As a safety check, the file containing the entry point of the program is built for a much earlier JRE, so that main() gets built for Java 1.2 or 1.4 or some such. The contents just do a version check against the running JRE (and some other tests), and if everything is okay, loads the real program and fires it off. Occasionally we get a very outdated user, and this lets us give them a useful error message instead of ClassNotFoundException.
Our official build system is using Ant, so we specify the older Java version by simply using a <javac> task with appropriate source= and target= parameters for that specific file. All is still well.
The trouble comes when the Eclipse users try to do a full build inside Eclipse's builtin Java Builder rather than using Ant. (While Eclipse isn't what we use for official builds, some of the coders like using it for moment-to-moment development.) The special entry point file contains code that's considered outdated now, like "Class" instead of "Class<?>" because JRE version 1.Old.Ancient didn't have generics, and so on. Eclipse tries building it with JDK 1.7 and complains about everydamnthing.
And of course, we can't do anything like @IgnoreThatParticularWarning("YARLY") because annotations didn't exist back in the dark ages of 2003 or whenever, so Ant fails in an official build.
This would be considerably easier if the Eclipse users could do what the Ant build does, and override the compliance level on a per-file basis. Is this possible?
(Yes, I know Ant-inside-Eclipse can read the same build.xml file, but our build system does things which simply don't work when run inside Eclipse. All the Eclipse users want is to be able to say "compile all the .java to .class", not produce a full product. Thus the builtin Java Builder instead of Ant-inside-Eclipse.)
Powered by FUDForum
. Page generated in 0.02405 seconds