views:

1195

answers:

2

Hi there,

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&lt;/configLocation&gt;
    </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!

+1  A: 

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&lt;/configLocation&gt;
  </configuration>
</plugin>

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

Pascal Thivent
Swithing back to version 2.4 did solve problem a), however problem b) resists. I followed the instructions given in MCHECKSTYLE-129 which solved problem b). So I have checkstyle plugin version 2.5 with plexus-resources 1.0-alpha-7-SNAPSHOT and everything works fine. Thanks Pascal!
Nils Schmidt
@Nils Weird, I tested b) with your URL and it worked for me with 2.4. Anyway, if you solved it with 2.5 by adding the plexus-resources dependency, that's fine :)
Pascal Thivent
A: 

Where have you placed the file checkstyle.xml? Because I have the same error et I have placed the file in resources folder

nico
As mentioned in the comment above: Swithing back to version 2.4 did solve problem a), however problem b) resists. I followed the instructions given in MCHECKSTYLE-129 which solved problem b). So I have checkstyle plugin version 2.5 with plexus-resources 1.0-alpha-7-SNAPSHOT and everything works fine.BUT: Now I am using 1.0-alpha-8-SNAPSHOT (seven is no longer in alpha status). In my case the checkstyle config is on my university server.
Nils Schmidt