Author: dennisl Date: Tue Mar 3 10:46:17 2015 New Revision: 1663618 URL: http://svn.apache.org/r1663618 Log: [MCHECKSTYLE-286] Add info on ruleset used in console output
- I also modified the message to correct when there is exactly 1 error Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/package-info.java - copied, changed from r1663588, maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-214-basedir-resource/verify.groovy maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-70-multi-sourcefolder/verify.groovy maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/MyClass.java maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/verify.groovy maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/exec/DefaultCheckstyleExecutor.java Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-214-basedir-resource/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-214-basedir-resource/verify.groovy?rev=1663618&r1=1663617&r2=1663618&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-214-basedir-resource/verify.groovy (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-214-basedir-resource/verify.groovy Tue Mar 3 10:46:17 2015 @@ -20,7 +20,7 @@ def buildLog = new File( basedir, 'build.log' ) // LICENSE.txt has 2 errors, src/main/resources/README.txt has 1 error -assert buildLog.text.contains( "[INFO] There are 3 checkstyle errors." ) +assert buildLog.text.contains( "[INFO] There are 3 errors reported by Checkstyle" ) def checkstyle = new XmlSlurper().parse( new File( basedir, "target/checkstyle-result.xml" ) ) assert 2 == checkstyle.file.size() Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-70-multi-sourcefolder/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-70-multi-sourcefolder/verify.groovy?rev=1663618&r1=1663617&r2=1663618&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-70-multi-sourcefolder/verify.groovy (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-70-multi-sourcefolder/verify.groovy Tue Mar 3 10:46:17 2015 @@ -20,4 +20,4 @@ def buildLog = new File( basedir, 'build.log' ) // 3 errors in src/additional/java and 2 errors in src/test-additional/java -assert buildLog.text.contains( "[INFO] There are 5 checkstyle errors." ) +assert buildLog.text.contains( "[INFO] There are 5 errors reported by Checkstyle" ) Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/MyClass.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/MyClass.java?rev=1663618&r1=1663617&r2=1663618&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/MyClass.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/MyClass.java Tue Mar 3 10:46:17 2015 @@ -19,6 +19,9 @@ package org; * under the License. */ +/** + * My class. + */ public class MyClass { } Copied: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/package-info.java (from r1663588, maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java) URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/package-info.java?p2=maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/package-info.java&p1=maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java&r1=1663588&r2=1663618&rev=1663618&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/src/main/java/org/package-info.java Tue Mar 3 10:46:17 2015 @@ -1,7 +1,7 @@ /** * Nothing very important here, only a file for checkstyle rule PackageInfo. */ -package com.company.example; +package org; /* * Licensed to the Apache Software Foundation (ASF) under one Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/verify.groovy?rev=1663618&r1=1663617&r2=1663618&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/verify.groovy (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-fail/verify.groovy Tue Mar 3 10:46:17 2015 @@ -19,4 +19,4 @@ */ def buildLog = new File( basedir, 'build.log' ) -assert buildLog.text.contains( "[INFO] There are 3 checkstyle errors." ) +assert buildLog.text.contains( "[INFO] There is 1 error reported by Checkstyle" ) Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/exec/DefaultCheckstyleExecutor.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/exec/DefaultCheckstyleExecutor.java?rev=1663618&r1=1663617&r2=1663618&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/exec/DefaultCheckstyleExecutor.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/exec/DefaultCheckstyleExecutor.java Tue Mar 3 10:46:17 2015 @@ -279,18 +279,43 @@ public class DefaultCheckstyleExecutor if ( nbErrors > 0 ) { - String message = "There are " + nbErrors + " checkstyle errors."; + StringBuffer message = new StringBuffer( "There " ); + if ( nbErrors == 1 ) + { + message.append( "is" ); + } + else + { + message.append( "are" ); + } + message.append( " " ); + message.append( nbErrors ); + message.append( " error" ); + if ( nbErrors != 1 ) + { + message.append( "s" ); + } + message.append( " reported by Checkstyle" ); + String version = getCheckstyleVersion(); + if ( version != null ) + { + message.append( " " ); + message.append( version ); + } + message.append( " with " ); + message.append( request.getConfigLocation() ); + message.append( " ruleset." ); if ( request.isFailsOnError() ) { // TODO: should be a failure, not an error. Report is not meant to // throw an exception here (so site would // work regardless of config), but should record this information - throw new CheckstyleExecutorException( message ); + throw new CheckstyleExecutorException( message.toString() ); } else { - getLogger().info( message ); + getLogger().info( message.toString() ); } } @@ -464,6 +489,19 @@ public class DefaultCheckstyleExecutor return false; } + /** + * Get the effective Checkstyle version at runtime. + * @return the MANIFEST implementation version of Checkstyle API package (can be <code>null</code>) + * + *@todo Copied from CheckstyleReportGenerator - move to a utility class + */ + private String getCheckstyleVersion() + { + Package checkstyleApiPackage = Configuration.class.getPackage(); + + return ( checkstyleApiPackage == null ) ? null : checkstyleApiPackage.getImplementationVersion(); + } + private Properties getOverridingProperties( CheckstyleExecutorRequest request ) throws CheckstyleExecutorException {