This commit is contained in:
Emmanuel Venisse 2005-06-22 23:01:35 +00:00
parent e95085dbbe
commit 35eb0793a3
2 changed files with 201 additions and 201 deletions

View File

@ -1,200 +1,200 @@
package org.apache.maven.report.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.project.MavenProject;
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 org.codehaus.doxia.site.renderer.SiteRenderer;
import java.io.IOException;
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
/**
* @goal dependencies
*
* @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
{
/**
* @parameter expression="${project.build.directory}/site"
* @required
*/
private String outputDirectory;
/**
* @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
* @required
* @readonly
*/
private SiteRenderer siteRenderer;
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
*/
public String getName( Locale locale )
{
return getBundle( locale ).getString( "report.dependencies.name" );
}
/**
* @see org.apache.maven.reporting.MavenReport#getCategoryName()
*/
public String getCategoryName()
{
return CATEGORY_PROJECT_INFORMATION;
}
/**
* @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
*/
public String getDescription( Locale locale )
{
return getBundle( locale ).getString( "report.dependencies.description" );
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
*/
protected String getOutputDirectory()
{
return outputDirectory;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getProject()
*/
protected MavenProject getProject()
{
return project;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
*/
protected SiteRenderer getSiteRenderer()
{
return siteRenderer;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
try
{
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject().getModel(), locale );
r.render();
}
catch( IOException e )
{
throw new MavenReportException( "Can't write the report " + getOutputName(), e );
}
}
/**
* @see org.apache.maven.reporting.MavenReport#getOutputName()
*/
public String getOutputName()
{
return "dependencies";
}
static class DependenciesRenderer
extends AbstractMavenReportRenderer
{
private Model model;
private Locale locale;
public DependenciesRenderer( Sink sink, Model model, Locale locale )
{
super( sink );
this.model = model;
this.locale = locale;
}
// How to i18n these ...
public String getTitle()
{
return getBundle( locale ).getString( "report.dependencies.title" );
}
public void renderBody()
{
startSection( getTitle() );
if ( model.getDependencies().isEmpty() )
{
// TODO: should the report just be excluded?
paragraph( getBundle( locale ).getString( "report.dependencies.nolist" ) );
}
else
{
startTable();
tableCaption( getBundle( locale ).getString( "report.dependencies.intro" ) );
String groupId = getBundle( locale ).getString( "report.dependencies.column.groupId" );
String artifactId = getBundle( locale ).getString( "report.dependencies.column.artifactId" );
String version = getBundle( locale ).getString( "report.dependencies.column.version" );
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();
}
}
private static ResourceBundle getBundle( Locale locale )
{
return ResourceBundle.getBundle("project-info-report", locale, DependenciesReport.class.getClassLoader() );
}
}
package org.apache.maven.report.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.project.MavenProject;
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 org.codehaus.doxia.site.renderer.SiteRenderer;
import java.io.IOException;
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
/**
* @goal dependencies
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @plexus.component
*/
public class DependenciesReport
extends AbstractMavenReport
{
/**
* @parameter expression="${project.build.directory}/site"
* @required
*/
private String outputDirectory;
/**
* @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
* @required
* @readonly
*/
private SiteRenderer siteRenderer;
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
*/
public String getName( Locale locale )
{
return getBundle( locale ).getString( "report.dependencies.name" );
}
/**
* @see org.apache.maven.reporting.MavenReport#getCategoryName()
*/
public String getCategoryName()
{
return CATEGORY_PROJECT_INFORMATION;
}
/**
* @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
*/
public String getDescription( Locale locale )
{
return getBundle( locale ).getString( "report.dependencies.description" );
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
*/
protected String getOutputDirectory()
{
return outputDirectory;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getProject()
*/
protected MavenProject getProject()
{
return project;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
*/
protected SiteRenderer getSiteRenderer()
{
return siteRenderer;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
try
{
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject().getModel(), locale );
r.render();
}
catch( IOException e )
{
throw new MavenReportException( "Can't write the report " + getOutputName(), e );
}
}
/**
* @see org.apache.maven.reporting.MavenReport#getOutputName()
*/
public String getOutputName()
{
return "dependencies";
}
static class DependenciesRenderer
extends AbstractMavenReportRenderer
{
private Model model;
private Locale locale;
public DependenciesRenderer( Sink sink, Model model, Locale locale )
{
super( sink );
this.model = model;
this.locale = locale;
}
// How to i18n these ...
public String getTitle()
{
return getBundle( locale ).getString( "report.dependencies.title" );
}
public void renderBody()
{
startSection( getTitle() );
if ( model.getDependencies().isEmpty() )
{
// TODO: should the report just be excluded?
paragraph( getBundle( locale ).getString( "report.dependencies.nolist" ) );
}
else
{
startTable();
tableCaption( getBundle( locale ).getString( "report.dependencies.intro" ) );
String groupId = getBundle( locale ).getString( "report.dependencies.column.groupId" );
String artifactId = getBundle( locale ).getString( "report.dependencies.column.artifactId" );
String version = getBundle( locale ).getString( "report.dependencies.column.version" );
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();
}
}
private static ResourceBundle getBundle( Locale locale )
{
return ResourceBundle.getBundle("project-info-report", locale, DependenciesReport.class.getClassLoader() );
}
}

View File

@ -35,7 +35,7 @@ import java.util.ResourceBundle;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: MailingListsReport.java,v 1.4 2005/02/23 00:08:03 brett Exp $
* @version $Id$
* @goal mailing-list
*/
public class MailingListsReport