Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven 2 checkstyle plugin version 2.5 - Problem with configLocation

I am using checkstyle plugin in maven 2. I now want to switch my config file, from the default one to a) an online file, or b) a local file. I tried the following two things, which both didnt work. Any suggestions?

A) Local file, which is directly in my project folder next to the pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <configuration>
        <configLocation>checkstyle.xml</configLocation>
    </configuration>
</plugin>

B) Remote file, that is stored on a server

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <configuration>
        <configLocation>http://stud.hs-heilbronn.de/~nischmid/development/checkstyle-config.xml</configLocation>
    </configuration>
</plugin>

Both cases result in an error like this:

[INFO] An error has occurred in Checkstyle report generation. Embedded error: Failed during checkstyle execution Could not find resource 'file:checkstyle.xml'.

Any help would be appreciated!

like image 544
Nils Schmidt Avatar asked Feb 17 '10 10:02

Nils Schmidt


People also ask

How do I fix Checkstyle violation in IntelliJ?

Go to Settings|Editor|Code Style, choose a code style you want to import CheckStyle configuration to. Click on the gear, then 'import scheme', choose "CheckStyle Configuration" and select a corresponding CheckStyle configuration file. Click OK.


1 Answers

I've seen several issues related to configLocation in Jira with the version 2.5 of the plugin (like MCHECKSTYLE-129 or MCHECKSTYLE-131), both a) and b) just work fine with the version 2.4.

So, unless you're using Maven 3, I suggest to rollback to 2.4 for now:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>2.4</version>
  <configuration>
    <configLocation>checkstyle.xml</configLocation>
  </configuration>
</plugins>

or

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>2.4</version>
  <configuration>
    <configLocation>http://stud.hs-heilbronn.de/~nischmid/development/checkstyle-config.xml</configLocation>
  </configuration>
</plugin>

As a side note, for a multi-modules build, have a look at the Multimodule Configuration.

like image 157
Pascal Thivent Avatar answered Sep 19 '22 15:09

Pascal Thivent