views:

1434

answers:

3

Hi,

i have a project which has as maven dependency a jar file which includes a xml file where i stored my rules for checkstyle. I thought it would be ok to just use this configuration: <configLocation>mycheckstyle.xml</configLocation>. My understanding is that the file should be searched on the classpath and my jar file is a Maven dependency so it should be found, however i get a resource not found exception. Any suggestions? Thanks in advance..

kuku

A: 

As explained in the Checkstyle plugin page,

configLocation :

Specifies the location of the XML configuration to use.

Potential values are a filesystem path, a URL, or a classpath resource.

I never did that on my project...

Are you sure that the JAR containing the XML file is in the classpath when the checkstyle plugin is starting?

romaintaz
A: 

I'm having a parent which specifies the checkstyle plugin and has in its resource folder the appropriate mycheckstyle.xml. I use the maven assembly plugin to make a jar of my parents resource folder and define that jar as a dependency in my child. So when the child inherits the checkstyle plugin + it's configuration from the parent it should be able to find the mycheckstyle.xml. I have followed the instructions on the checkstyle plugin page but it didn't work.

kukudas
You mean you did what is explained here: http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html ?Can you edit your initial post and put some pom.xml information in it...
romaintaz
No not exactly like this. It's not multi module. It is simple inheritence a parent to a child. The parent has the checkstyle plugin within its reporting tag and the child gets it inherited. I add the resources from the parent as jar to the child to have the configuration files.
kukudas
+5  A: 

Try adding a dependencies section to your plugin configuration.

E.g.,

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <dependencies>
      <dependency>
        <groupId>com.example.whizbang</groupId>
        <artifactId>build-tools</artifactId>
        <version>1.0</version>
      </dependency>
    </dependencies>
  </plugin>

See Maven Checkstyle Plugin - Multimodule Configuration for more information.

Clay
This is the correct answer.
Brian Fox