You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2009/08/13 13:10:31 UTC
svn commit: r803843 - in /maven/plugins/trunk/maven-checkstyle-plugin: ./
src/main/java/org/apache/maven/plugin/checkstyle/
src/test/java/org/apache/maven/plugin/checkstyle/
Author: vsiveton
Date: Thu Aug 13 11:10:31 2009
New Revision: 803843
URL: http://svn.apache.org/viewvc?rev=803843&view=rev
Log:
MCHECKSTYLE-120: Bump to Doxia 1.0
o updated dependencies
o fixed test cases
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java
Modified: maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/pom.xml?rev=803843&r1=803842&r2=803843&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/pom.xml Thu Aug 13 11:10:31 2009
@@ -58,10 +58,12 @@
</issueManagement>
<properties>
- <mavenVersion>2.0</mavenVersion>
+ <mavenVersion>2.0.6</mavenVersion>
+ <doxiaVersion>1.0</doxiaVersion>
</properties>
<dependencies>
+ <!-- maven -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
@@ -90,13 +92,39 @@
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
- <version>2.0</version>
+ <version>2.0.4.2</version>
+ </dependency>
+
+ <!-- doxia -->
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-sink-api</artifactId>
+ <version>${doxiaVersion}</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-site-renderer</artifactId>
+ <version>${doxiaVersion}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- shared -->
+ <dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-doxia-tools</artifactId>
- <version>1.0</version>
+ <version>1.0.2</version>
</dependency>
+
+ <!-- plexus -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
@@ -115,19 +143,24 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-velocity</artifactId>
- <version>1.1.2</version>
+ <version>1.1.7</version>
<exclusions>
<exclusion>
- <!-- Use the version specified by checkstyle:checkstyle instead -->
- <artifactId>commons-collections</artifactId>
- <groupId>commons-collections</groupId>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
</exclusion>
<exclusion>
- <artifactId>plexus-utils</artifactId>
- <groupId>plexus</groupId>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
</exclusion>
</exclusions>
</dependency>
+
+ <!-- checkstyle -->
<dependency>
<groupId>checkstyle</groupId>
<artifactId>checkstyle</artifactId>
@@ -138,6 +171,26 @@
<artifactId>checkstyle-optional</artifactId>
<version>4.4</version>
</dependency>
+
+ <!-- misc -->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+
+ <!-- test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java?rev=803843&r1=803842&r2=803843&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java Thu Aug 13 11:10:31 2009
@@ -34,6 +34,7 @@
import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
import com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.doxia.tools.SiteTool;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.MojoExecutionException;
@@ -44,7 +45,6 @@
import org.apache.velocity.context.Context;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.VelocityException;
-import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceLocator;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable;
@@ -500,7 +500,7 @@
* @required
* @readonly
*/
- private SiteRenderer siteRenderer;
+ private Renderer siteRenderer;
/**
* Velocity Component.
@@ -569,7 +569,7 @@
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
*/
- protected SiteRenderer getSiteRenderer()
+ protected Renderer getSiteRenderer()
{
return siteRenderer;
}
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java?rev=803843&r1=803842&r2=803843&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java Thu Aug 13 11:10:31 2009
@@ -24,10 +24,11 @@
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
+
+import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.tools.SiteTool;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
-import org.codehaus.doxia.sink.Sink;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java?rev=803843&r1=803842&r2=803843&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java Thu Aug 13 11:10:31 2009
@@ -20,16 +20,20 @@
*/
import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.Mojo;
+import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.reporting.MavenReport;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.WriterFactory;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
+import java.io.Writer;
import java.util.Locale;
-import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
/**
@@ -38,6 +42,8 @@
public class CheckstyleReportTest
extends AbstractMojoTestCase
{
+ private Locale oldLocale;
+
/**
* @see junit.framework.TestCase#setUp()
*/
@@ -45,6 +51,9 @@
throws Exception
{
super.setUp();
+
+ oldLocale = Locale.getDefault();
+ Locale.setDefault( Locale.ENGLISH );
}
/**
@@ -54,6 +63,9 @@
throws Exception
{
super.tearDown();
+
+ Locale.setDefault( oldLocale );
+ oldLocale = null;
}
public void testNoSource()
@@ -61,16 +73,17 @@
{
File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/no-source-plugin-config.xml" );
- Mojo mojo = lookupMojo( "checkstyle", pluginXmlFile );
+ CheckstyleReport mojo = (CheckstyleReport) lookupMojo( "checkstyle", pluginXmlFile );
assertNotNull( "Mojo found.", mojo );
mojo.execute();
File outputFile = (File) getVariableValueFromObject( mojo, "outputFile" );
- assertNotNull( "Test output file", outputFile );
- //if multiples executions without clean, this fail, because the
- // output file is not erased.
- //assertFalse( "Test output file exists", outputFile.exists() );
+ renderer( mojo, outputFile );
+
+ assertTrue( outputFile.getAbsolutePath() + " not generated!", outputFile.exists() );
+
+ assertTrue( outputFile.getAbsolutePath() + " is empty!", outputFile.length() > 0 );
}
public void testMinConfiguration()
@@ -150,9 +163,10 @@
throws Exception
{
File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/" + pluginXml );
- ResourceBundle bundle = ResourceBundle.getBundle( "checkstyle-report", Locale.ENGLISH, this.getClassLoader() );
+ ResourceBundle bundle =
+ ResourceBundle.getBundle( "checkstyle-report", Locale.getDefault(), this.getClassLoader() );
- Mojo mojo = lookupMojo( "checkstyle", pluginXmlFile );
+ CheckstyleReport mojo = (CheckstyleReport) lookupMojo( "checkstyle", pluginXmlFile );
assertNotNull( "Mojo found.", mojo );
@@ -186,11 +200,17 @@
String filename = reportMojo.getOutputName() + ".html";
File outputHtml = new File( outputDir, filename );
- assertTrue( "Test output html file exists", outputHtml.exists() );
+
+ renderer( mojo, outputHtml );
+
+ assertTrue( outputHtml.getAbsolutePath() + " not generated!", outputHtml.exists() );
+
+ assertTrue( outputHtml.getAbsolutePath() + " is empty!", outputHtml.length() > 0 );
+
String htmlString = FileUtils.fileRead( outputHtml );
- boolean searchHeaderFound = ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.rules" )
- + "</h2>" ) > 0 );
+ boolean searchHeaderFound =
+ ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.rules" ) + "</h2>" ) > 0 );
Boolean rules = (Boolean) getVariableValueFromObject( mojo, "enableRulesSummary" );
if ( rules.booleanValue() )
{
@@ -201,7 +221,8 @@
assertFalse( "Test for Rules Summary", searchHeaderFound );
}
- searchHeaderFound = ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.summary" ) + "</h2>" ) > 0 );
+ searchHeaderFound =
+ ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.summary" ) + "</h2>" ) > 0 );
Boolean severity = (Boolean) getVariableValueFromObject( mojo, "enableSeveritySummary" );
if ( severity.booleanValue() )
{
@@ -212,7 +233,8 @@
assertFalse( "Test for Severity Summary", searchHeaderFound );
}
- searchHeaderFound = ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.files" ) + "</h2>" ) > 0 );
+ searchHeaderFound =
+ ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.files" ) + "</h2>" ) > 0 );
Boolean files = (Boolean) getVariableValueFromObject( mojo, "enableFilesSummary" );
if ( files.booleanValue() )
{
@@ -225,4 +247,34 @@
return outputHtml;
}
+
+ /**
+ * Renderer the sink from the report mojo.
+ *
+ * @param mojo not null
+ * @param outputHtml not null
+ * @throws RendererException if any
+ * @throws IOException if any
+ */
+ private void renderer( CheckstyleReport mojo, File outputHtml )
+ throws RendererException, IOException
+ {
+ Writer writer = null;
+ SiteRenderingContext context = new SiteRenderingContext();
+ context.setDecoration( new DecorationModel() );
+ context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
+ context.setLocale( Locale.ENGLISH );
+
+ try
+ {
+ outputHtml.getParentFile().mkdirs();
+ writer = WriterFactory.newXmlWriter( outputHtml );
+
+ mojo.getSiteRenderer().generateDocument( writer, (SiteRendererSink) mojo.getSink(), context );
+ }
+ finally
+ {
+ IOUtil.close( writer );
+ }
+ }
}