Author: epunzalan Date: Tue Mar 7 02:14:54 2006 New Revision: 383836 URL: http://svn.apache.org/viewcvs?rev=383836&view=rev Log: PR: MPIR-30
Added new goal summary which include: - general project information like project name, homepage. - project organization - build information like groupId, artifactId, version, and type Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java?rev=383836&view=auto ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java (added) +++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java Tue Mar 7 02:14:54 2006 @@ -0,0 +1,257 @@ +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.project.MavenProject; +import org.apache.maven.reporting.AbstractMavenReport; +import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.model.Organization; +import org.codehaus.doxia.sink.Sink; +import org.codehaus.doxia.site.renderer.SiteRenderer; +import org.codehaus.plexus.i18n.I18N; + +import java.util.Locale; + +/** + * @goal summary + * @plexus.component + * + * @author Edwin Punzalan + */ +public class ProjectSummaryReport + extends AbstractMavenReport +{ + /** + * Report output directory. + * + * @parameter expression="${project.reporting.outputDirectory}" + * @required + */ + private String outputDirectory; + + /** + * Doxia Site Renderer. + * + * @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}" + * @required + * @readonly + */ + private SiteRenderer siteRenderer; + + /** + * The Maven Project. + * + * @parameter expression="${project}" + * @required + * @readonly + */ + private MavenProject project; + + /** + * Internationalization. + * + * @component + */ + private I18N i18n; + + protected void executeReport( Locale locale ) + throws MavenReportException + { + new ProjectSummaryRenderer( getSink(), locale ).render(); + } + + /** + * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) + */ + public String getName( Locale locale ) + { + return i18n.getString( "project-info-report", locale, "report.summary.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 i18n.getString( "project-info-report", locale, "report.summary.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.MavenReport#getOutputName() + */ + public String getOutputName() + { + return "project-summary"; + } + + private class ProjectSummaryRenderer + extends AbstractMavenReportRenderer + { + private Locale locale; + + public ProjectSummaryRenderer( Sink sink, Locale locale ) + { + super( sink ); + + this.locale = locale; + } + + public String getTitle() + { + return getReportString( "report.summary.title" ); + } + + protected void renderBody() + { + startSection( getTitle() ); + + //generatl information sub-section + String name = project.getName(); + if ( name == null ) + { + name = ""; + } + String description = project.getDescription(); + if ( description == null ) + { + description = ""; + } + String homepage = project.getUrl(); + if ( homepage == null ) + { + homepage = ""; + } + + startSection( getReportString( "report.summary.general.title" ) ); + startTable(); + tableHeader( new String[] { getReportString( "Field" ), getReportString( "Value" ) } ); + tableRow( new String[] { getReportString( "report.summary.general.name" ), name } ); + tableRow( new String[] { getReportString( "report.summary.general.description" ), description } ); + tableRowWithLink( new String[] { getReportString( "report.summary.general.homepage" ), homepage } ); + endTable(); + endSection(); + + //organization sub-section + startSection( getReportString( "report.summary.organization.title" ) ); + Organization organization = project.getOrganization(); + if ( organization == null ) + { + paragraph( "This project does not belong to an organization." ); + } + else + { + if ( organization.getName() == null ) + { + organization.setName( "" ); + } + if ( organization.getUrl() == null ) + { + organization.setUrl( "") ; + } + + startTable(); + tableHeader( new String[] { getReportString( "Field" ), getReportString( "Value" ) } ); + tableRow( new String[] { getReportString( "report.summary.organization.name" ), organization.getName() } ); + tableRowWithLink( new String[] { getReportString( "report.summary.organization.url" ), organization.getUrl() } ); + endTable(); + } + endSection(); + + //build section + startSection( getReportString( "report.summary.build.title" ) ); + startTable(); + tableHeader( new String[] { getReportString( "Field" ), getReportString( "Value" ) } ); + tableRow( new String[] { getReportString( "report.summary.build.groupid" ), project.getGroupId() } ); + tableRow( new String[] { getReportString( "report.summary.build.artifactid" ), project.getArtifactId() } ); + tableRow( new String[] { getReportString( "report.summary.build.version" ), project.getVersion() } ); + tableRow( new String[] { getReportString( "report.summary.build.type" ), project.getPackaging() } ); + endTable(); + endSection(); + + endSection(); + } + + private String getReportString( String key ) + { + return i18n.getString( "project-info-report", locale, key ); + } + + private void tableRowWithLink( String[] content ) + { + sink.tableRow(); + + for ( int ctr = 0; ctr < content.length; ctr++ ) + { + String cell = content[ ctr ]; + if ( cell == null ) + { + cell = ""; + } + + sink.tableCell(); + + if ( ctr == content.length -1 && cell.length() > 0 ) + { + sink.link( cell ); + sink.text( cell ); + sink.link_(); + } + else + { + sink.text( cell ); + } + + sink.tableCell_(); + } + + sink.tableRow_(); + } + } +} Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties?rev=383836&r1=383835&r2=383836&view=diff ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties (original) +++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties Tue Mar 7 02:14:54 2006 @@ -175,3 +175,21 @@ report.dependency-convergence.stats.readyrelease.error.convergence=You do not have 100% convergence. report.dependency-convergence.stats.readyrelease.error.snapshots=You have SNAPSHOT dependencies. report.dependency-convergence.convergence.caption=Dependencies used in sub-projects + +report.summary.title=Project Summary +report.summary.name=Project Summary +report.summary.description=This document lists other related information of this project +report.summary.field=Field +report.summary.value=Value +report.summary.general.title=Project Information +report.summary.general.name=Name +report.summary.general.description=Description +report.summary.general.homepage=Homepage +report.summary.build.title=Build Information +report.summary.build.groupid=GroupId +report.summary.build.artifactid=ArtifactId +report.summary.build.version=Version +report.summary.build.type=Type +report.summary.organization.title=Project Organization +report.summary.organization.name=Name +report.summary.organization.url=URL