You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vs...@apache.org on 2005/09/09 15:31:56 UTC
svn commit: r279769 - in
/maven/components/trunk/maven-plugins/maven-checkstyle-plugin: pom.xml
src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
src/main/resources/log4j.properties
Author: vsiveton
Date: Fri Sep 9 06:31:51 2005
New Revision: 279769
URL: http://svn.apache.org/viewcvs?rev=279769&view=rev
Log:
Corrected getConfigFile() by specifying sun as default config file; added log4j.properties to remove warn for org.apache.commons.beanutils.BeanUtils; formated code; added copyright to pom.xml
Added:
maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/resources/log4j.properties (with props)
Modified:
maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml
maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
Modified: maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml?rev=279769&r1=279768&r2=279769&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml (original)
+++ maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml Fri Sep 9 06:31:51 2005
@@ -1,4 +1,25 @@
-<project>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-plugin-parent</artifactId>
@@ -52,4 +73,16 @@
<version>1.0.3</version>
</dependency>
</dependencies>
+ <developers>
+ <developer>
+ <id>vsiveton</id>
+ <name>Vincent Siveton</name>
+ <email>vsiveton@apache.org</email>
+ <organization>Apache Software Foundation</organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ <timezone>-5</timezone>
+ </developer>
+ </developers>
</project>
Modified: maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java?rev=279769&r1=279768&r2=279769&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java (original)
+++ maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java Fri Sep 9 06:31:51 2005
@@ -47,11 +47,11 @@
import java.util.Properties;
import java.util.ResourceBundle;
-
/**
* @goal checkstyle
*
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: DependenciesReport.java,v 1.2 2005/02/23 00:08:02 brett Exp $
*/
public class CheckstyleReport
@@ -64,7 +64,7 @@
* @required
*/
private String outputDirectory;
-
+
/**
* Specifies the names filter of the source files to be used for checkstyle
*
@@ -72,14 +72,14 @@
* @required
*/
private String includes;
-
+
/**
* Specifies the names filter of the source files to be excluded for checkstyle
- *
+ *
* @parameter
*/
private String excludes;
-
+
/**
* Specifies what predefined check set to use. Available sets are
* "sun" (for the Sun coding conventions), "turbine", and "avalon".
@@ -88,21 +88,21 @@
* @parameter default-value="sun"
*/
private String format;
-
+
/**
* Specifies the location of the checkstyle properties that will be used to check the source.
*
* @parameter
*/
private File propertiesFile;
-
+
/**
* Specifies the URL of the checkstyle properties that will be used to check the source.
*
* @parameter
*/
private URL propertiesURL;
-
+
/**
* Specifies the location of the License file (a.k.a. the header file) that is used by Checkstyle
* to verify that source code has the correct copyright.
@@ -117,7 +117,7 @@
* @parameter expression="${project.build.directory}/checkstyle-cachefile"
*/
private String cacheFile;
-
+
/**
* If null, the checkstyle task will display violations on stdout. Otherwise, the text file will be
* created with the violations. Note: This is in addition to the XML result file (containing
@@ -126,7 +126,7 @@
* @parameter
*/
private String useFile;
-
+
/**
* Specifies the location of the supperssions XML file to use. The plugin defines a Checkstyle
* property named <code>checkstyle.supperssions.file</code> with the value of this
@@ -136,7 +136,7 @@
* @parameter
*/
private String suppressionsFile;
-
+
/**
* Specifies the path and filename to save the checkstyle output. The format of the output file is
* determined by the <code>outputFileFormat</code>
@@ -155,7 +155,7 @@
/**
* Specifies the location of the package names XML to be used to configure Checkstyle
- *
+ *
* @parameter
*/
private String packageNamesFile;
@@ -166,7 +166,7 @@
* @parameter default-value="false"
*/
private boolean failsOnError;
-
+
/**
* Specifies the location of the source files to be used for Checkstyle
*
@@ -232,7 +232,8 @@
/**
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
- public void executeReport( Locale locale ) throws MavenReportException
+ public void executeReport( Locale locale )
+ throws MavenReportException
{
File[] files = getFilesToProcess( includes, excludes );
@@ -241,25 +242,27 @@
Properties overridingProperties = getOverridingProperties();
ModuleFactory moduleFactory = getModuleFactory();
-
+
FilterSet filterSet = getSuppressions();
-
+
Checker checker = null;
-
+
try
{
- Configuration config = ConfigurationLoader.loadConfiguration( configFile,
- new PropertiesExpander( overridingProperties ) );
+ Configuration config = ConfigurationLoader
+ .loadConfiguration( configFile, new PropertiesExpander( overridingProperties ) );
checker = new Checker();
- if ( moduleFactory != null ) checker.setModuleFactory( moduleFactory );
-
- if ( filterSet != null ) checker.addFilter( filterSet );
+ if ( moduleFactory != null )
+ checker.setModuleFactory( moduleFactory );
+
+ if ( filterSet != null )
+ checker.addFilter( filterSet );
checker.configure( config );
}
- catch( CheckstyleException ce )
+ catch ( CheckstyleException ce )
{
throw new MavenReportException( "Failed during checkstyle configuration", ce );
}
@@ -270,13 +273,13 @@
{
checker.addListener( listener );
}
-
+
if ( StringUtils.isNotEmpty( useFile ) )
{
File outputFile = new File( useFile );
-
+
OutputStream out = getOutputStream( outputFile );
-
+
checker.addListener( new DefaultLogger( out, true ) );
}
@@ -301,17 +304,18 @@
{
return "checkstyle";
}
-
- private AuditListener getListener() throws MavenReportException
+
+ private AuditListener getListener()
+ throws MavenReportException
{
AuditListener listener = null;
if ( StringUtils.isNotEmpty( outputFileFormat ) )
{
File resultFile = new File( outputFile );
-
+
OutputStream out = getOutputStream( resultFile );
-
+
if ( "xml".equals( outputFileFormat ) )
{
listener = new XMLLogger( out, true );
@@ -322,23 +326,26 @@
}
else
{
- throw new MavenReportException( "Invalid output file format: (" + outputFileFormat + "). Must be 'plain' or 'xml'." );
+ throw new MavenReportException( "Invalid output file format: (" + outputFileFormat
+ + "). Must be 'plain' or 'xml'." );
}
}
-
+
return listener;
}
-
- private OutputStream getOutputStream( File file ) throws MavenReportException
+
+ private OutputStream getOutputStream( File file )
+ throws MavenReportException
{
FileOutputStream out;
-
+
try
{
File parentFile = file.getParentFile();
-
- if ( !parentFile.exists() ) parentFile.mkdirs();
-
+
+ if ( !parentFile.exists() )
+ parentFile.mkdirs();
+
return new FileOutputStream( file );
}
catch ( IOException ioe )
@@ -347,27 +354,28 @@
}
}
- private File[] getFilesToProcess( String includes, String excludes ) throws MavenReportException
+ private File[] getFilesToProcess( String includes, String excludes )
+ throws MavenReportException
{
StringBuffer excludesStr = new StringBuffer();
-
+
if ( StringUtils.isNotEmpty( excludes ) )
{
- excludesStr.append(excludes);
+ excludesStr.append( excludes );
}
-
+
for ( int i = 0; i < DEFAULT_EXCLUDES.length; i++ )
{
if ( excludesStr.length() > 0 )
{
excludesStr.append( "," );
}
-
+
excludesStr.append( DEFAULT_EXCLUDES[i] );
}
List files;
-
+
try
{
files = FileUtils.getFiles( new File( sourceDirectory ), includes, excludesStr.toString() );
@@ -376,17 +384,18 @@
{
throw new MavenReportException( "Failed to get source files", ioe );
}
-
- return (File[]) ( files.toArray( new File[ 0 ] ) );
+
+ return (File[]) ( files.toArray( new File[0] ) );
}
- private Properties getOverridingProperties() throws MavenReportException
+ private Properties getOverridingProperties()
+ throws MavenReportException
{
Properties p = new Properties();
-
+
try
{
- if ( propertiesFile != null )
+ if ( propertiesFile != null )
{
p.load( new FileInputStream( propertiesFile ) );
}
@@ -405,37 +414,41 @@
{
throw new MavenReportException( "Failed to get overriding properties", e );
}
-
+
return p;
}
-
- private String getConfigFile() throws MavenReportException
+
+ private String getConfigFile()
+ throws MavenReportException
{
URL configFile;
-
- if ( "turbine".equalsIgnoreCase( format ) )
+
+ if ( StringUtils.isEmpty( format ) || ( "sun".equalsIgnoreCase( format.trim() ) ) )
{
- configFile = getClass().getResource( "/config/turbine_checks.xml" );
+ // By default
+ configFile = getClass().getResource( "/config/sun_checks.xml" );
}
- else if ( "avalon".equalsIgnoreCase( format ) )
+ else if ( "turbine".equalsIgnoreCase( format.trim() ) )
{
- configFile = getClass().getResource( "/config/avalon_checks.xml" );
+ configFile = getClass().getResource( "/config/turbine_checks.xml" );
}
- else if ( "".equalsIgnoreCase( format ) )
+ else if ( "avalon".equalsIgnoreCase( format.trim() ) )
{
- configFile = getClass().getResource( "/config/sun_checks.xml" );
+ configFile = getClass().getResource( "/config/avalon_checks.xml" );
}
else
{
throw new MavenReportException( "Invalid configuration file format: " + format );
}
-
+
return configFile.toString();
}
-
- private ModuleFactory getModuleFactory() throws MavenReportException
+
+ private ModuleFactory getModuleFactory()
+ throws MavenReportException
{
- if ( StringUtils.isEmpty( packageNamesFile ) ) return null;
+ if ( StringUtils.isEmpty( packageNamesFile ) )
+ return null;
try
{
@@ -446,11 +459,13 @@
throw new MavenReportException( "failed to load package names XML: " + packageNamesFile, ce );
}
}
-
- private FilterSet getSuppressions() throws MavenReportException
+
+ private FilterSet getSuppressions()
+ throws MavenReportException
{
- if ( StringUtils.isEmpty( suppressionsFile ) ) return null;
-
+ if ( StringUtils.isEmpty( suppressionsFile ) )
+ return null;
+
try
{
return SuppressionsLoader.loadSuppressions( suppressionsFile );
@@ -463,6 +478,6 @@
private static ResourceBundle getBundle( Locale locale )
{
- return ResourceBundle.getBundle("checkstyle-report", locale, CheckstyleReport.class.getClassLoader() );
+ return ResourceBundle.getBundle( "checkstyle-report", locale, CheckstyleReport.class.getClassLoader() );
}
}
Added: maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/resources/log4j.properties?rev=279769&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/resources/log4j.properties (added)
+++ maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/resources/log4j.properties Fri Sep 9 06:31:51 2005
@@ -0,0 +1,23 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2005 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -------------------------------------------------------------------
+
+log4j.rootCategory=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%c{1}:%L] %d{ISO8601} - %m%n
+
+log4j.logger.org.apache.commons.beanutils=ERROR
Propchange: maven/components/trunk/maven-plugins/maven-checkstyle-plugin/src/main/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org