Reputation: 3
Is their a way to prevent Eclipse from building or compiling a project if unsolved warnings exist? I'm very lazy and know I am likely to ignore feedback from tools like checkstyle, so I was thinking it could be useful to force correct code before compiling. Do you think this is a good idea? Do you know how I might do this in eclipse?
Thanks.
Upvotes: 0
Views: 257
Reputation: 7899
In the Preferences window, under Java|Compiler|Errors/Warnings, each of the various types of problems can be set to Ignore, Warning, or Error. You can change any or all of them to Error.
At the bottom of the page is a checkbox for:
Treat above errors like fatal compile errors (make compiled code not executable).
So, decide what messages you want to fail your build, and check that last checkbox.
If you want to use checkstyle, findbugs, or pmd and have them fail your build, you will have to depend on an external build tool like Ant, Maven, or Gradle. You can create <checkstyle>
, <findbugs>
or <pmd>
tasks, and have your real <package>
target depend on them; that way if the audit task requires compilation, the target allows it, but you'll never get a [ejw]ar
file out of it.
It's actually a good idea to have a build system that does not depend on the IDE. You may want to use a CI system, for example.
Upvotes: 2