Author: brett Date: Tue Sep 27 20:17:58 2005 New Revision: 292104 URL: http://svn.apache.org/viewcvs?rev=292104&view=rev Log: PR: MNG-1034 use reporting for default output directory
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=292104&r1=292103&r2=292104&view=diff ============================================================================== --- maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml (original) +++ maven/components/trunk/maven-plugins/maven-checkstyle-plugin/pom.xml Tue Sep 27 20:17:58 2005 @@ -2,7 +2,7 @@ <parent> <artifactId>maven-plugin-parent</artifactId> <groupId>org.apache.maven.plugins</groupId> - <version>2.0-beta-1</version> + <version>2.0-beta-3-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>maven-checkstyle-plugin</artifactId> @@ -10,6 +10,9 @@ <name>Maven Checkstyle Plugin</name> <version>2.0-alpha-3-SNAPSHOT</version> <inceptionYear>2005</inceptionYear> + <prerequisites> + <maven>2.0-beta-3-SNAPSHOT</maven> + </prerequisites> <developers> <developer> <id>vsiveton</id> @@ -64,4 +67,4 @@ <version>3.4</version> </dependency> </dependencies> -</project> \ No newline at end of file +</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=292104&r1=292103&r2=292104&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 Tue Sep 27 20:17:58 2005 @@ -16,25 +16,24 @@ * limitations under the License. */ -import org.apache.maven.project.MavenProject; -import org.apache.maven.reporting.AbstractMavenReport; -import org.apache.maven.reporting.MavenReportException; -import org.codehaus.doxia.site.renderer.SiteRenderer; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; - -import com.puppycrawl.tools.checkstyle.api.AuditListener; -import com.puppycrawl.tools.checkstyle.api.Configuration; -import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.Checker; +import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.DefaultLogger; import com.puppycrawl.tools.checkstyle.ModuleFactory; import com.puppycrawl.tools.checkstyle.PackageNamesLoader; import com.puppycrawl.tools.checkstyle.PropertiesExpander; import com.puppycrawl.tools.checkstyle.XMLLogger; +import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; +import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.FilterSet; import com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.AbstractMavenReport; +import org.apache.maven.reporting.MavenReportException; +import org.codehaus.doxia.site.renderer.SiteRenderer; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.FileInputStream; @@ -48,11 +47,10 @@ import java.util.ResourceBundle; /** - * @goal checkstyle - * * @author <a href="mailto:[EMAIL PROTECTED]">Emmanuel Venisse</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> * @version $Id: DependenciesReport.java,v 1.2 2005/02/23 00:08:02 brett Exp $ + * @goal checkstyle */ public class CheckstyleReport extends AbstractMavenReport @@ -60,10 +58,10 @@ /** * Specifies the directory where the report will be generated * - * @parameter expression="${project.build.directory}/site" + * @parameter default-value="${project.reporting.outputDirectory}" * @required */ - private String outputDirectory; + private File outputDirectory; /** * Specifies the names filter of the source files to be used for checkstyle @@ -82,8 +80,8 @@ /** * Specifies what predefined check set to use. Available sets are - * "sun" (for the Sun coding conventions), "turbine", and "avalon". - * Default is sun. + * "sun" (for the Sun coding conventions), "turbine", and "avalon". + * Default is sun. * * @parameter default-value="sun" */ @@ -105,7 +103,7 @@ /** * 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. + * to verify that source code has the correct copyright. * * @parameter */ @@ -120,18 +118,18 @@ /** * 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 - * the violations in XML format which is always created. + * created with the violations. Note: This is in addition to the XML result file (containing + * the violations in XML format which is always created. * * @parameter */ - private String useFile; + private File 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 - * property. This allows using the Checkstyle property your own custom checkstyle - * configuration file when specifying a suppressions file. + * property named <code>checkstyle.supperssions.file</code> with the value of this + * property. This allows using the Checkstyle property your own custom checkstyle + * configuration file when specifying a suppressions file. * * @parameter */ @@ -139,7 +137,7 @@ /** * Specifies the path and filename to save the checkstyle output. The format of the output file is - * determined by the <code>outputFileFormat</code> + * determined by the <code>outputFileFormat</code> * * @parameter expression="${project.build.directory}/checkstyle-result.txt" */ @@ -147,7 +145,7 @@ /** * Specifies the format of the output to be used when writing to the output file. Valid values are - * "plain" and "xml" + * "plain" and "xml" * * @parameter default-value="plain" */ @@ -210,7 +208,7 @@ */ protected String getOutputDirectory() { - return outputDirectory; + return outputDirectory.getAbsolutePath(); } /** @@ -255,10 +253,14 @@ checker = new Checker(); if ( moduleFactory != null ) + { checker.setModuleFactory( moduleFactory ); + } if ( filterSet != null ) + { checker.addFilter( filterSet ); + } checker.configure( config ); } @@ -274,11 +276,9 @@ checker.addListener( listener ); } - if ( StringUtils.isNotEmpty( useFile ) ) + if ( useFile != null ) { - File outputFile = new File( useFile ); - - OutputStream out = getOutputStream( outputFile ); + OutputStream out = getOutputStream( useFile ); checker.addListener( new DefaultLogger( out, true ) ); } @@ -326,8 +326,8 @@ } 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'." ); } } @@ -337,14 +337,14 @@ private OutputStream getOutputStream( File file ) throws MavenReportException { - FileOutputStream out; - try { - File parentFile = file.getParentFile(); + File parentFile = file.getAbsoluteFile().getParentFile(); if ( !parentFile.exists() ) + { parentFile.mkdirs(); + } return new FileOutputStream( file ); } @@ -405,10 +405,14 @@ } if ( headerFile != null ) + { p.setProperty( "checkstyle.header.file", headerFile ); + } if ( cacheFile != null ) + { p.setProperty( "checkstyle.cache.file", cacheFile ); + } } catch ( IOException e ) { @@ -448,7 +452,9 @@ throws MavenReportException { if ( StringUtils.isEmpty( packageNamesFile ) ) + { return null; + } try { @@ -464,7 +470,9 @@ throws MavenReportException { if ( StringUtils.isEmpty( suppressionsFile ) ) + { return null; + } try { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]