Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one specify Java warning settings per project in Eclipse?

I have a Java project which is a combination of human-written Java code and Java code generated by axis2.

The axis2 generated code provokes thousands of warnings from the Java compiler (either javac or the one built into Eclipse). Examples of warnings: dead code, use of raw list and array types predating Java generics, etc. (more at http://www.coderanch.com/t/501752/Web-Services/java/Axis-Generate-without-Warnings). I'd like to silence and ignore these specific warnings in the generated code, but not the human-written code.

I've seen How to add -Xlint:unchecked option or any javac option in Eclipse? and that allows me to disable the relevant warnings via Window->Preferences, but workspace-wide, which is not what I want. Is there a way to do this on a per-project basis?

If not, how do people deal with generated code without ignoring warnings that would be useful to humans?

like image 589
metamatt Avatar asked Sep 18 '25 04:09

metamatt


2 Answers

You can enable lots of different options on a per-project basis. Assuming you're using Helios, here's how to configure warnings on a particular project:

  1. Right-click the project (or select the project, then Alt+Enter)
  2. Java Compiler → Errors/Warnings
  3. Check "Enable project specific settings" (does the missing hyphen bug you? It bugs me)
  4. Configure away!

illustrious illustration!

like image 188
Matt Ball Avatar answered Sep 19 '25 18:09

Matt Ball


The multiple projects approach suggested by Matt is the right solution (since you can remove all warnings for a given project)

To try to do so within the same project has been:

  • ignored in 2003 (bug 46391)
  • in discussion (with a proposed path) since 2009 (bug 220928)

So far, there isn't a way to "ignore warnings from certain source folders".

like image 40
VonC Avatar answered Sep 19 '25 17:09

VonC