mirror of https://github.com/apache/maven.git
PR: MNG-469
remove MavenConfiguration class git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191301 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a63032af4
commit
7299bd7058
|
@ -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";
|
||||
|
||||
|
|
|
@ -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( "<menu name=\"Project Documentation\">\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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 <a href="evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -115,7 +115,7 @@ public class DependenciesReport
|
|||
{
|
||||
try
|
||||
{
|
||||
DependenciesRenderer r = new DependenciesRenderer( getSink(), getConfiguration().getModel() );
|
||||
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject().getModel() );
|
||||
|
||||
r.render();
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ public class MailingListsReport
|
|||
{
|
||||
try
|
||||
{
|
||||
MailingListsRenderer r = new MailingListsRenderer( getSink(), getConfiguration().getModel() );
|
||||
MailingListsRenderer r = new MailingListsRenderer( getSink(), getProject().getModel() );
|
||||
|
||||
r.render();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue