Maven 2.x Checkstyle Plugin

checkstyle:check does not see provided scope dependencies

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 2.1
  • Fix Version/s: 2.2
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    2

Description

Running checkstyle:check against a project that uses Exceptions from dependencies that are provided scope causes checktyle errors such as the following:

<file name="/share/duncans/workspace/eclipse/cdcie-webapp-feedreader/src/main/java/mil/jfcom/cie/portal/feedreader/converter/ConverterImpl.java">
<error line="0" severity="error" message="Got an exception - java.lang.RuntimeException: Unable to get class information for ValidationException." source="com.puppyc
rawl.tools.checkstyle.TreeWalker"/>

These errors go away when the scope is changed to compile. This does not happen for checkstyle:checkstyle; the report correct indicates no checkstyle errors. This is preventing us from using the checkstyle plugin to enforce checkstyle rules.

Issue Links

Activity

Hide
Yoav Shapira added a comment -

This issue also affects Maven 2.0.4 and 2.0.5, not just 2.1. I've tested and confirmed the presence of this issue on Windows XP and Linux (Fedora Core), JDK 5 and JDK 6 alike. I've sent full details of my situation to the Maven users list just now.

Having <scope>provided</scope> is fairly common, as you know. Many Java webapps, for example, include the servlet-api, jsp-api, and related jars with provided scope on their classpath. So here's my vote for fixing it soon

Show
Yoav Shapira added a comment - This issue also affects Maven 2.0.4 and 2.0.5, not just 2.1. I've tested and confirmed the presence of this issue on Windows XP and Linux (Fedora Core), JDK 5 and JDK 6 alike. I've sent full details of my situation to the Maven users list just now. Having <scope>provided</scope> is fairly common, as you know. Many Java webapps, for example, include the servlet-api, jsp-api, and related jars with provided scope on their classpath. So here's my vote for fixing it soon
Hide
Stephen Duncan Jr added a comment -

Indeed, I reported this against Maven 2.0.4; the version meant version 2.1 of the checkstyle plugin.

Show
Stephen Duncan Jr added a comment - Indeed, I reported this against Maven 2.0.4; the version meant version 2.1 of the checkstyle plugin.
Hide
Dennis Lundberg added a comment -

Do you have includeTestSourceDirectory set to true in your plugin configuration?

Show
Dennis Lundberg added a comment - Do you have includeTestSourceDirectory set to true in your plugin configuration?
Hide
Yoav Shapira added a comment -

I didn't have includeTestSourceDirectory set before. Now I've tried setting it, and it makes no difference.

Show
Yoav Shapira added a comment - I didn't have includeTestSourceDirectory set before. Now I've tried setting it, and it makes no difference.
Hide
Yoav Shapira added a comment -

This issue still happens with Maven 2.0.5 and 2.0.6 on Windows XP, JDK5 and JDK6 both tested.

Show
Yoav Shapira added a comment - This issue still happens with Maven 2.0.5 and 2.0.6 on Windows XP, JDK5 and JDK6 both tested.
Hide
Vladimir Pertu added a comment -

The issue is still present with following setup:

Maven version: 2.0.8, Java version: 1.5.0_14

Show
Vladimir Pertu added a comment - The issue is still present with following setup: Maven version: 2.0.8, Java version: 1.5.0_14
Hide
Dennis Lundberg added a comment -

I have committed a fix for this in r617973.

A new 2.2-SNAPSHOT has been deployed to the snapshot-repository. Please give that version a try to verify that this issue has been properly resolved.

Show
Dennis Lundberg added a comment - I have committed a fix for this in r617973. A new 2.2-SNAPSHOT has been deployed to the snapshot-repository. Please give that version a try to verify that this issue has been properly resolved.
Hide
Benjamin Bentmann added a comment -

Attached are a demo project and a fix.

Using the demo project and the unpatched plugin, the following behavior occurred (with Maven 2.0.8):
Running mvn clean checkstyle:checkstyle failed to locate the compile-time dependency on log4j whereas mvn clean compile runs checkstyle as part of the default lifecycle and succeeds.

Show
Benjamin Bentmann added a comment - Attached are a demo project and a fix. Using the demo project and the unpatched plugin, the following behavior occurred (with Maven 2.0.8): Running mvn clean checkstyle:checkstyle failed to locate the compile-time dependency on log4j whereas mvn clean compile runs checkstyle as part of the default lifecycle and succeeds.
Hide
Benjamin Bentmann added a comment -

I have committed a fix for this in r617973.

I was a few minutes too late... anyway, take it as as "worked for me" feedback then.

By the way, I wonder whether @requiresDependencyResolution is really required for the CheckstyleViolationCheckMojo. It does not invoke Checkstyle directly but forks the CheckstyleReport mojo which in turn gets the dependencies via its on annotation.

Show
Benjamin Bentmann added a comment -
I have committed a fix for this in r617973.
I was a few minutes too late... anyway, take it as as "worked for me" feedback then. By the way, I wonder whether @requiresDependencyResolution is really required for the CheckstyleViolationCheckMojo. It does not invoke Checkstyle directly but forks the CheckstyleReport mojo which in turn gets the dependencies via its on annotation.
Hide
Dennis Lundberg added a comment -

Thanks Benjamin.

I wasn't sure myself whether the annotation was required in CheckstyleViolationCheckMojo, but I figured it can't harm to have it there.

Show
Dennis Lundberg added a comment - Thanks Benjamin. I wasn't sure myself whether the annotation was required in CheckstyleViolationCheckMojo, but I figured it can't harm to have it there.
Hide
fabrice added a comment -

Is is noted as fixed but I use maven 2.0.9 and checkstyle maven plugin 2.2 and I still have the same error

Show
fabrice added a comment - Is is noted as fixed but I use maven 2.0.9 and checkstyle maven plugin 2.2 and I still have the same error
Hide
Dennis Lundberg added a comment -

fabrice,

This issue has been verified and closed. If you think it should be reopened you need to provide us with a sample project that can be used to reproduce the problems.

Show
Dennis Lundberg added a comment - fabrice, This issue has been verified and closed. If you think it should be reopened you need to provide us with a sample project that can be used to reproduce the problems.

People

Vote (18)
Watch (11)

Dates

  • Created:
    Updated:
    Resolved: