PR: MNG-1034

use reporting for default output directory

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292104 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-28 03:17:58 +00:00
parent c5d1b378f2
commit 2bc0f749a1
2 changed files with 51 additions and 40 deletions

View File

@ -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>

View File

@ -16,6 +16,18 @@ package org.apache.maven.plugin.checkstyle;
* limitations under the License.
*/
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;
@ -23,19 +35,6 @@ 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.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.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.FilterSet;
import com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -48,11 +47,10 @@ 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 $
* @goal checkstyle
*/
public class CheckstyleReport
extends AbstractMavenReport
@ -60,10 +58,10 @@ public class CheckstyleReport
/**
* 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
@ -125,7 +123,7 @@ public class CheckstyleReport
*
* @parameter
*/
private String useFile;
private File useFile;
/**
* Specifies the location of the supperssions XML file to use. The plugin defines a Checkstyle
@ -210,7 +208,7 @@ public class CheckstyleReport
*/
protected String getOutputDirectory()
{
return outputDirectory;
return outputDirectory.getAbsolutePath();
}
/**
@ -255,10 +253,14 @@ public class CheckstyleReport
checker = new Checker();
if ( moduleFactory != null )
{
checker.setModuleFactory( moduleFactory );
}
if ( filterSet != null )
{
checker.addFilter( filterSet );
}
checker.configure( config );
}
@ -274,11 +276,9 @@ public class CheckstyleReport
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 @@ public class CheckstyleReport
}
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 @@ public class CheckstyleReport
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,11 +405,15 @@ public class CheckstyleReport
}
if ( headerFile != null )
{
p.setProperty( "checkstyle.header.file", headerFile );
}
if ( cacheFile != null )
{
p.setProperty( "checkstyle.cache.file", cacheFile );
}
}
catch ( IOException e )
{
throw new MavenReportException( "Failed to get overriding properties", e );
@ -448,7 +452,9 @@ public class CheckstyleReport
throws MavenReportException
{
if ( StringUtils.isEmpty( packageNamesFile ) )
{
return null;
}
try
{
@ -464,7 +470,9 @@ public class CheckstyleReport
throws MavenReportException
{
if ( StringUtils.isEmpty( suppressionsFile ) )
{
return null;
}
try
{