mirror of https://github.com/apache/maven.git
Do not extend AbstractMavenReport as it does not support externally generated HTML report files (see MNG-645). Indeed, in our case it is Clover which generates the report files.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@225267 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e78bef0429
commit
c692568a42
|
@ -20,10 +20,16 @@ import com.cenqua.clover.reporters.html.HtmlReporter;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.reporting.AbstractMavenReport;
|
||||
import org.apache.maven.reporting.MavenReportException;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.codehaus.doxia.site.renderer.SiteRenderer;
|
||||
import org.codehaus.doxia.sink.Sink;
|
||||
import org.codehaus.doxia.module.xhtml.XhtmlSink;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Generate a Clover report.
|
||||
|
@ -33,8 +39,7 @@ import java.util.ResourceBundle;
|
|||
* @goal report
|
||||
* @execute phase="test" lifecycle="clover"
|
||||
*/
|
||||
public class CloverReportMojo
|
||||
extends AbstractMavenReport
|
||||
public class CloverReportMojo extends AbstractMojo implements MavenReport
|
||||
{
|
||||
/**
|
||||
* @parameter expression="${project.build.directory}/clover/clover.db"
|
||||
|
@ -62,6 +67,8 @@ public class CloverReportMojo
|
|||
*/
|
||||
private MavenProject project;
|
||||
|
||||
private File reportOutputDirectory;
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
|
||||
*/
|
||||
|
@ -134,4 +141,60 @@ public class CloverReportMojo
|
|||
{
|
||||
return getBundle( locale ).getString( "report.clover.name" );
|
||||
}
|
||||
|
||||
// The methods below are required because we don't extend AbstractMavenReport. The reason is that
|
||||
// AbstractMavenReport does not support externally generated HTML report files.
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.reporting.MavenReport#getReportOutputDirectory()
|
||||
*/
|
||||
public File getReportOutputDirectory()
|
||||
{
|
||||
if ( this.reportOutputDirectory == null )
|
||||
{
|
||||
this.reportOutputDirectory = new File( getOutputDirectory() );
|
||||
}
|
||||
return this.reportOutputDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MavenReport#setReportOutputDirectory(java.io.File)
|
||||
*/
|
||||
public void setReportOutputDirectory( File reportOutputDirectory )
|
||||
{
|
||||
this.reportOutputDirectory = reportOutputDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.reporting.MavenReport#getCategoryName()
|
||||
*/
|
||||
public String getCategoryName()
|
||||
{
|
||||
return CATEGORY_PROJECT_REPORTS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MavenReport#generate(org.codehaus.doxia.sink.Sink, java.util.Locale)
|
||||
*/
|
||||
public void generate(Sink sink, Locale locale) throws MavenReportException
|
||||
{
|
||||
executeReport( locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.plugin.Mojo#execute()
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
generate( null, Locale.ENGLISH );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
|
||||
+ " report generation.", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue