mirror of https://github.com/apache/maven.git
o check if plugin version is defined
o refactor the report execution, it use only the MavenReportConfiguration o obtain reports list via reportManager.getReports git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@165232 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
235fb09cb9
commit
0f6db45c22
|
@ -85,15 +85,17 @@ public class DoxiaMojo
|
|||
|
||||
config.setModel( project.getModel() );
|
||||
|
||||
config.setOutputDirectory( new File( generatedSiteDirectory ) );
|
||||
|
||||
if ( project.getReports() != null )
|
||||
{
|
||||
reportManager.addReports( project.getReports(), localRepository, remoteRepositories );
|
||||
|
||||
for ( Iterator i = project.getReports().getPlugins().iterator(); i.hasNext(); )
|
||||
for ( Iterator i = reportManager.getReports().keySet().iterator(); i.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin) i.next();
|
||||
String reportName = (String) i.next();
|
||||
|
||||
reportManager.executeReport( plugin.getArtifactId(), config, outputDirectory );
|
||||
reportManager.executeReport( reportName, config );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,42 @@ import java.io.IOException;
|
|||
public abstract class AbstractMavenReport
|
||||
implements MavenReport
|
||||
{
|
||||
public Sink getSink( File outputDirectory )
|
||||
throws IOException
|
||||
private MavenReportConfiguration config;
|
||||
|
||||
public MavenReportConfiguration getConfiguration()
|
||||
{
|
||||
return getSink( outputDirectory, getOutputName() );
|
||||
return config;
|
||||
}
|
||||
|
||||
public Sink getSink( File outputDirectory, String outputName )
|
||||
public void setConfiguration( MavenReportConfiguration config )
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public void generate()
|
||||
throws MavenReportException
|
||||
{
|
||||
if ( config == null )
|
||||
{
|
||||
throw new MavenReportException( "You must specify a report configuration." );
|
||||
}
|
||||
|
||||
execute();
|
||||
}
|
||||
|
||||
protected abstract void execute()
|
||||
throws MavenReportException;
|
||||
|
||||
public Sink getSink()
|
||||
throws IOException
|
||||
{
|
||||
FileWriter writer = new FileWriter( new File( outputDirectory, "xdoc/" + outputName + ".xml" ) );
|
||||
return getSink( getOutputName() );
|
||||
}
|
||||
|
||||
public Sink getSink( String outputName )
|
||||
throws IOException
|
||||
{
|
||||
FileWriter writer = new FileWriter( new File( config.getOutputDirectory(), "xdoc/" + outputName + ".xml" ) );
|
||||
|
||||
return new XdocSink( writer );
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.codehaus.doxia.sink.Sink;
|
|||
* @todo Later it may be appropriate to create something like a VelocityMavenReportRenderer that could take a velocity template and pipe that through Doxia rather than coding them up like this.
|
||||
*/
|
||||
public abstract class AbstractMavenReportRenderer
|
||||
implements MavenReportRenderer
|
||||
{
|
||||
protected Sink sink;
|
||||
|
||||
|
@ -180,7 +181,7 @@ public abstract class AbstractMavenReportRenderer
|
|||
sink.tableRow_();
|
||||
}
|
||||
|
||||
protected abstract String getTitle();
|
||||
public abstract String getTitle();
|
||||
|
||||
protected abstract void renderBody();
|
||||
|
||||
|
|
|
@ -32,14 +32,18 @@ public interface MavenReport
|
|||
{
|
||||
String ROLE = MavenReport.class.getName();
|
||||
|
||||
void execute( MavenReportConfiguration config )
|
||||
MavenReportConfiguration getConfiguration();
|
||||
|
||||
void setConfiguration( MavenReportConfiguration config );
|
||||
|
||||
void generate()
|
||||
throws MavenReportException;
|
||||
|
||||
String getOutputName();
|
||||
|
||||
Sink getSink( File outputDirectory )
|
||||
Sink getSink()
|
||||
throws IOException;
|
||||
|
||||
Sink getSink( File outputDirectory, String outputName )
|
||||
Sink getSink( String outputName )
|
||||
throws IOException;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.reporting;
|
|||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Scm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -29,6 +30,18 @@ public class MavenReportConfiguration
|
|||
{
|
||||
private Model model;
|
||||
|
||||
private File outputDirectory;
|
||||
|
||||
public File getOutputDirectory()
|
||||
{
|
||||
return outputDirectory;
|
||||
}
|
||||
|
||||
public void setOutputDirectory( File outputDirectory )
|
||||
{
|
||||
this.outputDirectory = outputDirectory;
|
||||
}
|
||||
|
||||
public Model getModel()
|
||||
{
|
||||
if ( model == null )
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package org.apache.maven.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 2004-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.
|
||||
*/
|
||||
|
||||
import org.codehaus.doxia.sink.Sink;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id: AbstractMavenReportRenderer.java 163373 2005-02-22 03:37:00Z brett $
|
||||
* @todo Later it may be appropriate to create something like a VelocityMavenReportRenderer that could take a velocity template and pipe that through Doxia rather than coding them up like this.
|
||||
*/
|
||||
public interface MavenReportRenderer
|
||||
{
|
||||
String getTitle();
|
||||
|
||||
void render();
|
||||
}
|
|
@ -39,6 +39,7 @@ import org.codehaus.plexus.context.Context;
|
|||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -74,16 +75,19 @@ public class DefaultMavenReportManager
|
|||
|
||||
String version = pluginReport.getVersion();
|
||||
|
||||
if ( version == null )
|
||||
{
|
||||
throw new ReportManagerException( "The version of " + groupId + ":" + artifactId + " can not be empty" );
|
||||
if ( pluginReport != null && StringUtils.isEmpty( version ) )
|
||||
{
|
||||
// The model/project builder should have validated this already
|
||||
String message = "The maven plugin with groupId: '" + groupId + "' and artifactId: '" + artifactId +
|
||||
"' which was configured for use in this project does not have a version associated with it.";
|
||||
throw new IllegalStateException( message );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Artifact pluginArtifact = artifactFactory.createArtifact( pluginReport.getGroupId(),
|
||||
pluginReport.getArtifactId(),
|
||||
pluginReport.getVersion(),
|
||||
version,
|
||||
null, "maven-plugin", null );
|
||||
|
||||
addPlugin( pluginArtifact, localRepository, remoteRepositories );
|
||||
|
@ -159,17 +163,33 @@ public class DefaultMavenReportManager
|
|||
}
|
||||
}
|
||||
|
||||
public Map getReports()
|
||||
{
|
||||
try
|
||||
{
|
||||
mavenReports = container.lookupMap( MavenReport.ROLE );
|
||||
}
|
||||
catch(ComponentLookupException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("nb reports=" + mavenReports.keySet().size() );
|
||||
return mavenReports;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo we need some type of response
|
||||
*/
|
||||
public void executeReport( String name, MavenReportConfiguration config, String outputDirectory )
|
||||
public void executeReport( String name, MavenReportConfiguration config )
|
||||
throws MavenReportException
|
||||
{
|
||||
MavenReport report = (MavenReport) mavenReports.get( name );
|
||||
|
||||
if ( report != null )
|
||||
{
|
||||
report.execute( config );
|
||||
report.setConfiguration( config );
|
||||
|
||||
report.generate();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.maven.reporting.MavenReportConfiguration;
|
|||
import org.apache.maven.reporting.MavenReportException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Manage the set of available reports.
|
||||
|
@ -34,9 +35,11 @@ public interface MavenReportManager
|
|||
{
|
||||
String ROLE = MavenReportManager.class.getName();
|
||||
|
||||
Map getReports();
|
||||
|
||||
void addReports( Reports reports, ArtifactRepository localRepository, List remoteRepositories )
|
||||
throws ReportManagerException, ReportNotFoundException;
|
||||
|
||||
void executeReport( String name, MavenReportConfiguration config, String outputDirectory )
|
||||
void executeReport( String name, MavenReportConfiguration config )
|
||||
throws MavenReportException;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue