-
Notifications
You must be signed in to change notification settings - Fork 70
sonar checkstyle with Eclipse
Please visit Eclipse IDE official web site, download and install the latest version of Eclipse IDE for Java Developers.
Select File > Import > Maven > Existing Maven Projects. sonar-checkstyle will show 3 projects and all 3 must be imported into the workspace. It is not recommended to add them to a "working set".
When importing as a maven project for the first time, a build will probably produce a lot of errors in checkstyle-sonar-plugin
like AbstractCheck cannot be resolved to a type
. These errors are because Eclipse can't find the original checkstyle dependency in checkstyle-all
.
To fix this, you must first create the shaded JAR of checkstyle-all
as Eclipse doesn't create it on a build normally. To do this, you must either:
- run the maven command
mvn package
incheckstyle-all
outside of Eclipse, or - run the command through Eclipse's maven via Run > Run Configurations and creating a new Maven Build defining the goal as
package
.
Once the JAR is created, you must manually add it as a dependency to checkstyle-sonar-plugin
. To do this, right click the checkstyle-sonar-plugin
project and select Properties. Then go to Build Path > Libraries and click add Add Jars. Select the shaded JAR named checkstyle-all-X.X-SNAPSHOT-shaded.jar
(X.X being the version number).
Once these steps are done, all build errors should go away and the project should be ready to run. Please note that when a new version of the project is released, these steps will have to be redone as the version number will change and Eclipse will not automatically warn you that your dependency JAR is out of date.