You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ni...@apache.org on 2009/05/18 10:48:04 UTC
svn commit: r775863 -
/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
Author: nicolas
Date: Mon May 18 08:48:04 2009
New Revision: 775863
URL: http://svn.apache.org/viewvc?rev=775863&view=rev
Log:
MCHECKSTYLE-110
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=775863&r1=775862&r2=775863&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 Mon May 18 08:48:04 2009
@@ -19,6 +19,11 @@
* under the License.
*/
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -27,11 +32,6 @@
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-
/**
* Perform a violation check against the last Checkstyle run to see if there are
* any violations. It reads the Checkstyle output file, counts the number of
@@ -89,6 +89,15 @@
*/
private boolean skip;
+
+ /**
+ * Ouput detected violations in the console
+ *
+ * @parameter expression="${checkstyle.console}" default-value="false"
+ * @since 2.3
+ */
+ private boolean logViolationsToConsole;
+
/**
* @see org.apache.maven.plugin.Mojo#execute()
*/
@@ -149,11 +158,30 @@
int count = 0;
int eventType = xpp.getEventType();
+ String file = "";
while ( eventType != XmlPullParser.END_DOCUMENT )
{
+ if ( eventType == XmlPullParser.START_TAG && "file".equals( xpp.getName() ) )
+ {
+ file = xpp.getAttributeValue( "", "name" );
+ file = file.substring( file.lastIndexOf( File.separatorChar ) + 1 );
+ }
+
if ( eventType == XmlPullParser.START_TAG && "error".equals( xpp.getName() )
&& isViolation( xpp.getAttributeValue( "", "severity" ) ) )
{
+ if ( logViolationsToConsole )
+ {
+ StringBuffer stb = new StringBuffer();
+ stb.append( file );
+ stb.append( '[' );
+ stb.append( xpp.getAttributeValue( "", "line" ) );
+ stb.append( ':' );
+ stb.append( xpp.getAttributeValue( "", "column" ) );
+ stb.append( "] " );
+ stb.append( xpp.getAttributeValue( "", "message" ) );
+ getLog().error( stb.toString() );
+ }
count++;
}
eventType = xpp.next();
Re: svn commit: r775863 - /maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
Posted by nicolas de loof <ni...@gmail.com>.
svn log edited
Cheers,
Nicolas
2009/5/18 Lukas Theussl <lt...@apache.org>
>
> Hi Nicolas,
>
> Please also log a short description of the commit in addition to the issue
> number, not everybody knows by heart what a specific issue is about... ;)
> See [1] for a template.
>
> Thanks,
> -Lukas
>
>
> [1] http://maven.apache.org/developers/conventions/svn.html
>
>
> nicolas@apache.org wrote:
>
>> Author: nicolas
>> Date: Mon May 18 08:48:04 2009
>> New Revision: 775863
>>
>> URL: http://svn.apache.org/viewvc?rev=775863&view=rev
>> Log:
>> MCHECKSTYLE-110
>>
>> 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=775863&r1=775862&r2=775863&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
>> Mon May 18 08:48:04 2009
>> @@ -19,6 +19,11 @@
>> * under the License.
>> */
>> +import java.io.BufferedReader;
>> +import java.io.File;
>> +import java.io.IOException;
>> +import java.io.Reader;
>> +
>> import org.apache.maven.plugin.AbstractMojo;
>> import org.apache.maven.plugin.MojoExecutionException;
>> import org.apache.maven.plugin.MojoFailureException;
>> @@ -27,11 +32,6 @@
>> import org.codehaus.plexus.util.xml.pull.XmlPullParser;
>> import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
>> -import java.io.BufferedReader;
>> -import java.io.File;
>> -import java.io.IOException;
>> -import java.io.Reader;
>> -
>> /**
>> * Perform a violation check against the last Checkstyle run to see if
>> there are
>> * any violations. It reads the Checkstyle output file, counts the number
>> of
>> @@ -89,6 +89,15 @@
>> */
>> private boolean skip;
>> +
>> + /**
>> + * Ouput detected violations in the console
>> + *
>> + * @parameter expression="${checkstyle.console}"
>> default-value="false"
>> + * @since 2.3
>> + */
>> + private boolean logViolationsToConsole;
>> +
>> /**
>> * @see org.apache.maven.plugin.Mojo#execute()
>> */
>> @@ -149,11 +158,30 @@
>> int count = 0;
>> int eventType = xpp.getEventType();
>> + String file = "";
>> while ( eventType != XmlPullParser.END_DOCUMENT )
>> {
>> + if ( eventType == XmlPullParser.START_TAG && "file".equals(
>> xpp.getName() ) )
>> + {
>> + file = xpp.getAttributeValue( "", "name" );
>> + file = file.substring( file.lastIndexOf(
>> File.separatorChar ) + 1 );
>> + }
>> +
>> if ( eventType == XmlPullParser.START_TAG && "error".equals(
>> xpp.getName() )
>> && isViolation( xpp.getAttributeValue( "", "severity" ) )
>> )
>> {
>> + if ( logViolationsToConsole )
>> + {
>> + StringBuffer stb = new StringBuffer();
>> + stb.append( file );
>> + stb.append( '[' );
>> + stb.append( xpp.getAttributeValue( "", "line" ) );
>> + stb.append( ':' );
>> + stb.append( xpp.getAttributeValue( "", "column" ) );
>> + stb.append( "] " );
>> + stb.append( xpp.getAttributeValue( "", "message" ) );
>> + getLog().error( stb.toString() );
>> + }
>> count++;
>> }
>> eventType = xpp.next();
>>
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
Re: svn commit: r775863 - /maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
Posted by Lukas Theussl <lt...@apache.org>.
Hi Nicolas,
Please also log a short description of the commit in addition to the issue number,
not everybody knows by heart what a specific issue is about... ;) See [1] for a
template.
Thanks,
-Lukas
[1] http://maven.apache.org/developers/conventions/svn.html
nicolas@apache.org wrote:
> Author: nicolas
> Date: Mon May 18 08:48:04 2009
> New Revision: 775863
>
> URL: http://svn.apache.org/viewvc?rev=775863&view=rev
> Log:
> MCHECKSTYLE-110
>
> 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=775863&r1=775862&r2=775863&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 Mon May 18 08:48:04 2009
> @@ -19,6 +19,11 @@
> * under the License.
> */
>
> +import java.io.BufferedReader;
> +import java.io.File;
> +import java.io.IOException;
> +import java.io.Reader;
> +
> import org.apache.maven.plugin.AbstractMojo;
> import org.apache.maven.plugin.MojoExecutionException;
> import org.apache.maven.plugin.MojoFailureException;
> @@ -27,11 +32,6 @@
> import org.codehaus.plexus.util.xml.pull.XmlPullParser;
> import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
>
> -import java.io.BufferedReader;
> -import java.io.File;
> -import java.io.IOException;
> -import java.io.Reader;
> -
> /**
> * Perform a violation check against the last Checkstyle run to see if there are
> * any violations. It reads the Checkstyle output file, counts the number of
> @@ -89,6 +89,15 @@
> */
> private boolean skip;
>
> +
> + /**
> + * Ouput detected violations in the console
> + *
> + * @parameter expression="${checkstyle.console}" default-value="false"
> + * @since 2.3
> + */
> + private boolean logViolationsToConsole;
> +
> /**
> * @see org.apache.maven.plugin.Mojo#execute()
> */
> @@ -149,11 +158,30 @@
> int count = 0;
>
> int eventType = xpp.getEventType();
> + String file = "";
> while ( eventType != XmlPullParser.END_DOCUMENT )
> {
> + if ( eventType == XmlPullParser.START_TAG && "file".equals( xpp.getName() ) )
> + {
> + file = xpp.getAttributeValue( "", "name" );
> + file = file.substring( file.lastIndexOf( File.separatorChar ) + 1 );
> + }
> +
> if ( eventType == XmlPullParser.START_TAG && "error".equals( xpp.getName() )
> && isViolation( xpp.getAttributeValue( "", "severity" ) ) )
> {
> + if ( logViolationsToConsole )
> + {
> + StringBuffer stb = new StringBuffer();
> + stb.append( file );
> + stb.append( '[' );
> + stb.append( xpp.getAttributeValue( "", "line" ) );
> + stb.append( ':' );
> + stb.append( xpp.getAttributeValue( "", "column" ) );
> + stb.append( "] " );
> + stb.append( xpp.getAttributeValue( "", "message" ) );
> + getLog().error( stb.toString() );
> + }
> count++;
> }
> eventType = xpp.next();
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org