mirror of https://github.com/apache/maven.git
Initial version of reporting integration
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@165071 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4441daa199
commit
3502cae978
|
@ -30,12 +30,10 @@
|
|||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-reporting-api</artifactId>
|
||||
<groupId>org.apache.maven.reporting</groupId>
|
||||
<artifactId>maven-reporting-manager</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
package org.apache.maven.doxia;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.plugin.Plugin;
|
||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
||||
import org.apache.maven.plugin.AbstractPlugin;
|
||||
import org.apache.maven.plugin.PluginExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.reporting.MavenReportConfiguration;
|
||||
import org.apache.maven.reporting.manager.MavenReportManager;
|
||||
import org.codehaus.doxia.site.renderer.SiteRenderer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @goal site
|
||||
* @description Doxia plugin
|
||||
|
@ -15,37 +21,55 @@ import org.codehaus.doxia.site.renderer.SiteRenderer;
|
|||
* type=""
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="#basedir/src/site"
|
||||
* expression="${basedir}/src/site"
|
||||
* description=""
|
||||
* @parameter name="generatedSiteDirectory"
|
||||
* type=""
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="#project.build.directory/site-generated"
|
||||
* expression="${project.build.directory}/site-generated"
|
||||
* description=""
|
||||
* @parameter name="outputDirectory"
|
||||
* type=""
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="#project.build.directory/site"
|
||||
* expression="${project.build.directory}/site"
|
||||
* description=""
|
||||
* @parameter name="flavour"
|
||||
* type="String"
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="maven"
|
||||
* description=""
|
||||
* @parameter name="project"
|
||||
* type=""
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="#project"
|
||||
* expression="${project}"
|
||||
* description=""
|
||||
* @parameter name="localRepository"
|
||||
* type="org.apache.maven.artifact.ArtifactRepository"
|
||||
* required="true"
|
||||
* validator=""
|
||||
* expression="#localRepository"
|
||||
* description=""
|
||||
* @parameter name="remoteRepositories"
|
||||
* type="java.util.List"
|
||||
* required="true"
|
||||
* validator=""
|
||||
* expression="#project.remoteArtifactRepositories"
|
||||
* description=""
|
||||
* @parameter name="siteRenderer"
|
||||
* type=""
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="#component.org.codehaus.doxia.site.renderer.SiteRenderer"
|
||||
* expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
|
||||
* description=""
|
||||
* @parameterx name="reportManager"
|
||||
* @parameter name="reportManager"
|
||||
* type=""
|
||||
* required=""
|
||||
* validator=""
|
||||
* expression="#component.org.apache.maven.reporting.MavenReportManager"
|
||||
* expression="${component.org.apache.maven.reporting.manager.MavenReportManager}"
|
||||
* description=""
|
||||
*/
|
||||
public class DoxiaMojo
|
||||
|
@ -57,25 +81,40 @@ public class DoxiaMojo
|
|||
|
||||
private String outputDirectory;
|
||||
|
||||
private String flavour;
|
||||
|
||||
private SiteRenderer siteRenderer;
|
||||
|
||||
private MavenProject project;
|
||||
|
||||
private MavenReportManager reportManager;
|
||||
|
||||
private ArtifactRepository localRepository;
|
||||
|
||||
private List remoteRepositories;
|
||||
|
||||
public void execute()
|
||||
throws PluginExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
/*
|
||||
for ( Iterator i = project.getReports().iterator(); i.hasNext(); )
|
||||
MavenReportConfiguration config = new MavenReportConfiguration();
|
||||
|
||||
config.setModel( project.getModel() );
|
||||
|
||||
if ( project.getReports() != null )
|
||||
{
|
||||
String name = (String) i.next();
|
||||
reportManager.addReports( project.getReports(), localRepository, remoteRepositories );
|
||||
|
||||
reportManager.executeReport( name, project.getModel(), siteRenderer, outputDirectory );
|
||||
for ( Iterator i = project.getReports().getPlugins().iterator(); i.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin) i.next();
|
||||
|
||||
reportManager.executeReport( plugin.getArtifactId(), config, outputDirectory );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
siteRenderer.render( siteDirectory, generatedSiteDirectory, outputDirectory );
|
||||
siteRenderer.render( siteDirectory, generatedSiteDirectory, outputDirectory, flavour );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
|
|
@ -79,7 +79,9 @@
|
|||
<module>maven-jar-plugin</module>
|
||||
<module>maven-plugin-plugin</module>
|
||||
<module>maven-resources-plugin</module>
|
||||
<!--
|
||||
<module>maven-site-plugin</module>
|
||||
-->
|
||||
<module>maven-surefire-plugin</module>
|
||||
<module>maven-war-plugin</module>
|
||||
</modules>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-reporting</artifactId>
|
||||
<groupId>org.apache.maven.reporting</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>maven-reporting-api</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<inceptionYear>2005</inceptionYear>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>doxia</groupId>
|
||||
<artifactId>doxia-core</artifactId>
|
||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plexus-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build -->
|
||||
</project>
|
|
@ -0,0 +1,42 @@
|
|||
package org.apache.maven.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 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;
|
||||
import org.codehaus.doxia.module.xdoc.XdocSink;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class AbstractMavenReport
|
||||
implements MavenReport
|
||||
{
|
||||
public Sink getSink( File outputDirectory )
|
||||
throws IOException
|
||||
{
|
||||
return getSink( outputDirectory, getOutputName() );
|
||||
}
|
||||
|
||||
public Sink getSink( File outputDirectory, String outputName )
|
||||
throws IOException
|
||||
{
|
||||
FileWriter writer = new FileWriter( new File( outputDirectory, "xdoc/" + outputName + ".xml" ) );
|
||||
|
||||
return new XdocSink( writer );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
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 abstract class AbstractMavenReportRenderer
|
||||
{
|
||||
protected Sink sink;
|
||||
|
||||
private int section = 0;
|
||||
|
||||
public AbstractMavenReportRenderer( Sink sink )
|
||||
{
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
public void render()
|
||||
{
|
||||
sink.head();
|
||||
|
||||
sink.title();
|
||||
|
||||
sink.text( getTitle() );
|
||||
|
||||
sink.title_();
|
||||
|
||||
sink.head_();
|
||||
|
||||
sink.body();
|
||||
|
||||
renderBody();
|
||||
|
||||
sink.body_();
|
||||
}
|
||||
|
||||
protected void startTable()
|
||||
{
|
||||
sink.table();
|
||||
}
|
||||
|
||||
protected void endTable()
|
||||
{
|
||||
sink.table_();
|
||||
}
|
||||
|
||||
protected void startSection( String name )
|
||||
{
|
||||
section = section + 1;
|
||||
|
||||
switch ( section )
|
||||
{
|
||||
case 1:
|
||||
sink.section1();
|
||||
break;
|
||||
case 2:
|
||||
sink.section2();
|
||||
break;
|
||||
case 3:
|
||||
sink.section3();
|
||||
break;
|
||||
case 4:
|
||||
sink.section4();
|
||||
break;
|
||||
case 5:
|
||||
sink.section5();
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: warning - just don't start a section
|
||||
break;
|
||||
}
|
||||
|
||||
sink.sectionTitle();
|
||||
|
||||
sink.text( name );
|
||||
|
||||
sink.sectionTitle_();
|
||||
}
|
||||
|
||||
protected void endSection()
|
||||
{
|
||||
switch ( section )
|
||||
{
|
||||
case 1:
|
||||
sink.section1_();
|
||||
break;
|
||||
case 2:
|
||||
sink.section2_();
|
||||
break;
|
||||
case 3:
|
||||
sink.section3_();
|
||||
break;
|
||||
case 4:
|
||||
sink.section4_();
|
||||
break;
|
||||
case 5:
|
||||
sink.section5_();
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: warning - just don't start a section
|
||||
break;
|
||||
}
|
||||
|
||||
section = section - 1;
|
||||
|
||||
if ( section < 0 )
|
||||
{
|
||||
throw new IllegalStateException( "Too many closing sections" );
|
||||
}
|
||||
}
|
||||
|
||||
protected void tableHeaderCell( String text )
|
||||
{
|
||||
sink.tableHeaderCell();
|
||||
|
||||
sink.text( text );
|
||||
|
||||
sink.tableHeaderCell_();
|
||||
}
|
||||
|
||||
protected void tableCell( String text )
|
||||
{
|
||||
sink.tableCell();
|
||||
|
||||
if ( text != null )
|
||||
{
|
||||
sink.text( text );
|
||||
}
|
||||
else
|
||||
{
|
||||
sink.nonBreakingSpace();
|
||||
}
|
||||
|
||||
sink.tableCell_();
|
||||
}
|
||||
|
||||
protected void tableRow( String[] content )
|
||||
{
|
||||
sink.tableRow();
|
||||
|
||||
for ( int i = 0; i < content.length; i++ )
|
||||
{
|
||||
tableCell( content[i] );
|
||||
}
|
||||
|
||||
sink.tableRow_();
|
||||
}
|
||||
|
||||
protected void tableHeader( String[] content )
|
||||
{
|
||||
sink.tableRow();
|
||||
|
||||
for ( int i = 0; i < content.length; i++ )
|
||||
{
|
||||
tableHeaderCell( content[i] );
|
||||
}
|
||||
|
||||
sink.tableRow_();
|
||||
}
|
||||
|
||||
protected abstract String getTitle();
|
||||
|
||||
protected abstract void renderBody();
|
||||
|
||||
protected void tableCaption( String caption )
|
||||
{
|
||||
sink.tableCaption();
|
||||
sink.text( caption );
|
||||
sink.tableCaption_();
|
||||
}
|
||||
|
||||
protected void paragraph( String paragraph )
|
||||
{
|
||||
sink.paragraph();
|
||||
|
||||
sink.text( paragraph );
|
||||
|
||||
sink.paragraph_();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.apache.maven.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The basis for a Maven report.
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id: MavenReport.java 163376 2005-02-23 00:06:06Z brett $
|
||||
*/
|
||||
public interface MavenReport
|
||||
{
|
||||
String ROLE = MavenReport.class.getName();
|
||||
|
||||
void execute( MavenReportConfiguration config )
|
||||
throws MavenReportException;
|
||||
|
||||
String getOutputName();
|
||||
|
||||
Sink getSink( File outputDirectory )
|
||||
throws IOException;
|
||||
|
||||
Sink getSink( File outputDirectory, String outputName )
|
||||
throws IOException;
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package org.apache.maven.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 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.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Scm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id: MavenReport.java 163376 2005-02-23 00:06:06Z brett $
|
||||
*/
|
||||
public class MavenReportConfiguration
|
||||
{
|
||||
private Model model;
|
||||
|
||||
public Model getModel()
|
||||
{
|
||||
if ( model == null )
|
||||
{
|
||||
model = new Model();
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel( Model model )
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public List getDependencies()
|
||||
{
|
||||
return getModel().getDependencies();
|
||||
}
|
||||
|
||||
public List getMailingLists()
|
||||
{
|
||||
return getModel().getMailingLists();
|
||||
}
|
||||
|
||||
public Scm getScm()
|
||||
{
|
||||
return getModel().getScm();
|
||||
}
|
||||
|
||||
public void setScm( Scm scm )
|
||||
{
|
||||
getModel().setScm( scm );
|
||||
}
|
||||
|
||||
public String getSourceDirectory()
|
||||
{
|
||||
return getModel().getBuild().getSourceDirectory();
|
||||
}
|
||||
|
||||
public void setSourceDirectory( String sourceDirectory )
|
||||
{
|
||||
getModel().getBuild().setSourceDirectory( sourceDirectory );
|
||||
}
|
||||
|
||||
public String getScriptSourceDirectory()
|
||||
{
|
||||
return getModel().getBuild().getScriptSourceDirectory();
|
||||
}
|
||||
|
||||
public void setScriptSourceDirectory( String scriptSourceDirectory )
|
||||
{
|
||||
getModel().getBuild().setScriptSourceDirectory( scriptSourceDirectory );
|
||||
}
|
||||
|
||||
public String getTestSourceDirectory()
|
||||
{
|
||||
return getModel().getBuild().getTestSourceDirectory();
|
||||
}
|
||||
|
||||
public void setTestSourceDirectory( String testSourceDirectory )
|
||||
{
|
||||
getModel().getBuild().setTestSourceDirectory( testSourceDirectory );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.apache.maven.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An exception occurring during the execution of a Maven report.
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id: MavenReportException.java 163361 2005-02-17 07:00:25Z brett $
|
||||
*/
|
||||
public class MavenReportException extends Exception
|
||||
{
|
||||
public MavenReportException( String msg )
|
||||
{
|
||||
super( msg );
|
||||
}
|
||||
|
||||
public MavenReportException( String msg, Exception e )
|
||||
{
|
||||
super( msg, e );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-reporting</artifactId>
|
||||
<groupId>org.apache.maven.reporting</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>maven-reporting-manager</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<inceptionYear>2005</inceptionYear>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.reporting</groupId>
|
||||
<artifactId>maven-reporting-api</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-container-artifact</artifactId>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plexus-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build -->
|
||||
</project>
|
|
@ -0,0 +1,184 @@
|
|||
package org.apache.maven.reporting.manager;
|
||||
|
||||
/*
|
||||
* Copyright 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.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.Reports;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.reporting.MavenReportConfiguration;
|
||||
import org.apache.maven.reporting.MavenReportException;
|
||||
import org.codehaus.plexus.ArtifactEnabledContainer;
|
||||
import org.codehaus.plexus.ArtifactEnabledContainerException;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
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 java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Manage the set of available reports.
|
||||
*
|
||||
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id: DefaultMavenReportManager.java 163376 2005-02-23 00:06:06Z brett $
|
||||
* @plexus.component
|
||||
*/
|
||||
public class DefaultMavenReportManager
|
||||
extends AbstractLogEnabled
|
||||
implements MavenReportManager, Contextualizable
|
||||
{
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
protected PlexusContainer container;
|
||||
|
||||
private Map mavenReports;
|
||||
|
||||
public void addReports( Reports reports, ArtifactRepository localRepository, List remoteRepositories )
|
||||
throws ReportManagerException, ReportNotFoundException
|
||||
{
|
||||
for ( Iterator i = reports.getPlugins().iterator(); i.hasNext(); )
|
||||
{
|
||||
Plugin pluginReport = (Plugin) i.next();
|
||||
|
||||
String groupId = pluginReport.getGroupId();
|
||||
|
||||
String artifactId = pluginReport.getArtifactId();
|
||||
|
||||
String version = pluginReport.getVersion();
|
||||
|
||||
try
|
||||
{
|
||||
Artifact pluginArtifact = artifactFactory.createArtifact( pluginReport.getGroupId(),
|
||||
pluginReport.getArtifactId(),
|
||||
pluginReport.getVersion(),
|
||||
null, "maven-plugin", null );
|
||||
|
||||
addPlugin( pluginArtifact, localRepository, remoteRepositories );
|
||||
}
|
||||
catch ( ArtifactEnabledContainerException e )
|
||||
{
|
||||
throw new ReportManagerException( "Error occurred in the artifact container attempting to download plugin " +
|
||||
groupId + ":" + artifactId, e );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
||||
version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) )
|
||||
{
|
||||
throw new ReportNotFoundException( groupId, artifactId, version, e );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ReportManagerException( "Error occurred in the artifact resolver attempting to download plugin " +
|
||||
groupId + ":" + artifactId, e );
|
||||
}
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new ReportManagerException( "Error occurred in the container attempting to load report plugin " +
|
||||
groupId + ":" + artifactId, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlugin( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||
throws ArtifactEnabledContainerException, ArtifactResolutionException, ComponentLookupException
|
||||
{
|
||||
ArtifactResolver artifactResolver = null;
|
||||
|
||||
MavenProjectBuilder mavenProjectBuilder = null;
|
||||
|
||||
try
|
||||
{
|
||||
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
|
||||
|
||||
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
|
||||
|
||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||
|
||||
( (ArtifactEnabledContainer) container ).addComponent( artifact, artifactResolver,
|
||||
remoteRepositories,
|
||||
localRepository, metadataSource,
|
||||
null );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( artifactResolver != null )
|
||||
{
|
||||
releaseComponent( artifactResolver );
|
||||
}
|
||||
if ( mavenProjectBuilder != null )
|
||||
{
|
||||
releaseComponent( mavenProjectBuilder );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseComponent( Object component )
|
||||
{
|
||||
try
|
||||
{
|
||||
container.release( component );
|
||||
}
|
||||
catch ( ComponentLifecycleException e )
|
||||
{
|
||||
getLogger().error( "Error releasing component - ignoring", e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo we need some type of response
|
||||
*/
|
||||
public void executeReport( String name, MavenReportConfiguration config, String outputDirectory )
|
||||
throws MavenReportException
|
||||
{
|
||||
MavenReport report = (MavenReport) mavenReports.get( name );
|
||||
|
||||
if ( report != null )
|
||||
{
|
||||
report.execute( config );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new MavenReportException( "The report " + name + " doesn't exist." );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Lifecycle
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void contextualize( Context context )
|
||||
throws ContextException
|
||||
{
|
||||
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package org.apache.maven.reporting.manager;
|
||||
|
||||
/*
|
||||
* Copyright 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.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Reports;
|
||||
import org.apache.maven.reporting.MavenReportConfiguration;
|
||||
import org.apache.maven.reporting.MavenReportException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Manage the set of available reports.
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id: MavenReportManager.java 163376 2005-02-23 00:06:06Z brett $
|
||||
*/
|
||||
public interface MavenReportManager
|
||||
{
|
||||
String ROLE = MavenReportManager.class.getName();
|
||||
|
||||
void addReports( Reports reports, ArtifactRepository localRepository, List remoteRepositories )
|
||||
throws ReportManagerException, ReportNotFoundException;
|
||||
|
||||
void executeReport( String name, MavenReportConfiguration config, String outputDirectory )
|
||||
throws MavenReportException;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.apache.maven.reporting.manager;
|
||||
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
public class ReportManagerException
|
||||
extends Exception
|
||||
{
|
||||
public ReportManagerException( String message, Exception e )
|
||||
{
|
||||
super( message, e );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.apache.maven.reporting.manager;
|
||||
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
public class ReportNotFoundException
|
||||
extends Exception
|
||||
{
|
||||
public ReportNotFoundException( String groupId, String artifactId, String version, Exception e )
|
||||
{
|
||||
super( groupId + ":" + artifactId + ":" + version, e );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.reporting.manager.MavenReportManager</role>
|
||||
<implementation>org.apache.maven.reporting.manager.DefaultMavenReportManager</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
<field-name>artifactFactory</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.reporting.MavenReport</role>
|
||||
<field-name>mavenReports</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -0,0 +1,14 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven</artifactId>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.apache.maven.reporting</groupId>
|
||||
<artifactId>maven-reporting</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Maven Reporting</name>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<inceptionYear>2005</inceptionYear>
|
||||
</project>
|
Loading…
Reference in New Issue