Add Dependencies Report

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@165233 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-04-28 23:44:59 +00:00
parent 0f6db45c22
commit 0cae92051b
3 changed files with 144 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<project>
<modelVersion>4.0.0</modelVersion>
<!-- parent>
<artifactId>mojo</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>1.0-SNAPSHOT</version>
</parent -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven Project Info Reports Plugin</name>
<inceptionYear>2005</inceptionYear>
<dependencies>
<dependency>
<groupId>doxia</groupId>
<artifactId>doxia-core</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</dependency>
<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-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,98 @@
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.Dependency;
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:jason@maven.org">Jason van Zyl</a>
* @version $Id: DependenciesReport.java,v 1.2 2005/02/23 00:08:02 brett Exp $
* @plexus.component
*/
public class DependenciesReport
extends AbstractMavenReport
{
public void execute()
throws MavenReportException
{
try
{
DependenciesRenderer r = new DependenciesRenderer( getSink(), getConfiguration().getModel() );
r.render();
}
catch( IOException e )
{
throw new MavenReportException( "Can't write the report " + getOutputName(), e );
}
}
public String getOutputName()
{
return "dependencies";
}
static class DependenciesRenderer
extends AbstractMavenReportRenderer
{
private Model model;
public DependenciesRenderer( Sink sink, Model model )
{
super( sink );
this.model = model;
}
// How to i18n these ...
public String getTitle()
{
return "Project Dependencies";
}
public void renderBody()
{
startSection( getTitle() );
startTable();
tableCaption( "Declared Dependencies" );
tableHeader( new String[]{"GroupId", "ArtifactId", "Version"} );
for ( Iterator i = model.getDependencies().iterator(); i.hasNext(); )
{
Dependency d = (Dependency) i.next();
tableRow( new String[]{d.getGroupId(), d.getArtifactId(), d.getVersion()} );
}
endTable();
endSection();
}
}
}

View File

@ -0,0 +1,15 @@
<component-set>
<!-- TODO:
- this should be generated using cdc
- need to configure the reports
- the hint should perhaps use a qualifier -> this is equivalent to how we must deal with plugins outside of the maven group ID
-->
<components>
<component>
<role>org.apache.maven.reporting.MavenReport</role>
<role-hint>dependencies</role-hint>
<implementation>org.apache.maven.reports.projectinfo.DependenciesReport</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
</components>
</component-set>