Issue Details (XML | Word | Printable)

Key: MCHECKSTYLE-54
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Dennis Lundberg
Reporter: Stephen Duncan Jr
Votes: 18
Watchers: 11
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Checkstyle Plugin

checkstyle:check does not see provided scope dependencies

Created: 01/Sep/06 08:32 AM   Updated: 03/May/09 01:22 PM
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.2

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive MCHECKSTYLE-54.zip (1 kB)
2. Text File requires-dep-resolution.patch (0.6 kB)

Issue Links:
Related
 


 Description  « Hide
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.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Yoav Shapira added a comment - 02/Mar/07 01:46 PM
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


Stephen Duncan Jr added a comment - 02/Mar/07 04:45 PM
Indeed, I reported this against Maven 2.0.4; the version meant version 2.1 of the checkstyle plugin.

Dennis Lundberg added a comment - 03/Mar/07 04:35 PM
Do you have includeTestSourceDirectory set to true in your plugin configuration?

Yoav Shapira added a comment - 13/Mar/07 01:19 PM
I didn't have includeTestSourceDirectory set before. Now I've tried setting it, and it makes no difference.

Yoav Shapira added a comment - 26/Apr/07 08:29 AM
This issue still happens with Maven 2.0.5 and 2.0.6 on Windows XP, JDK5 and JDK6 both tested.

Vladimir Pertu added a comment - 31/Jan/08 07:17 AM
The issue is still present with following setup:

Maven version: 2.0.8, Java version: 1.5.0_14


Dennis Lundberg added a comment - 03/Feb/08 05:30 AM
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.


Benjamin Bentmann added a comment - 03/Feb/08 05:33 AM
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.


Benjamin Bentmann added a comment - 03/Feb/08 05:42 AM

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.


Dennis Lundberg added a comment - 03/Feb/08 05:47 AM
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.


fabrice added a comment - 29/Apr/09 03:10 AM
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

Dennis Lundberg added a comment - 03/May/09 01:22 PM
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.