Author: vsiveton
Date: Wed Nov 17 11:37:44 2010
New Revision: 1035985
URL: http://svn.apache.org/viewvc?rev=1035985&view=rev
Log:
MPIR-206: Generalize configuration for text reports
o added customBundle which load a customI18N object
o updated documentation
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm
(with props)
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/CimReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IssueTrackingReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/site.xml
Modified: maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml Wed Nov 17
11:37:44 2010
@@ -310,6 +310,11 @@ under the License.
<artifactId>plexus-utils</artifactId>
<version>1.5.5</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interpolation</artifactId>
+ <version>1.9</version>
+ </dependency>
<dependency>
<groupId>commons-validator</groupId>
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java
Wed Nov 17 11:37:44 2010
@@ -20,10 +20,12 @@ package org.apache.maven.report.projecti
*/
import java.util.Locale;
+import java.util.regex.Pattern;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.util.StringUtils;
public abstract class AbstractProjectInfoRenderer
extends AbstractMavenReportRenderer
@@ -57,5 +59,26 @@ public abstract class AbstractProjectInf
return i18n.getString( "project-info-report", locale, "report." +
section + '.' + key );
}
+ protected void text( String text )
+ {
+ if ( StringUtils.isEmpty( text ) ) // Take care of spaces
+ {
+ sink.text( "-" );
+ }
+ else
+ {
+ // custombundle text with xml?
+ String regex = "(.+?)<(\"[^\"]*\"|'[^']*'|[^'\">])*>(.+?)";
+ if ( Pattern.matches( regex, text ) )
+ {
+ sink.rawText( text );
+ }
+ else
+ {
+ sink.text( text );
+ }
+ }
+ }
+
protected abstract String getI18Nsection();
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
Wed Nov 17 11:37:44 2010
@@ -36,17 +36,30 @@ import org.apache.maven.plugin.MojoExecu
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
+import org.apache.maven.settings.Settings;
import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
+import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
+import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
import org.codehaus.plexus.util.IOUtil;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
/**
* Base class with the things that should be in AbstractMavenReport anyway.
@@ -92,11 +105,11 @@ public abstract class AbstractProjectInf
protected ArtifactFactory factory;
/**
- * Internationalization component.
+ * Internationalization component, could support also custom bundle using
{...@link #customBundle}.
*
* @component
*/
- protected I18N i18n;
+ private I18N i18n;
// ----------------------------------------------------------------------
// Mojo parameters
@@ -130,6 +143,25 @@ public abstract class AbstractProjectInf
*/
protected ArtifactRepository localRepository;
+ /**
+ * The current user system settings for use in Maven.
+ *
+ * @parameter expression="${settings}"
+ * @required
+ * @readonly
+ * @since 2.3
+ */
+ protected Settings settings;
+
+ /**
+ * Path for a custom bundle instead of using the default one. <br/>
+ * Using this field, you could change the texts in the generated reports.
+ *
+ * @parameter
expression="${project.basedir}/src/site/custom/project-info-report.properties"
+ * @since 2.3
+ */
+ protected String customBundle;
+
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@@ -160,8 +192,8 @@ public abstract class AbstractProjectInf
Artifact defaultSkin =
siteTool.getDefaultSkinArtifact( localRepository,
project.getRemoteArtifactRepositories() );
- SiteRenderingContext siteContext =
siteRenderer.createContextForSkin( defaultSkin.getFile(), attributes,
-
model, getName( locale ), locale );
+ SiteRenderingContext siteContext =
+ siteRenderer.createContextForSkin( defaultSkin.getFile(),
attributes, model, getName( locale ), locale );
RenderingContext context = new RenderingContext( outputDirectory,
filename );
@@ -180,23 +212,23 @@ public abstract class AbstractProjectInf
}
catch ( RendererException e )
{
- throw new MojoExecutionException(
- "An error has occurred in " + getName( Locale.ENGLISH ) + "
report generation.", e );
+ throw new MojoExecutionException( "An error has occurred in " +
getName( Locale.ENGLISH )
+ + " report generation.", e );
}
catch ( IOException e )
{
- throw new MojoExecutionException(
- "An error has occurred in " + getName( Locale.ENGLISH ) + "
report generation.", e );
+ throw new MojoExecutionException( "An error has occurred in " +
getName( Locale.ENGLISH )
+ + " report generation.", e );
}
catch ( SiteToolException e )
{
- throw new MojoExecutionException(
- "An error has occurred in " + getName( Locale.ENGLISH ) + "
report generation.", e );
+ throw new MojoExecutionException( "An error has occurred in " +
getName( Locale.ENGLISH )
+ + " report generation.", e );
}
catch ( MavenReportException e )
{
- throw new MojoExecutionException(
- "An error has occurred in " + getName( Locale.ENGLISH ) + "
report generation.", e );
+ throw new MojoExecutionException( "An error has occurred in " +
getName( Locale.ENGLISH )
+ + " report generation.", e );
}
finally
{
@@ -246,7 +278,29 @@ public abstract class AbstractProjectInf
protected String getI18nString( Locale locale, String key )
{
- return i18n.getString( "project-info-report", locale, "report." +
getI18Nsection() + '.' + key );
+ return getI18N( locale ).getString( "project-info-report", locale,
"report." + getI18Nsection() + '.' + key );
+ }
+
+ protected I18N getI18N( Locale locale )
+ {
+ if ( customBundle != null )
+ {
+ File customBundleFile = new File( customBundle );
+ if ( customBundleFile.isFile() &&
customBundleFile.getName().endsWith( ".properties" ) )
+ {
+ if ( !i18n.getClass().isAssignableFrom( CustomI18N.class ) )
+ {
+ // first load
+ i18n = new CustomI18N( project, settings,
customBundleFile, locale, i18n );
+ }
+ else if ( !i18n.getDefaultLanguage().equals(
locale.getLanguage() ) )
+ {
+ i18n = new CustomI18N( project, settings,
customBundleFile, locale, i18n );
+ }
+ }
+ }
+
+ return i18n;
}
protected abstract String getI18Nsection();
@@ -262,4 +316,209 @@ public abstract class AbstractProjectInf
{
return getI18nString( locale, "description" );
}
+
+ private static class CustomI18N
+ implements I18N
+ {
+ private final MavenProject project;
+
+ private final Settings settings;
+
+ private final String bundleName;
+
+ private final Locale locale;
+
+ private final I18N i18nOriginal;
+
+ private ResourceBundle bundle;
+
+ private final Object[] NO_ARGS = new Object[0];
+
+ public CustomI18N( MavenProject project, Settings settings, File
customBundleFile, Locale locale,
+ I18N i18nOriginal )
+ {
+ super();
+ this.project = project;
+ this.settings = settings;
+ this.locale = locale;
+ this.i18nOriginal = i18nOriginal;
+ this.bundleName =
+ customBundleFile.getName().substring( 0,
customBundleFile.getName().indexOf( ".properties" ) );
+
+ URLClassLoader classLoader = null;
+ try
+ {
+ classLoader = new URLClassLoader( new URL[] {
customBundleFile.getParentFile().toURI().toURL() } );
+ }
+ catch ( MalformedURLException e )
+ {
+ }
+
+ this.bundle = ResourceBundle.getBundle( this.bundleName, locale,
classLoader );
+ if ( !this.bundle.getLocale().getLanguage().equals(
locale.getLanguage() ) )
+ {
+ this.bundle = ResourceBundle.getBundle( this.bundleName, new
Locale( null ), classLoader );
+ }
+ }
+
+ public String getDefaultLanguage()
+ {
+ return locale.getLanguage();
+ }
+
+ public String getDefaultCountry()
+ {
+ return locale.getCountry();
+ }
+
+ public String getDefaultBundleName()
+ {
+ return bundleName;
+ }
+
+ public String[] getBundleNames()
+ {
+ return new String[] { bundleName };
+ }
+
+ public ResourceBundle getBundle()
+ {
+ return bundle;
+ }
+
+ public ResourceBundle getBundle( String bundleName )
+ {
+ return bundle;
+ }
+
+ public ResourceBundle getBundle( String bundleName, String
languageHeader )
+ {
+ return bundle;
+ }
+
+ public ResourceBundle getBundle( String bundleName, Locale locale )
+ {
+ return bundle;
+ }
+
+ public Locale getLocale( String languageHeader )
+ {
+ return new Locale( languageHeader );
+ }
+
+ public String getString( String key )
+ {
+ return getString( bundleName, locale, key );
+ }
+
+ public String getString( String key, Locale locale )
+ {
+ return getString( bundleName, locale, key );
+ }
+
+ public String getString( String bundleName, Locale locale, String key )
+ {
+ String value;
+
+ if ( locale == null )
+ {
+ locale = getLocale( null );
+ }
+
+ ResourceBundle rb = getBundle( bundleName, locale );
+ value = getStringOrNull( rb, key );
+
+ if ( value == null )
+ {
+ // try to load default
+ value = i18nOriginal.getString( bundleName, locale, key );
+ }
+
+ if ( value.indexOf( "${" ) < 0 )
+ {
+ return value;
+ }
+
+ final RegexBasedInterpolator interpolator = new
RegexBasedInterpolator();
+ try
+ {
+ interpolator.addValueSource( new EnvarBasedValueSource() );
+ }
+ catch ( final IOException e )
+ {
+ }
+
+ interpolator.addValueSource( new PropertiesBasedValueSource(
System.getProperties() ) );
+ interpolator.addValueSource( new PropertiesBasedValueSource(
project.getProperties() ) );
+ interpolator.addValueSource( new PrefixedObjectValueSource(
"project", project ) );
+ interpolator.addValueSource( new PrefixedObjectValueSource( "pom",
project ) );
+ interpolator.addValueSource( new PrefixedObjectValueSource(
"settings", settings ) );
+
+ try
+ {
+ value = interpolator.interpolate( value );
+ }
+ catch ( final InterpolationException e )
+ {
+ }
+
+ return value;
+ }
+
+ public String format( String key, Object arg1 )
+ {
+ return format( bundleName, locale, key, new Object[] { arg1 } );
+ }
+
+ public String format( String key, Object arg1, Object arg2 )
+ {
+ return format( bundleName, locale, key, new Object[] { arg1, arg2
} );
+ }
+
+ public String format( String bundleName, Locale locale, String key,
Object arg1 )
+ {
+ return format( bundleName, locale, key, new Object[] { arg1 } );
+ }
+
+ public String format( String bundleName, Locale locale, String key,
Object arg1, Object arg2 )
+ {
+ return format( bundleName, locale, key, new Object[] { arg1, arg2
} );
+ }
+
+ public String format( String bundleName, Locale locale, String key,
Object[] args )
+ {
+ if ( locale == null )
+ {
+ locale = getLocale( null );
+ }
+
+ String value = getString( bundleName, locale, key );
+ if ( args == null )
+ {
+ args = NO_ARGS;
+ }
+
+ MessageFormat messageFormat = new MessageFormat( "" );
+ messageFormat.setLocale( locale );
+ messageFormat.applyPattern( value );
+
+ return messageFormat.format( args );
+ }
+
+ private final String getStringOrNull( ResourceBundle rb, String key )
+ {
+ if ( rb != null )
+ {
+ try
+ {
+ return rb.getString( key );
+ }
+ catch ( MissingResourceException ignored )
+ {
+ // intentional
+ }
+ }
+ return null;
+ }
+ }
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/CimReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/CimReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/CimReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/CimReport.java
Wed Nov 17 11:37:44 2010
@@ -47,7 +47,7 @@ public class CimReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- CimRenderer r = new CimRenderer( getSink(), getProject().getModel(),
i18n, locale );
+ CimRenderer r = new CimRenderer( getSink(), getProject().getModel(),
getI18N( locale ), locale );
r.render();
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
Wed Nov 17 11:37:44 2010
@@ -42,7 +42,6 @@ import org.apache.maven.report.projectin
import
org.apache.maven.report.projectinfo.dependencies.DependenciesReportConfiguration;
import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
import
org.apache.maven.report.projectinfo.dependencies.renderer.DependenciesRenderer;
-import org.apache.maven.settings.Settings;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
@@ -136,16 +135,6 @@ public class DependenciesReport
// ----------------------------------------------------------------------
/**
- * The current user system settings for use in Maven.
- *
- * @since 2.1
- * @parameter expression="${settings}"
- * @required
- * @readonly
- */
- private Settings settings;
-
- /**
* Remote repositories used for the project.
*
* @since 2.1
@@ -210,7 +199,7 @@ public class DependenciesReport
new DependenciesReportConfiguration( dependencyDetailsEnabled,
dependencyLocationsEnabled );
DependenciesRenderer r =
- new DependenciesRenderer( getSink(), locale, i18n, getLog(),
settings, dependencies,
+ new DependenciesRenderer( getSink(), locale, getI18N( locale ),
getLog(), settings, dependencies,
dependencyTreeNode, config, repoUtils,
artifactFactory, mavenProjectBuilder,
remoteRepositories, localRepository );
r.render();
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
Wed Nov 17 11:37:44 2010
@@ -30,9 +30,6 @@ import org.apache.maven.project.MavenPro
import org.apache.maven.report.projectinfo.dependencies.ManagementDependencies;
import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
import
org.apache.maven.report.projectinfo.dependencies.renderer.DependencyManagementRenderer;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-
/**
* Generates the Project Dependency Management report.
@@ -93,16 +90,6 @@ public class DependencyManagementReport
private List<ArtifactRepository> remoteRepositories;
/**
- * The current user system settings for use in Maven.
- *
- * @since 2.3
- * @parameter expression="${settings}"
- * @required
- * @readonly
- */
- private Settings settings;
-
- /**
* Lazy instantiation for management dependencies.
*/
private ManagementDependencies managementDependencies;
@@ -121,7 +108,7 @@ public class DependencyManagementReport
repositoryMetadataManager );
DependencyManagementRenderer r =
- new DependencyManagementRenderer( getSink(), locale, i18n,
getLog(), getManagementDependencies(),
+ new DependencyManagementRenderer( getSink(), locale, getI18N(
locale ), getLog(), getManagementDependencies(),
artifactFactory,
mavenProjectBuilder, remoteRepositories,
localRepository, repoUtils );
r.render();
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IssueTrackingReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IssueTrackingReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IssueTrackingReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IssueTrackingReport.java
Wed Nov 17 11:37:44 2010
@@ -45,7 +45,7 @@ public class IssueTrackingReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- IssueTrackingRenderer r = new IssueTrackingRenderer( getSink(),
getProject().getModel(), i18n, locale );
+ IssueTrackingRenderer r = new IssueTrackingRenderer( getSink(),
getProject().getModel(), getI18N( locale ), locale );
r.render();
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java
Wed Nov 17 11:37:44 2010
@@ -84,7 +84,7 @@ public class LicenseReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- LicenseRenderer r = new LicenseRenderer( getSink(), getProject(),
i18n, locale, settings, linkOnly );
+ LicenseRenderer r = new LicenseRenderer( getSink(), getProject(),
getI18N( locale ), locale, settings, linkOnly );
r.render();
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
Wed Nov 17 11:37:44 2010
@@ -27,6 +27,7 @@ import java.util.Locale;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.model.MailingList;
import org.apache.maven.model.Model;
+import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.util.StringUtils;
@@ -48,9 +49,9 @@ public class MailingListsReport
*
* @parameter
* @since 2.2
+ * @deprecated since 2.3, you should use a custom bundle.
*/
- protected String introduction;
-
+ protected String introduction;
// ----------------------------------------------------------------------
// Public methods
@@ -59,7 +60,9 @@ public class MailingListsReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- MailingListsRenderer r = new MailingListsRenderer( getSink(),
getProject().getModel(), i18n, locale, introduction );
+ MailingListsRenderer r =
+ new MailingListsRenderer( getSink(), getProject().getModel(),
getI18N( locale ), locale, introduction,
+ getLog() );
r.render();
}
@@ -85,19 +88,23 @@ public class MailingListsReport
protected static class MailingListsRenderer
extends AbstractProjectInfoRenderer
{
- private Model model;
-
private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- private String introduction;
- MailingListsRenderer( Sink sink, Model model, I18N i18n, Locale
locale, String introduction )
+ private final Model model;
+
+ private final String introduction;
+
+ private final Log log;
+
+ MailingListsRenderer( Sink sink, Model model, I18N i18n, Locale
locale, String introduction, Log log )
{
super( sink, i18n, locale );
this.model = model;
-
+
this.introduction = introduction;
+
+ this.log = log;
}
protected String getI18Nsection()
@@ -126,13 +133,15 @@ public class MailingListsReport
if ( StringUtils.isNotBlank( introduction ) )
{
+ log.warn( "Since 2.3, the <introduction/> parameter is
deprecated. Please use a <customBundle/>"
+ + " parameter to configure a custom bundle." );
paragraph( introduction );
}
else
{
paragraph( getI18nString( "intro" ) );
}
-
+
startTable();
// To beautify the display with other archives
@@ -199,7 +208,7 @@ public class MailingListsReport
textRow.add( createLinkPatternedText( getArchiveServer(
otherArchive ), otherArchive ) );
- tableRow( (String[]) textRow.toArray( EMPTY_STRING_ARRAY )
);
+ tableRow( textRow.toArray( EMPTY_STRING_ARRAY ) );
// Other lines...
while ( it.hasNext() )
@@ -226,7 +235,7 @@ public class MailingListsReport
textRow.add( createLinkPatternedText(
getArchiveServer( otherArchive ), otherArchive ) );
- tableRow( (String[]) textRow.toArray(
EMPTY_STRING_ARRAY ) );
+ tableRow( textRow.toArray( EMPTY_STRING_ARRAY ) );
}
}
else
@@ -236,7 +245,7 @@ public class MailingListsReport
textRow.add( null );
}
- tableRow( (String[]) textRow.toArray( EMPTY_STRING_ARRAY )
);
+ tableRow( textRow.toArray( EMPTY_STRING_ARRAY ) );
}
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
Wed Nov 17 11:37:44 2010
@@ -52,7 +52,7 @@ public class ModulesReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- new ModulesRenderer( getSink(), getProject().getModel(), i18n, locale
).render();
+ new ModulesRenderer( getSink(), getProject().getModel(), getI18N(
locale ), locale ).render();
}
/** {...@inheritdoc} */
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
Wed Nov 17 11:37:44 2010
@@ -75,7 +75,7 @@ public class PluginManagementReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- PluginManagementRenderer r = new PluginManagementRenderer( getLog(),
getSink(), locale, i18n, project
+ PluginManagementRenderer r = new PluginManagementRenderer( getLog(),
getSink(), locale, getI18N( locale ), project
.getPluginManagement().getPlugins(), project, mavenProjectBuilder,
artifactFactory, localRepository );
r.render();
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
Wed Nov 17 11:37:44 2010
@@ -75,7 +75,7 @@ public class PluginsReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- PluginsRenderer r = new PluginsRenderer( getLog(), getSink(), locale,
i18n, project.getPluginArtifacts(),
+ PluginsRenderer r = new PluginsRenderer( getLog(), getSink(), locale,
getI18N( locale ), project.getPluginArtifacts(),
project.getReportArtifacts(),
project, mavenProjectBuilder,
artifactFactory,
localRepository );
r.render();
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java
Wed Nov 17 11:37:44 2010
@@ -73,7 +73,7 @@ public class ProjectSummaryReport
{
ProjectSummaryRenderer( Sink sink, Locale locale )
{
- super( sink, i18n, locale );
+ super( sink, getI18N( locale ), locale );
}
protected String getI18Nsection()
@@ -192,7 +192,7 @@ public class ProjectSummaryReport
// no source, target, compilerVersion: toolchain? default
target attribute of current
// maven-compiler-plugin's version? analyze packaged jar (like
dependencies)?
}
-
+
return minimumJavaVersion;
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java
Wed Nov 17 11:37:44 2010
@@ -103,7 +103,7 @@ public class ScmReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- ScmRenderer r = new ScmRenderer( getLog(), scmManager, getSink(),
getProject().getModel(), i18n, locale,
+ ScmRenderer r = new ScmRenderer( getLog(), scmManager, getSink(),
getProject().getModel(), getI18N( locale ), locale,
checkoutDirectoryName, webAccessUrl,
anonymousConnection,
developerConnection );
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java
Wed Nov 17 11:37:44 2010
@@ -56,7 +56,7 @@ public class TeamListReport
/** {...@inheritdoc} */
public void executeReport( Locale locale )
{
- TeamListRenderer r = new TeamListRenderer( getSink(),
project.getModel(), i18n, locale, getLog() );
+ TeamListRenderer r = new TeamListRenderer( getSink(),
project.getModel(), getI18N( locale ), locale, getLog() );
r.render();
}
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm?rev=1035985&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm
Wed Nov 17 11:37:44 2010
@@ -0,0 +1,105 @@
+ ------
+ Customize the Text Reports
+ ------
+ Vincent Siveton
+ ------
+ 2010-10-30
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Customize the Text Reports
+
+ Actually, all reports have a static renderer, only texts could be changed.
+
+ <<Note:>> This feature is only available in version 2.3+ of this plugin.
+
++-----------------+
+<project>
+ ...
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <!-- By default -->
+
<customBundle>\${project.basedir}/src/site/custom/project-info-report.properties</customBundle>
+ </configuration>
+ </plugin>
+ ...
+ </plugins>
+ </reporting>
+ ...
+</project>
++-----------------+
+
+ To change texts in the reports, you should import the default Project Info
report bundles from
+
{{http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/}}
+ and edit them. For example, if you want to modify the Mailing List
introduction, you should edit the report.mailing-lists.intro property.
+
+ Extract of the default bundle
{{{http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties}project-info-report.properties}}:
+
++-----------------+
+report.mailing-lists.intro = These are the mailing lists that have been
established for this project. For each list, there is a subscribe, unsubscribe,
and an archive link.
++-----------------+
+
+ Extract of a custom bundle
$\{project.basedir\}/src/site/custom/project-info-report.properties for the
Apache Commons project:
+
++-----------------+
+
+report.mailing-lists.intro = These are the mailing lists that have been
established for this project. For each list, there is a subscribe, unsubscribe,
and an archive link.\
+ <p>\
+ Questions related to the usage of Commons components should be
posted to the\
+ <a href="http://mail-archives.apache.org/mod_mbox/commons-user/"
class="externalLink">User List</a>.\
+ <br>\
+ The <a
href="http://mail-archives.apache.org/mod_mbox/commons-dev/"
class="externalLink">Developer List</a>\
+ is for questions and discussion related to the development of
Commons components.\
+ <br>\
+ Please do not cross-post; developers are also subscribed to the
user list.\
+ Read the archives first in case your question has already been
answered.\
+ If not, then subscribe to the appropriate list and post your
question.\
+ </p>\
+ <p>
+ <strong>Note:</strong> please don't send patches or attachments to
any of the mailing lists.\
+ Patches are best handled via the <i>Issue Tracking</i> system.\
+ Otherwise, please upload the file to a public server and include
the URL in the mail.\
+ </p>\
+ <p>\
+ Please read the <a
href="http://www.apache.org/foundation/public-archives.html"
class="externalLink">Public Forum Archive Policy</a>\
+ and <a href="http://www.apache.org/dev/contrib-email-tips.html"
class="externalLink">Tips for email contributors</a>.\
+ <br>\
+ For further information on Apache mailing lists please read\
+ <a href="http://www.apache.org/foundation/mailinglists.html"
class="externalLink">General mailing list information</a>\
+ in particular the section entitled\
+ <a
href="http://www.apache.org/foundation/mailinglists.html#subscribe"
class="externalLink">Subscribing and Unsubscribing</a>\
+ </p>
+
++-----------------+
+
+ <<Notes:>>
+
+ [[1]] You could also use Maven properties (i.e. $\{project.artifactId\}) in
the messages.
+
+ [[2]] If a bundle property is not defined in your custom bundle, the default
will be displayed.
+
+ []
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/apt/examples/custom-report.apt.vm
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml
Wed Nov 17 11:37:44 2010
@@ -73,5 +73,15 @@ under the License.
</p>
</answer>
</faq>
+
+ <faq id="Is it possible to customize the reports rendering">
+ <question>Is it possible to customize the reports rendering?</question>
+ <answer>
+ <p>
+ Not yet, but <a href="./issue-tracking.html">patches</a> are always
welcome!
+ You could only <a href="./examples/custom-report.html">customize</a>
the texts in the reports.
+ </p>
+ </answer>
+ </faq>
</part>
</faqs>
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/site/site.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/site/site.xml?rev=1035985&r1=1035984&r2=1035985&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/site/site.xml
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/site/site.xml Wed
Nov 17 11:37:44 2010
@@ -32,6 +32,7 @@ under the License.
<item name="Run Selective Reports"
href="examples/selective-project-info-reports.html"/>
<item name="Run Individual Reports"
href="examples/individual-reports.html"/>
<item name="Customize the SCM Report" href="examples/scm-report.html"/>
+ <item name="Customize Text Reports" href="examples/custom-report.html"/>
</menu>
</body>
</project>