maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Whelan (JIRA)" <j...@codehaus.org>
Subject [jira] Commented: (MCHECKSTYLE-163) Test classpath resolution fails in mvn check:check when includeTestSourceDirectory = true
Date Wed, 03 Aug 2011 06:07:42 GMT

    [ https://jira.codehaus.org/browse/MCHECKSTYLE-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=274868#comment-274868
] 

Chris Whelan commented on MCHECKSTYLE-163:
------------------------------------------

Example log with patch applied.  Note that build now fails for the correct reason and all
four Redundant throws errors are shown in the console.

C:\Working\MCHECKSTYLE-163>mvn clean verify
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for sample:sample:pom:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin
is missing. @ line 47, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability
of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed
projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Example project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ sample ---
[INFO] Deleting C:\Working\MCHECKSTYLE-163\target
[INFO]
[INFO] --- maven-checkstyle-plugin:2.7-SNAPSHOT:check (checkstyle-verify) @ sample ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform
dependent!
[INFO] Starting audit...
C:\Working\MCHECKSTYLE-163\src\test\java\sample\Example.java:7:59: warning: Redundant throws:
'InitializationError' is subclass of 'Exception'.
C:\Working\MCHECKSTYLE-163\src\test\java\sample\Example.java:11:60: warning: Redundant throws:
'IllegalArgumentException' is subclass of 'Exception'.
C:\Working\MCHECKSTYLE-163\src\test\java\sample\Example.java:11:60: warning: Redundant throws:
'IllegalArgumentException' is unchecked exception.
C:\Working\MCHECKSTYLE-163\src\test\java\sample\Example.java:13:74: warning: Redundant throws:
'IllegalArgumentException' is unchecked exception.
Audit done.

[ERROR] Example.java[7:59] Redundant throws: 'InitializationError' is subclass of 'Exception'.
[ERROR] Example.java[11:60] Redundant throws: 'IllegalArgumentException' is subclass of 'Exception'.
[ERROR] Example.java[11:60] Redundant throws: 'IllegalArgumentException' is unchecked exception.
[ERROR] Example.java[13:74] Redundant throws: 'IllegalArgumentException' is unchecked exception.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.500s
[INFO] Finished at: Wed Aug 03 13:58:55 SGT 2011
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.7-SNAPSHOT:check
(checkstyle-verify) on project sample: You have 4 Checkstyle violations. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following
articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

> Test classpath resolution fails in mvn check:check when includeTestSourceDirectory =
true
> -----------------------------------------------------------------------------------------
>
>                 Key: MCHECKSTYLE-163
>                 URL: https://jira.codehaus.org/browse/MCHECKSTYLE-163
>             Project: Maven 2.x Checkstyle Plugin
>          Issue Type: Bug
>    Affects Versions: 2.7
>            Reporter: Chris Whelan
>         Attachments: MCHECKSTYLE-163.zip, resolveTestClasspath.patch
>
>
> When includeTestSourceDirectory=true is set for maven-checkstyle-plugin, the full test
classpath should be made available to checkstyle.  Patch included to resolve issue by setting
@requiresDependencyResolution to test.
> In DefaultCheckstyleExecutor.java the checker.setClassLoader() is configured using the
classpath string from request.getProject().getTestClasspathElements() (see DefaultCheckstyleExecutor
line 114).
> However, the CheckstyleViolationCheckMojo only has @requiresDependencyResolution compile
which means that pom dependencies which have been declared as <scope>test</scope>
are not returned by project.getTestClasspathElements().
> This is a particular issue for the checkstyle RedundantThrows check (http://checkstyle.sourceforge.net/config_coding.html#RedundantThrows)
as it requires all Exceptions to be available on it's classpath.
> If code throws an Exception which has been imported from a maven <scope>test</scope>
dependency, the exception will not be available on the classpath and this checkstyle check
will fail.
> Example:
> Include junit as a test scope dependency in the project POM:
> <dependency>
>   <groupId>junit</groupId>
>   <artifactId>junit</artifactId>
>   <version>${junit.version}</version>
>   <scope>test</scope>
> </dependency>
> Throw any junit exception within project test code, e.g.:
> public class MyCustomTestRunner extends BlockJUnit4ClassRunner {
> 	public MyCustomTestRunner(final Class<?> klass) throws InitializationError {
> If RedundantThrows check is enabled, the following error will be thrown:
> [INFO] --- maven-checkstyle-plugin:2.7-SNAPSHOT:check (checkstyle-verify) @ sample-project
---
> [INFO] Starting audit...
> C:\Working\hg\sample-project\src\test\java\com\sample\support\junit\MyCustomTestRunner.java:28:72:
warning: Unable to get class information for InitializationError.
> Audit done.
> [ERROR] MyCustomTestRunner.java[28:72] Unable to get class information for InitializationError.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message