MNG-411: all transitive dependencies report

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219261 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vincent Siveton 2005-07-15 23:31:53 +00:00
parent 5f412ebb40
commit c6ad9aa729
7 changed files with 291 additions and 17 deletions

View File

@ -1,3 +1,23 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/*
* Copyright 2001-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.
*/
-->
<project> <project>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -10,10 +30,16 @@
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
<name>Maven Project Info Reports Plugin</name> <name>Maven Project Info Reports Plugin</name>
<inceptionYear>2005</inceptionYear> <inceptionYear>2005</inceptionYear>
<contributors> <developers>
<contributor> <developer>
<id>vsiveton</id>
<name>Vincent Siveton</name> <name>Vincent Siveton</name>
<email>vincent.siveton@gmail.com</email> <email>vsiveton@apache.org</email>
</contributor> <organization>Apache Software Foundation</organization>
</contributors> <roles>
<role>Java Developer</role>
</roles>
<timezone>-5</timezone>
</developer>
</developers>
</project> </project>

View File

@ -16,8 +16,8 @@ package org.apache.maven.report.projectinfo;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReportRenderer; import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.AbstractMavenReport;
@ -26,14 +26,20 @@ import org.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer; import org.codehaus.doxia.site.renderer.SiteRenderer;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Set;
/** /**
* Generates the dependencies report.
*
* @goal dependencies * @goal dependencies
* *
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$ * @version $Id$
* @plexus.component * @plexus.component
*/ */
@ -116,7 +122,7 @@ public class DependenciesReport
{ {
try try
{ {
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject().getModel(), locale ); DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject(), locale );
r.render(); r.render();
} }
@ -137,20 +143,19 @@ public class DependenciesReport
static class DependenciesRenderer static class DependenciesRenderer
extends AbstractMavenReportRenderer extends AbstractMavenReportRenderer
{ {
private Model model; private MavenProject project;
private Locale locale; private Locale locale;
public DependenciesRenderer( Sink sink, Model model, Locale locale ) public DependenciesRenderer( Sink sink, MavenProject project, Locale locale )
{ {
super( sink ); super( sink );
this.model = model; this.project = project;
this.locale = locale; this.locale = locale;
} }
// How to i18n these ...
public String getTitle() public String getTitle()
{ {
return getBundle( locale ).getString( "report.dependencies.title" ); return getBundle( locale ).getString( "report.dependencies.title" );
@ -160,7 +165,10 @@ public class DependenciesReport
{ {
startSection( getTitle() ); startSection( getTitle() );
if ( model.getDependencies().isEmpty() ) // Dependencies report
List dependencies = project.getDependencies();
if ( dependencies.isEmpty() )
{ {
// TODO: should the report just be excluded? // TODO: should the report just be excluded?
paragraph( getBundle( locale ).getString( "report.dependencies.nolist" ) ); paragraph( getBundle( locale ).getString( "report.dependencies.nolist" ) );
@ -172,14 +180,12 @@ public class DependenciesReport
tableCaption( getBundle( locale ).getString( "report.dependencies.intro" ) ); tableCaption( getBundle( locale ).getString( "report.dependencies.intro" ) );
String groupId = getBundle( locale ).getString( "report.dependencies.column.groupId" ); String groupId = getBundle( locale ).getString( "report.dependencies.column.groupId" );
String artifactId = getBundle( locale ).getString( "report.dependencies.column.artifactId" ); String artifactId = getBundle( locale ).getString( "report.dependencies.column.artifactId" );
String version = getBundle( locale ).getString( "report.dependencies.column.version" ); String version = getBundle( locale ).getString( "report.dependencies.column.version" );
tableHeader( new String[]{groupId, artifactId, version} ); tableHeader( new String[]{groupId, artifactId, version} );
for ( Iterator i = model.getDependencies().iterator(); i.hasNext(); ) for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{ {
Dependency d = (Dependency) i.next(); Dependency d = (Dependency) i.next();
@ -188,8 +194,91 @@ public class DependenciesReport
endTable(); endTable();
} }
endSection(); endSection();
// Transitive dependencies
if ( !dependencies.isEmpty() )
{
Set artifacts = getTransitiveDependencies( project );
startSection( getBundle( locale ).getString( "report.transitivedependencies.title" ) );
if ( artifacts.isEmpty() )
{
// TODO: should the report just be excluded?
paragraph( getBundle( locale ).getString( "report.transitivedependencies.nolist" ) );
}
else
{
startTable();
tableCaption( getBundle( locale ).getString( "report.transitivedependencies.intro" ) );
String groupId = getBundle( locale ).getString( "report.transitivedependencies.column.groupId" );
String artifactId = getBundle( locale ).getString( "report.transitivedependencies.column.artifactId" );
String version = getBundle( locale ).getString( "report.transitivedependencies.column.version" );
tableHeader( new String[]{groupId, artifactId, version} );
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
tableRow( new String[]{artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()} );
}
endTable();
}
endSection();
}
}
/**
* Return a set of artifact which are not already present in the dependencies list.
*
* @param project a Maven project
* @return a set of transitive dependencies
*/
private Set getTransitiveDependencies( MavenProject project )
{
Set result = new HashSet();
if ( ( project.getDependencies() == null ) ||
( project.getArtifacts() == null ) )
{
return result;
}
List dependencies = project.getDependencies();
Set artifacts = project.getArtifacts();
for ( Iterator j = artifacts.iterator(); j.hasNext(); )
{
Artifact artifact = (Artifact)j.next();
boolean toadd = true;
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
Dependency dependency = (Dependency) i.next();
if ( ( artifact.getArtifactId().equals( dependency.getArtifactId() ) ) &&
( artifact.getGroupId().equals( dependency.getGroupId() ) ) &&
( artifact.getVersion().equals( dependency.getVersion() ) ) )
{
toadd = false;
break;
}
}
if ( toadd )
{
result.add( artifact );
}
}
return result;
} }
} }

View File

@ -1,3 +1,19 @@
# -------------------------------------------------------------------
# Copyright 2001-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.
# -------------------------------------------------------------------
report.dependencies.name=Dependencies report.dependencies.name=Dependencies
report.dependencies.nolist=There are no dependencies for this project. It is a standalone application that does not depend on any other project. report.dependencies.nolist=There are no dependencies for this project. It is a standalone application that does not depend on any other project.
report.dependencies.title=Project Dependencies report.dependencies.title=Project Dependencies
@ -6,6 +22,12 @@ report.dependencies.intro=The following is a list of dependencies for this proje
report.dependencies.column.groupId=GroupId report.dependencies.column.groupId=GroupId
report.dependencies.column.artifactId=ArtifactId report.dependencies.column.artifactId=ArtifactId
report.dependencies.column.version=Version report.dependencies.column.version=Version
report.transitivedependencies.title=Project Transitive Dependencies
report.transitivedependencies.nolist=There are no transitive dependencies for this project.
report.transitivedependencies.intro=The following is a list of transitive dependencies for this project. Transitive dependencies are the dependencies of the project dependencies :
report.transitivedependencies.column.groupId=GroupId
report.transitivedependencies.column.artifactId=ArtifactId
report.transitivedependencies.column.version=Version
report.mailing-lists.name=Mailing Lists report.mailing-lists.name=Mailing Lists
report.mailing-lists.nolist=There are no mailing lists currently associated with this project. report.mailing-lists.nolist=There are no mailing lists currently associated with this project.
report.mailing-lists.title=Project Mailing Lists report.mailing-lists.title=Project Mailing Lists

View File

@ -1,11 +1,33 @@
# -------------------------------------------------------------------
# Copyright 2001-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.
# -------------------------------------------------------------------
report.dependencies.name=Dépendances report.dependencies.name=Dépendances
report.dependencies.nolist=Il n'y a aucune dépendance pour ce projet. C'est une application autonome qui ne dépend d'aucun autre projet. report.dependencies.nolist=Il n'y a aucune dépendance pour ce projet. C'est une application autonome qui ne dépend d'aucun autre projet.
report.dependencies.title=Dépendances du projet report.dependencies.title=Dépendances du projet
report.dependencies.description=Ce document liste les dépendances du projet et fournit les informations sur chaque dépendance. report.dependencies.description=Ce document liste les dépendances du projet et fournit les informations sur chaque dépendance.
report.dependencies.intro= Ce qui suit est la liste de dépendances pour ce projet. Ces dépendances sont requises pour compiler et exécuter l'application : report.dependencies.intro=Ce qui suit est la liste de dépendances pour ce projet. Ces dépendances sont requises pour compiler et exécuter l'application :
report.dependencies.column.groupId=GroupId report.dependencies.column.groupId=GroupId
report.dependencies.column.artifactId=ArtifactId report.dependencies.column.artifactId=ArtifactId
report.dependencies.column.version=Version report.dependencies.column.version=Version
report.transitivedependencies.title=Dépendances transitives du projet
report.transitivedependencies.nolist=Il n'y a aucune dépendance transitive pour ce projet.
report.transitivedependencies.intro=Ce qui suit est la liste de dépendances transitives pour ce projet. Les dépendances transitives sont les dépendances des dépendances du projet :
report.transitivedependencies.column.groupId=GroupId
report.transitivedependencies.column.artifactId=ArtifactId
report.transitivedependencies.column.version=Version
report.mailing-lists.name=Listes de diffusion report.mailing-lists.name=Listes de diffusion
report.mailing-lists.nolist= Il n'y a aucune liste de diffusion actuellement liée à ce projet. report.mailing-lists.nolist= Il n'y a aucune liste de diffusion actuellement liée à ce projet.
report.mailing-lists.title=Listes de diffusion du projet report.mailing-lists.title=Listes de diffusion du projet

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/*
* Copyright 2001-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.
*/
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.report.projectinfo.test1</groupId>
<artifactId>project-info-reports-plugin-test1</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2005</inceptionYear>
<name>Maven ProjectInfo Report Test1</name>
<description>Test the transitive dependencies of this project</description>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<developers>
<developer>
<id>vsiveton</id>
<name>Vincent Siveton</name>
<email>vsiveton@apache.org</email>
<organization>Apache Software Foundation</organization>
<roles>
<role>Java Developer</role>
</roles>
<timezone>-5</timezone>
</developer>
</developers>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -0,0 +1,13 @@
package org.apache.maven.report.projectinfo.test1;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
org.apache.maven.report.projectinfo.test1;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}