o Add Mailing List Report

o Add a simple report generator mojo for dependencies and mailing list

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168217 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-05-05 00:17:49 +00:00
parent 94a31ffa02
commit 21592f058c
4 changed files with 196 additions and 26 deletions

View File

@ -12,6 +12,11 @@
<name>Maven Project Info Reports Plugin</name>
<inceptionYear>2005</inceptionYear>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>doxia</groupId>
<artifactId>doxia-core</artifactId>

View File

@ -0,0 +1,106 @@
package org.apache.maven.reports.projectinfo;
/*
* 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.apache.maven.model.MailingList;
import org.apache.maven.model.Model;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.doxia.sink.Sink;
import java.io.IOException;
import java.util.Iterator;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: MailingListsReport.java,v 1.4 2005/02/23 00:08:03 brett Exp $
*/
public class MailingListsReport
extends AbstractMavenReport
{
public void execute()
throws MavenReportException
{
try
{
MailingListsRenderer r = new MailingListsRenderer( getSink(), getConfiguration().getModel() );
r.render();
}
catch( IOException e )
{
throw new MavenReportException( "Can't write the report " + getOutputName(), e );
}
}
public String getOutputName()
{
return "mail-lists";
}
static class MailingListsRenderer
extends AbstractMavenReportRenderer
{
private Model model;
public MailingListsRenderer( Sink sink, Model model )
{
super( sink );
this.model = model;
}
// How to i18n these ...
public String getTitle()
{
return "Project Mailing Lists";
}
public void renderBody()
{
startSection( getTitle() );
if ( model.getMailingLists().isEmpty() )
{
// TODO: should the report just be excluded?
paragraph( "There are no mailing lists currently associated with this project." );
}
else
{
paragraph( "These are the mailing lists that have been established for this project. For each list, " +
"there is a subscribe, unsubscribe, and an archive link." );
startTable();
tableHeader( new String[]{"Name", "Subscribe", "Unsubscribe", "Archive"} );
for ( Iterator i = model.getMailingLists().iterator(); i.hasNext(); )
{
MailingList m = (MailingList) i.next();
// TODO: render otherArchives?
tableRow( new String[]{m.getName(), m.getSubscribe(), m.getUnsubscribe(), m.getArchive()} );
}
endTable();
}
endSection();
}
}
}

View File

@ -0,0 +1,79 @@
package org.apache.maven.reports.projectinfo;
/*
* 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.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.reporting.MavenReportConfiguration;
import org.apache.maven.reporting.MavenReportException;
import java.io.File;
/**
* @goal generate
* @description A Maven2 plugin which generates the set of project reports
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: ProjectReportsMojo.java,v 1.3 2005/02/23 00:08:03 brett Exp $
*/
public class ProjectReportsMojo
extends AbstractMojo
{
/**
* @parameter alias="workingDirectory" expression="${project.build.directory}/site-generated"
* @required
*/
private String outputDirectory;
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
public void execute()
throws MojoExecutionException
{
MavenReportConfiguration config = new MavenReportConfiguration();
config.setModel( project.getModel() );
config.setOutputDirectory( new File( outputDirectory ) );
MavenReport dependenciesReport = new DependenciesReport();
dependenciesReport.setConfiguration( config );
MavenReport mailingListsReport = new MailingListsReport();
mailingListsReport.setConfiguration( config );
try
{
dependenciesReport.generate();
mailingListsReport.generate();
}
catch ( MavenReportException e )
{
throw new MojoExecutionException( "An error is occurred in the report generation.", e );
}
}
}

View File

@ -11,31 +11,11 @@
<implementation>org.apache.maven.reports.projectinfo.DependenciesReport</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
<component>
<role>org.apache.maven.reporting.MavenReport</role>
<role-hint>mail-lists</role-hint>
<implementation>org.apache.maven.reports.projectinfo.MailingListsReport</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
</components>
<dependencies>
<dependency>
<groupId>doxia</groupId>
<artifactId>doxia-core</artifactId>
<type>jar</type>
<version>1.0-alpha-2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<type>jar</type>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<type>jar</type>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<type>jar</type>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</component-set>