Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Override workspace/project compiler settings for a specific file
Override workspace/project compiler settings for a specific file [message #1103444] Fri, 06 September 2013 19:58 Go to next message
J. Zufallig is currently offline J. ZufalligFriend
Messages: 18
Registered: May 2013
Junior Member
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.)
Re: Override workspace/project compiler settings for a specific file [message #1764513 is a reply to message #1103444] Tue, 30 May 2017 16:49 Go to previous message
J. Zufallig is currently offline J. ZufalligFriend
Messages: 18
Registered: May 2013
Junior Member
It's been a few years, some of our developers are using Eclipse 4.6.3 by now, so I thought I'd ask if this ever changed.

Alternatively, if the compliance level can't be changed per-file, what about the warning categories/levels?

Previous Topic:LDAP server startup logs
Next Topic:Apache Tomcat v9.0
Goto Forum:
  


Current Time: Fri Apr 19 04:14:51 GMT 2024

Powered by FUDForum. Page generated in 0.01707 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top