Search code examples
maven-2maven-plugincheckstyle

Maven 2 Checkstyle configLocation


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?


Solution

  • 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.