Skip to content

Add Eclipse Checkstyle Plugin support #82

@brenuart

Description

@brenuart

Sorry for posting this issue here but I could not find any other place :(

I tried to use the spring-javaformat-checkstyle together with the maven-checkstyle-plugin as described in the project home page. I made a simple project with no dependencies and a simple main class. I copied the maven-checkstyle-plugin section from the readme and pasted it into the project pom. I did not include the spring-javaformat-maven-plugin plugin. The pom is as follows:

<project>
	....
	<dependencies>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>3.0.0</version>
				<dependencies>
					<dependency>
						<groupId>com.puppycrawl.tools</groupId>
						<artifactId>checkstyle</artifactId>
						<version>8.11</version>
					</dependency>
					<dependency>
						<groupId>io.spring.javaformat</groupId>
						<artifactId>spring-javaformat-checkstyle</artifactId>
						<version>0.0.6</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>checkstyle-validation</id>
						<phase>validate</phase>
						<inherited>true</inherited>
						<configuration>
							<configLocation>io/spring/javaformat/checkstyle/checkstyle.xml</configLocation>
							<includeTestSourceDirectory>true</includeTestSourceDirectory>
						</configuration>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

Everything works fine from the command line: mvn validate triggers the validation and reports violations.

Unfortunately, things are different from within Eclipse where I constantly receive an error saying:

Checkstyle execution failed due to an internal error. Please check the error log for details.

My Eclipse installation is running Eclipse Checkstyle Plugin version 8.12.0 (it installed itself automatically after the project is imported inside Eclipse - I did not select the version myself). spring-javaformat-checkstyle is built against 8.11.0 - is this an issue?

I tested with different versions of Eclipse, every time with a fresh installation and a brand new workspace - no other plugins than what is included in the Eclipse IDE for Java Developers package. I tested with Eclipse Photon, 201809 and 201812 and got the same error each time.

The Eclipse log contains the following when the error occurs:

!ENTRY net.sf.eclipsecs.core 4 0 2019-03-13 19:35:51.442
!MESSAGE Checkstyle-Plugin: cannot initialize module io.spring.javaformat.checkstyle.SpringChecks - Unable to instantiate 'io.spring.javaformat.checkstyle.SpringChecks' class, it is also not possible to instantiate it as null. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
!STACK 0
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module io.spring.javaformat.checkstyle.SpringChecks - Unable to instantiate 'io.spring.javaformat.checkstyle.SpringChecks' class, it is also not possible to instantiate it as null. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
	at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:460)
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:198)
	at net.sf.eclipsecs.core.builder.CheckerFactory.createCheckerInternal(CheckerFactory.java:299)
	at net.sf.eclipsecs.core.builder.CheckerFactory.createChecker(CheckerFactory.java:133)
	at net.sf.eclipsecs.core.builder.Auditor.runAudit(Auditor.java:141)
	at net.sf.eclipsecs.core.builder.CheckstyleBuilder.handleBuildSelection(CheckstyleBuilder.java:306)
	at net.sf.eclipsecs.core.jobs.RunCheckstyleOnFilesJob.runInWorkspace(RunCheckstyleOnFilesJob.java:119)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate 'io.spring.javaformat.checkstyle.SpringChecks' class, it is also not possible to instantiate it as null. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
	at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:208)
	at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:450)
	... 8 more

I have no idea what I did wrong :-(
Can someone help me ?
Thanks for your help.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions