You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2014/02/27 20:30:32 UTC

svn commit: r1572714 - /maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java

Author: struberg
Date: Thu Feb 27 19:30:32 2014
New Revision: 1572714

URL: http://svn.apache.org/r1572714
Log:
MCHECKSTYLE-211 fix code style and add JavaDoc

Modified:
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java?rev=1572714&r1=1572713&r2=1572714&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java Thu Feb 27 19:30:32 2014
@@ -385,6 +385,30 @@ public class CheckstyleViolationCheckMoj
     @Parameter( property = "checkstyle.includeTestResources", defaultValue = "true", required = true )
     private boolean includeTestResources = true;
 
+    /**
+     * By using this property, you can specify the whole checkstyle rules
+     * inline directly inside this pom.
+     *
+     * <pre>
+     * &lt;plugin&gt;
+     *   ...
+     *   &lt;configuration&gt;
+     *     &lt;checkstyleRules&gt;
+     *       &lt;module name="Checker"&gt;
+     *         &lt;module name="FileTabCharacter"&gt;
+     *           &lt;property name="eachLine" value="true" /&gt;
+     *         &lt;/module&gt;
+     *         &lt;module name="TreeWalker"&gt;
+     *           &lt;module name="EmptyBlock"/&gt;
+     *         &lt;/module&gt;
+     *       &lt;/module&gt;
+     *     &lt;/checkstyleRules&gt;
+     *   &lt;/configuration&gt;
+     *   ...
+     * </pre>
+     *
+     * @since 2.12
+     */
     @Parameter
     private PlexusConfiguration checkstyleRules;
 
@@ -407,26 +431,26 @@ public class CheckstyleViolationCheckMoj
             if ( !skipExec )
             {
 
-                if (checkstyleRules != null)
+                if ( checkstyleRules != null )
                 {
-                    if (!"config/sun_checks.xml".equals(configLocation))
+                    if ( ! "config/sun_checks.xml".equals( configLocation ) )
                     {
-                        throw new MojoExecutionException("If you use inline configuration for rules don't specify a configLocation");
+                        throw new MojoExecutionException( "If you use inline configuration for rules don't specify a configLocation" );
                     }
-                    if (checkstyleRules.getChildCount() > 1)
+                    if ( checkstyleRules.getChildCount() > 1 )
                     {
-                        throw new MojoExecutionException("Currently only one root module is supported");
+                        throw new MojoExecutionException( "Currently only one root module is supported" );
                     }
-                    PlexusConfiguration checkerModule = checkstyleRules.getChild(0);
+                    PlexusConfiguration checkerModule = checkstyleRules.getChild( 0 );
 
                     try
                     {
-                        FileUtils.forceMkdir(rulesFiles.getParentFile());
-                        FileUtils.fileWrite(rulesFiles, CHECKSTYLE_FILE_HEADER + checkerModule.toString());
+                        FileUtils.forceMkdir( rulesFiles.getParentFile() );
+                        FileUtils.fileWrite( rulesFiles, CHECKSTYLE_FILE_HEADER + checkerModule.toString() );
                     }
-                    catch (final IOException e)
+                    catch ( final IOException e )
                     {
-                        throw new MojoExecutionException(e.getMessage(), e);
+                        throw new MojoExecutionException( e.getMessage(), e );
                     }
                     configLocation = rulesFiles.getAbsolutePath();
                 }