diff --git a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java index 0ec197f953..50bc0aad28 100644 --- a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java +++ b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java @@ -28,7 +28,6 @@ import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReport; -import org.apache.maven.reporting.MavenReportConfiguration; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.i18n.I18N; @@ -225,14 +224,8 @@ public class DoxiaMojo { Locale locale = (Locale) i.next(); - MavenReportConfiguration config = new MavenReportConfiguration(); - - config.setProject( project ); - File localeOutputDirectory = getOuputDirectory( locale ); - config.setReportOutputDirectory( localeOutputDirectory ); - //Generate reports if ( reports != null ) { @@ -242,7 +235,7 @@ public class DoxiaMojo getLog().info( "Generate " + report.getName( locale ) + " report." ); - report.setConfiguration( config ); + report.setReportOutputDirectory( localeOutputDirectory ); String outputFileName = report.getOutputName() + ".html"; diff --git a/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java b/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java index bdb8836552..1e572784fc 100644 --- a/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java +++ b/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java @@ -43,7 +43,9 @@ public abstract class AbstractMavenReport extends AbstractMojo implements MavenReport { - /** @todo share, use default excludes from plexus utils. */ + /** + * @todo share, use default excludes from plexus utils. + */ protected static final String[] DEFAULT_EXCLUDES = {// Miscellaneous typical temporary files "**/*~", "**/#*#", "**/.#*", "**/%*%", "**/._*", @@ -62,47 +64,30 @@ public abstract class AbstractMavenReport // Mac "**/.DS_Store"}; - private MavenReportConfiguration config; - private Sink sink; private Locale locale = Locale.ENGLISH; - public MavenReportConfiguration getConfiguration() - { - return config; - } - - public void setConfiguration( MavenReportConfiguration config ) - { - this.config = config; - } - protected abstract SiteRenderer getSiteRenderer(); protected abstract String getOutputDirectory(); protected abstract MavenProject getProject(); + private File reportOutputDirectory; + /** * @see org.apache.maven.plugin.Mojo#execute() */ public void execute() throws MojoExecutionException { - config = new MavenReportConfiguration(); - - config.setProject( getProject() ); - - config.setReportOutputDirectory( new File( getOutputDirectory() ) ); - try { String outputDirectory = getOutputDirectory(); XhtmlSink sink = getSiteRenderer().createSink( new File( outputDirectory ), getOutputName() + ".html", - outputDirectory, - getSiteDescriptor(), "maven" ); + outputDirectory, getSiteDescriptor(), "maven" ); generate( sink, Locale.ENGLISH ); @@ -120,14 +105,9 @@ public abstract class AbstractMavenReport public void generate( Sink sink, Locale locale ) throws MavenReportException { - if ( config == null ) - { - throw new MavenReportException( "You must specify a report configuration." ); - } - if ( sink == null ) { - throw new MavenReportException( "You must specify a sink configuration." ); + throw new MavenReportException( "You must specify a sink." ); } else { @@ -158,7 +138,6 @@ public abstract class AbstractMavenReport } private String getReportsMenu() - throws MojoExecutionException { StringBuffer buffer = new StringBuffer(); buffer.append( "\n" ); @@ -212,4 +191,18 @@ public abstract class AbstractMavenReport return new StringInputStream( siteDescriptorContent ); } + + public File getReportOutputDirectory() + { + if ( reportOutputDirectory == null ) + { + reportOutputDirectory = new File( getOutputDirectory() ); + } + return reportOutputDirectory; + } + + public void setReportOutputDirectory( File reportOutputDirectory ) + { + this.reportOutputDirectory = reportOutputDirectory; + } } diff --git a/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReport.java b/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReport.java index e67174b562..f6f0f053be 100644 --- a/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReport.java +++ b/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReport.java @@ -19,6 +19,7 @@ package org.apache.maven.reporting; import org.codehaus.doxia.sink.Sink; import java.io.IOException; +import java.io.File; import java.util.Locale; /** @@ -36,10 +37,6 @@ public interface MavenReport String CATEGORY_PROJECT_REPORTS = "Project Reports"; - MavenReportConfiguration getConfiguration(); - - void setConfiguration( MavenReportConfiguration config ); - void generate( Sink sink, Locale locale ) throws MavenReportException; @@ -53,4 +50,9 @@ public interface MavenReport Sink getSink() throws IOException; + + // TODO: remove? + void setReportOutputDirectory( File outputDirectory ); + + File getReportOutputDirectory(); } diff --git a/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReportConfiguration.java b/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReportConfiguration.java deleted file mode 100644 index 8bc28afe33..0000000000 --- a/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReportConfiguration.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.apache.maven.reporting; - -/* - * Copyright 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.Model; -import org.apache.maven.model.Scm; -import org.apache.maven.project.MavenProject; - -import java.io.File; -import java.util.List; - -/** - * @author Emmanuel Venisse - * @version $Id: MavenReport.java 163376 2005-02-23 00:06:06Z brett $ - */ -public class MavenReportConfiguration -{ - private MavenProject project; - - private File basedir; - - private File outputDirectory; - - public void setReportOutputDirectory( File outputDirectory ) - { - this.outputDirectory = outputDirectory; - } - - public File getReportOutputDirectory() - { - return outputDirectory; - } - - public File getBasedir() - { - return basedir; - } - - public void setBasedir( File basedir ) - { - this.basedir = basedir; - } - - public Model getModel() - { - return project.getModel(); - } - - public void setProject( MavenProject project ) - { - this.project = project; - } - - public MavenProject getProject() - { - return project; - } - - public List getDependencies() - { - return getModel().getDependencies(); - } - - public List getMailingLists() - { - return getModel().getMailingLists(); - } - - public Scm getScm() - { - return getModel().getScm(); - } - - public void setScm( Scm scm ) - { - getModel().setScm( scm ); - } - - public String getSourceDirectory() - { - return getModel().getBuild().getSourceDirectory(); - } - - public void setSourceDirectory( String sourceDirectory ) - { - getModel().getBuild().setSourceDirectory( sourceDirectory ); - } - - public List getCompileSourceRoots() - { - return project.getCompileSourceRoots(); - } - - public String getScriptSourceDirectory() - { - return getModel().getBuild().getScriptSourceDirectory(); - } - - public void setScriptSourceDirectory( String scriptSourceDirectory ) - { - getModel().getBuild().setScriptSourceDirectory( scriptSourceDirectory ); - } - - public String getTestSourceDirectory() - { - return getModel().getBuild().getTestSourceDirectory(); - } - - public void setTestSourceDirectory( String testSourceDirectory ) - { - getModel().getBuild().setTestSourceDirectory( testSourceDirectory ); - } - - public List getTestCompileSourceRoots() - { - return project.getTestCompileSourceRoots(); - } - -} \ No newline at end of file diff --git a/maven-reports/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java b/maven-reports/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java index e07f4b1a37..4bc9bde345 100644 --- a/maven-reports/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java +++ b/maven-reports/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java @@ -141,7 +141,7 @@ public class CheckstyleReport { FileOutputStream out; // TODO: I removed outputDirectory, and shouldn't have. Put it back here. - File resultFile = new File( getConfiguration().getModel().getBuild().getDirectory() + "/site", resultFileName ); + File resultFile = new File( getProject().getModel().getBuild().getDirectory() + "/site", resultFileName ); try { File parentFile = resultFile.getParentFile(); @@ -168,6 +168,7 @@ public class CheckstyleReport } File[] files; + String sourceDirectory = getProject().getBuild().getSourceDirectory(); try { List filesList = getFilesToProcess( "**/*.java", null ); @@ -180,7 +181,7 @@ public class CheckstyleReport } catch( IOException e ) { - throw new MavenReportException( "Can't parse " + getConfiguration().getSourceDirectory(), e ); + throw new MavenReportException( "Can't parse " + sourceDirectory, e ); } Configuration config; @@ -220,7 +221,8 @@ public class CheckstyleReport checker.configure( config ); - AuditListener sinkListener = new CheckstyleReportListener( getSink(), getConfiguration().getSourceDirectory() ); + // TODO: use source roots + AuditListener sinkListener = new CheckstyleReportListener( getSink(), sourceDirectory ); if ( listener != null ) { @@ -272,7 +274,7 @@ public class CheckstyleReport excludesStr.append( DEFAULT_EXCLUDES[i] ); } - return FileUtils.getFiles( new File( getConfiguration().getSourceDirectory() ), includes, excludesStr.toString() ); + return FileUtils.getFiles( new File( getProject().getBuild().getSourceDirectory() ), includes, excludesStr.toString() ); } private Properties createOverridingProperties() @@ -280,7 +282,7 @@ public class CheckstyleReport Properties props = new Properties(); props.setProperty( "checkstyle.header.file", "LICENSE.txt" ); // TODO: explicit output directory when it is back - props.setProperty( "checkstyle.cache.file", getConfiguration().getModel().getBuild().getDirectory() + "/checkstyle-cachefile" ); + props.setProperty( "checkstyle.cache.file", getProject().getModel().getBuild().getDirectory() + "/checkstyle-cachefile" ); return props; } } \ No newline at end of file diff --git a/maven-reports/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java b/maven-reports/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java index 02b680b994..9f2a7e485e 100644 --- a/maven-reports/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java +++ b/maven-reports/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java @@ -24,6 +24,7 @@ import java.util.Locale; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.model.Model; import org.codehaus.doxia.sink.Sink; import org.codehaus.doxia.site.renderer.SiteRenderer; import org.codehaus.plexus.util.FileUtils; @@ -106,11 +107,6 @@ public class JavadocReport public void generate( Sink sink, Locale locale ) throws MavenReportException { - if ( getConfiguration() == null ) - { - throw new MavenReportException( "You must specify a report configuration." ); - } - executeReport( locale); } @@ -122,23 +118,24 @@ public class JavadocReport { try { - File outputDir = new File( getConfiguration().getReportOutputDirectory().getAbsolutePath() + "/apidocs" ); + File outputDir = new File( getReportOutputDirectory().getAbsolutePath() + "/apidocs" ); outputDir.mkdirs(); int actualYear = Calendar.getInstance().get( Calendar.YEAR ); String year; - if ( getConfiguration().getModel().getInceptionYear() != null - && Integer.valueOf( getConfiguration().getModel().getInceptionYear() ).intValue() == actualYear ) + Model model = getProject().getModel(); + if ( model.getInceptionYear() != null + && Integer.valueOf( model.getInceptionYear() ).intValue() == actualYear ) { - year = getConfiguration().getModel().getInceptionYear(); + year = model.getInceptionYear(); } else { - year = getConfiguration().getModel().getInceptionYear() + "-" + String.valueOf( actualYear ); + year = model.getInceptionYear() + "-" + String.valueOf( actualYear ); } StringBuffer classpath = new StringBuffer(); - for ( Iterator i = getConfiguration().getProject().getCompileClasspathElements().iterator(); i.hasNext(); ) + for ( Iterator i = getProject().getCompileClasspathElements().iterator(); i.hasNext(); ) { classpath.append( (String) i.next() ); if ( i.hasNext() ) @@ -149,14 +146,14 @@ public class JavadocReport StringBuffer sourcePath = new StringBuffer(); String[] fileList = new String[1]; - for ( Iterator i = getConfiguration().getCompileSourceRoots().iterator(); i.hasNext(); ) + for ( Iterator i = getProject().getCompileSourceRoots().iterator(); i.hasNext(); ) { String sourceDirectory = (String) i.next(); fileList = FileUtils.getFilesFromExtension( sourceDirectory, new String[] { "java" } ); sourcePath.append( sourceDirectory ); } - File javadocDirectory = new File( getConfiguration().getProject().getBuild().getDirectory() + "/javadoc" ); + File javadocDirectory = new File( getProject().getBuild().getDirectory() + "/javadoc" ); if ( fileList != null && fileList.length != 0 ) { StringBuffer files = new StringBuffer(); @@ -181,11 +178,11 @@ public class JavadocReport cl.createArgument().setValue( "-author" ); cl.createArgument().setValue( "-windowtitle" ); cl.createArgument().setValue( - getConfiguration().getModel().getName() + " " - + getConfiguration().getModel().getVersion() ); + model.getName() + " " + + model.getVersion() ); cl.createArgument().setValue( "-bottom" ); cl.createArgument().setValue( "Copyright © " + year + " " - + getConfiguration().getModel().getOrganization().getName() + + model.getOrganization().getName() + ". All Rights Reserved." ); cl.createArgument().setValue( "-sourcePath" ); cl.createArgument().setValue( sourcePath.toString() ); diff --git a/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java b/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java index 4493a63f49..80b2ee6f80 100644 --- a/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java +++ b/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java @@ -132,7 +132,9 @@ public class PmdReport PMD pmd = new PMD(); RuleContext ruleContext = new RuleContext(); Report report = new Report(); - PmdReportListener reportSink = new PmdReportListener( sink, getConfiguration().getSourceDirectory() ); + // TODO: use source roots instead + String sourceDirectory = getProject().getBuild().getSourceDirectory(); + PmdReportListener reportSink = new PmdReportListener( sink, sourceDirectory ); report.addListener( reportSink ); ruleContext.setReport( report ); @@ -149,7 +151,7 @@ public class PmdReport } catch ( IOException e ) { - throw new MavenReportException( "Can't parse " + getConfiguration().getSourceDirectory(), e ); + throw new MavenReportException( "Can't parse " + sourceDirectory, e ); } for ( Iterator i = files.iterator(); i.hasNext(); ) @@ -209,7 +211,7 @@ public class PmdReport private List getFilesToProcess( String includes, String excludes ) throws IOException { - File dir = new File( getConfiguration().getSourceDirectory() ); + File dir = new File( getProject().getBuild().getSourceDirectory() ); if ( !dir.exists() ) { return Collections.EMPTY_LIST; diff --git a/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java b/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java index bdb6f93132..c56c9e6358 100644 --- a/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java +++ b/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java @@ -115,7 +115,7 @@ public class DependenciesReport { try { - DependenciesRenderer r = new DependenciesRenderer( getSink(), getConfiguration().getModel() ); + DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject().getModel() ); r.render(); } diff --git a/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java b/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java index d416854a46..d53b5dc1bb 100644 --- a/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java +++ b/maven-reports/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java @@ -116,7 +116,7 @@ public class MailingListsReport { try { - MailingListsRenderer r = new MailingListsRenderer( getSink(), getConfiguration().getModel() ); + MailingListsRenderer r = new MailingListsRenderer( getSink(), getProject().getModel() ); r.render(); }