clean up MavenReportException uses

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@314937 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-12 14:58:24 +00:00
parent 0ad22e0a67
commit ec7316abed
10 changed files with 281 additions and 268 deletions

View File

@ -38,15 +38,16 @@ import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Map;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@ -240,7 +241,8 @@ public class CheckstyleReport
{
if ( !canGenerateReport() )
{
throw new MavenReportException( "No source directory to process for style" );
// TODO: failure if not a report
throw new MavenReportException( "No source directory to process for checkstyle" );
}
Map files = executeCheckstyle();
@ -253,22 +255,30 @@ public class CheckstyleReport
private Map executeCheckstyle()
throws MavenReportException
{
File[] files = getFilesToProcess( includes, excludes );
File[] files = new File[0];
try
{
files = getFilesToProcess( includes, excludes );
}
catch ( IOException e )
{
throw new MavenReportException( "Error getting files to process", e );
}
String configFile = getConfigFile();
Properties overridingProperties = getOverridingProperties();
ModuleFactory moduleFactory = getModuleFactory();
FilterSet filterSet = getSuppressions();
Checker checker;
try
{
Configuration config = ConfigurationLoader.loadConfiguration( configFile, new PropertiesExpander(
overridingProperties ) );
ModuleFactory moduleFactory = getModuleFactory();
FilterSet filterSet = getSuppressions();
Configuration config =
ConfigurationLoader.loadConfiguration( configFile, new PropertiesExpander( overridingProperties ) );
checker = new Checker();
@ -313,6 +323,8 @@ public class CheckstyleReport
if ( failsOnError && nbErrors > 0 )
{
// TODO: should be a failure, not an error. Report is not meant to throw an exception here (so site would
// work regardless of config), but should record this information
throw new MavenReportException( "There are " + nbErrors + " formatting errors." );
}
@ -348,6 +360,7 @@ public class CheckstyleReport
}
else
{
// TODO: failure if not a report
throw new MavenReportException(
"Invalid output file format: (" + outputFileFormat + "). Must be 'plain' or 'xml'." );
}
@ -359,25 +372,27 @@ public class CheckstyleReport
private OutputStream getOutputStream( File file )
throws MavenReportException
{
File parentFile = file.getAbsoluteFile().getParentFile();
if ( !parentFile.exists() )
{
parentFile.mkdirs();
}
FileOutputStream fileOutputStream = null;
try
{
File parentFile = file.getAbsoluteFile().getParentFile();
if ( !parentFile.exists() )
{
parentFile.mkdirs();
}
return new FileOutputStream( file );
fileOutputStream = new FileOutputStream( file );
}
catch ( IOException ioe )
catch ( FileNotFoundException e )
{
throw new MavenReportException( "Can't open file for output: " + file.getAbsolutePath(), ioe );
throw new MavenReportException( "Unable to create output stream: " + file, e );
}
return fileOutputStream;
}
private File[] getFilesToProcess( String includes, String excludes )
throws MavenReportException
throws MavenReportException, IOException
{
StringBuffer excludesStr = new StringBuffer();
@ -397,16 +412,7 @@ public class CheckstyleReport
excludesStr.append( defaultExcludes[i] );
}
List files;
try
{
files = FileUtils.getFiles( sourceDirectory, includes, excludesStr.toString() );
}
catch ( IOException ioe )
{
throw new MavenReportException( "Failed to get source files", ioe );
}
List files = FileUtils.getFiles( sourceDirectory, includes, excludesStr.toString() );
return (File[]) files.toArray( EMPTY_FILE_ARRAY );
}
@ -420,7 +426,14 @@ public class CheckstyleReport
{
if ( propertiesFile != null )
{
p.load( new FileInputStream( propertiesFile ) );
if ( propertiesFile.exists() )
{
p.load( new FileInputStream( propertiesFile ) );
}
else
{
getLog().warn( "File '" + propertiesFile + "' not found - skipping" );
}
}
else if ( propertiesURL != null )
{
@ -465,6 +478,7 @@ public class CheckstyleReport
}
else
{
// TODO: failure if not a report
throw new MavenReportException( "Invalid configuration file format: " + format );
}
@ -472,21 +486,14 @@ public class CheckstyleReport
}
private ModuleFactory getModuleFactory()
throws MavenReportException
throws CheckstyleException
{
if ( StringUtils.isEmpty( packageNamesFile ) )
{
return null;
}
try
{
return PackageNamesLoader.loadModuleFactory( packageNamesFile );
}
catch ( CheckstyleException ce )
{
throw new MavenReportException( "failed to load package names XML: " + packageNamesFile, ce );
}
return PackageNamesLoader.loadModuleFactory( packageNamesFile );
}
private FilterSet getSuppressions()

View File

@ -19,6 +19,7 @@ package org.apache.maven.plugin.javadoc;
import org.apache.commons.lang.ClassUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
@ -28,6 +29,7 @@ import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
import org.codehaus.plexus.util.cli.DefaultConsumer;
@ -579,29 +581,29 @@ public class JavadocReport
protected void executeReport( Locale locale )
throws MavenReportException
{
try
{
int actualYear = Calendar.getInstance().get( Calendar.YEAR );
String year = String.valueOf( actualYear );
int actualYear = Calendar.getInstance().get( Calendar.YEAR );
String year = String.valueOf( actualYear );
Model model = getProject().getModel();
if ( model.getInceptionYear() != null )
Model model = getProject().getModel();
if ( model.getInceptionYear() != null )
{
if ( StringUtils.isNumeric( model.getInceptionYear() ) )
{
if ( StringUtils.isNumeric( model.getInceptionYear() ) )
if ( Integer.valueOf( model.getInceptionYear() ).intValue() != actualYear )
{
if ( Integer.valueOf( model.getInceptionYear() ).intValue() != actualYear )
{
year = model.getInceptionYear() + "-" + String.valueOf( actualYear );
}
}
else
{
getLog().warn( "The inception year is not a valid year." );
year = model.getInceptionYear() + "-" + String.valueOf( actualYear );
}
}
else
{
getLog().warn( "The inception year is not a valid year." );
}
}
StringBuffer options = new StringBuffer();
StringBuffer classpath = new StringBuffer();
StringBuffer options = new StringBuffer();
StringBuffer classpath = new StringBuffer();
try
{
for ( Iterator i = getProject().getCompileClasspathElements().iterator(); i.hasNext(); )
{
classpath.append( (String) i.next() );
@ -611,226 +613,251 @@ public class JavadocReport
classpath.append( PATH_SEPARATOR );
}
}
}
catch ( DependencyResolutionRequiredException e )
{
throw new MavenReportException( "Error in plugin descriptor - compile dependencies were not resolved", e );
}
if ( classpath.length() > 0 )
if ( classpath.length() > 0 )
{
options.append( "-classpath " );
options.append( quotedPathArgument( classpath.toString() ) );
}
StringBuffer sourcePath = new StringBuffer();
StringBuffer files = new StringBuffer();
for ( Iterator i = getProject().getCompileSourceRoots().iterator(); i.hasNext(); )
{
String sourceDirectory = (String) i.next();
String[] fileList = FileUtils.getFilesFromExtension( sourceDirectory, new String[]{"java"} );
if ( fileList != null && fileList.length != 0 )
{
options.append( "-classpath " );
options.append( quotedPathArgument( classpath.toString() ) );
}
StringBuffer sourcePath = new StringBuffer();
StringBuffer files = new StringBuffer();
for ( Iterator i = getProject().getCompileSourceRoots().iterator(); i.hasNext(); )
{
String sourceDirectory = (String) i.next();
String[] fileList = FileUtils.getFilesFromExtension( sourceDirectory, new String[]{"java"} );
if ( fileList != null && fileList.length != 0 )
for ( int j = 0; j < fileList.length; j++ )
{
for ( int j = 0; j < fileList.length; j++ )
{
files.append( quotedPathArgument( fileList[j] ) );
files.append( "\n" );
}
}
sourcePath.append( sourceDirectory );
if ( i.hasNext() )
{
sourcePath.append( PATH_SEPARATOR );
files.append( quotedPathArgument( fileList[j] ) );
files.append( "\n" );
}
}
if ( files.length() == 0 )
sourcePath.append( sourceDirectory );
if ( i.hasNext() )
{
return;
sourcePath.append( PATH_SEPARATOR );
}
}
File javadocDirectory = getReportOutputDirectory();
if ( files.length() == 0 )
{
return;
}
if ( !javadocDirectory.equals( getOutputDirectory() ) )
{
// we're in site-embedded report mode, so Doxia has set the
// reportOutputDirectory to the basedir of the site.
// Append 'apidocs'.
javadocDirectory = new File( javadocDirectory, "apidocs" );
}
javadocDirectory.mkdirs();
File javadocDirectory = getReportOutputDirectory();
File file = new File( javadocDirectory, "files" );
file.deleteOnExit();
if ( !javadocDirectory.equals( getOutputDirectory() ) )
{
// we're in site-embedded report mode, so Doxia has set the
// reportOutputDirectory to the basedir of the site.
// Append 'apidocs'.
javadocDirectory = new File( javadocDirectory, "apidocs" );
}
javadocDirectory.mkdirs();
File file = new File( javadocDirectory, "files" );
file.deleteOnExit();
try
{
FileUtils.fileWrite( file.getAbsolutePath(), files.toString() );
}
catch ( IOException e )
{
throw new MavenReportException( "Unable to write temporary file for command execution", e );
}
try
{
// Copy default style sheet
copyDefaultStylesheet( javadocDirectory );
}
catch ( IOException e )
{
throw new MavenReportException( "Unable to copy default stylesheet", e );
}
Commandline cmd = new Commandline();
Commandline cmd = new Commandline();
List arguments = new ArrayList();
List arguments = new ArrayList();
cmd.setWorkingDirectory( javadocDirectory.getAbsolutePath() );
cmd.setExecutable( getJavadocPath() );
cmd.setWorkingDirectory( javadocDirectory.getAbsolutePath() );
cmd.setExecutable( getJavadocPath() );
// General javadoc arguments
addArgIfNotEmpty( arguments, "-locale", quotedArgument( this.locale ) );
addArgIf( arguments, breakiterator, "-breakiterator", 1.4f );
if ( !StringUtils.isEmpty( doclet ) )
// General javadoc arguments
addArgIfNotEmpty( arguments, "-locale", quotedArgument( this.locale ) );
addArgIf( arguments, breakiterator, "-breakiterator", 1.4f );
if ( !StringUtils.isEmpty( doclet ) )
{
addArgIfNotEmpty( arguments, "-doclet", quotedArgument( doclet ) );
addArgIfNotEmpty( arguments, "-docletPath", quotedPathArgument( docletPath ) );
}
addArgIfNotEmpty( arguments, "-encoding", quotedArgument( encoding ) );
addArgIfNotEmpty( arguments, "-extdirs", quotedPathArgument( extdirs ) );
addArgIfNotEmpty( arguments, "-exclude", quotedArgument( excludePackageNames ), 1.4f );
if ( !StringUtils.isEmpty( maxmemory ) )
{
// Allow '128' or '128m'
if ( NumberUtils.isDigits( maxmemory ) )
{
addArgIfNotEmpty( arguments, "-doclet", quotedArgument( doclet ) );
addArgIfNotEmpty( arguments, "-docletPath", quotedPathArgument( docletPath ) );
}
addArgIfNotEmpty( arguments, "-encoding", quotedArgument( encoding ) );
addArgIfNotEmpty( arguments, "-extdirs", quotedPathArgument( extdirs ) );
addArgIfNotEmpty( arguments, "-exclude", quotedArgument( excludePackageNames ), 1.4f );
if ( !StringUtils.isEmpty( maxmemory ) )
{
// Allow '128' or '128m'
if ( NumberUtils.isDigits( maxmemory ) )
{
addArgIf( arguments, true, "-J-Xmx" + maxmemory + "m" );
}
else
{
if ( ( NumberUtils.isDigits( maxmemory.substring( 0, maxmemory.length() - 1 ) ) ) &&
( maxmemory.toLowerCase().endsWith( "m" ) ) )
{
addArgIf( arguments, true, "-J-Xmx" + maxmemory );
}
else
{
getLog().error(
"The maxmemory '" + maxmemory + "' is not a valid number. Ignore this option." );
}
}
}
if ( !StringUtils.isEmpty( minmemory ) )
{
// Allow '128' or '128m'
if ( NumberUtils.isDigits( minmemory ) )
{
addArgIf( arguments, true, "-J-Xms" + minmemory + "m" );
}
else
{
if ( ( NumberUtils.isDigits( minmemory.substring( 0, minmemory.length() - 1 ) ) ) &&
( minmemory.toLowerCase().endsWith( "m" ) ) )
{
addArgIf( arguments, true, "-J-Xms" + minmemory );
}
else
{
getLog().error(
"The minmemory '" + minmemory + "' is not a valid number. Ignore this option." );
}
}
}
if ( old && SystemUtils.isJavaVersionAtLeast( 1.4f ) )
{
getLog().warn( "Javadoc 1.4 doesn't support the -1.1 switch anymore. Ignore this option." );
addArgIf( arguments, true, "-J-Xmx" + maxmemory + "m" );
}
else
{
addArgIf( arguments, old, "-1.1" );
}
addArgIfNotEmpty( arguments, "-overview", quotedArgument( overview ) );
addArgIf( arguments, showPackage, "-package" );
addArgIf( arguments, showPrivate, "-private" );
addArgIf( arguments, showProtected, "-protected" );
addArgIf( arguments, public_, "-public" );
addArgIf( arguments, quiet, "-quiet", 1.4f );
addArgIfNotEmpty( arguments, "-source", quotedArgument( source ), 1.4f );
addArgIf( arguments, verbose, "-verbose" );
addArgIfNotEmpty( arguments, "-additionalparam", quotedArgument( additionalparam ) );
addArgIfNotEmpty( arguments, "-sourcePath", quotedPathArgument( sourcePath.toString() ) );
// javadoc arguments for default doclet
if ( StringUtils.isEmpty( doclet ) )
{
bottom = StringUtils.replace( bottom, "{currentYear}", year );
if ( project.getInceptionYear() != null )
if ( ( NumberUtils.isDigits( maxmemory.substring( 0, maxmemory.length() - 1 ) ) ) &&
( maxmemory.toLowerCase().endsWith( "m" ) ) )
{
bottom = StringUtils.replace( bottom, "{inceptionYear}", project.getInceptionYear() );
addArgIf( arguments, true, "-J-Xmx" + maxmemory );
}
else
{
bottom = StringUtils.replace( bottom, "{inceptionYear}-", "" );
getLog().error( "The maxmemory '" + maxmemory + "' is not a valid number. Ignore this option." );
}
if ( StringUtils.isEmpty( stylesheetfile ) )
{
stylesheetfile = javadocDirectory + File.separator + DEFAULT_CSS_NAME;
}
// End Specify default values
addArgIf( arguments, author, "-author" );
addArgIfNotEmpty( arguments, "-bottom", quotedArgument( bottom ) );
addArgIf( arguments, breakiterator, "-breakiterator", 1.4f );
addArgIfNotEmpty( arguments, "-charset", quotedArgument( charset ) );
addArgIfNotEmpty( arguments, "-d", quotedPathArgument( javadocDirectory.toString() ) );
addArgIf( arguments, docfilessubdirs, "-docfilessubdirs", 1.4f );
addArgIfNotEmpty( arguments, "-docencoding", quotedArgument( docencoding ) );
addArgIfNotEmpty( arguments, "-doctitle", quotedArgument( doctitle ) );
addArgIfNotEmpty( arguments, "-excludedocfilessubdir", quotedPathArgument( excludedocfilessubdir ),
1.4f );
addArgIfNotEmpty( arguments, "-footer", quotedArgument( footer ) );
addArgIfNotEmpty( arguments, "-group", quotedArgument( group ), true );
addArgIfNotEmpty( arguments, "-header", quotedArgument( header ) );
addArgIfNotEmpty( arguments, "-helpfile", quotedPathArgument( helpfile ) );
addArgIfNotEmpty( arguments, "-link", quotedPathArgument( link ), true );
addArgIfNotEmpty( arguments, "-linkoffline", quotedPathArgument( linkoffline ), true );
addArgIf( arguments, linksource, "-linksource", 1.4f );
addArgIf( arguments, nodeprecated, "-nodeprecated" );
addArgIf( arguments, nodeprecatedlist, "-nodeprecatedlist" );
addArgIf( arguments, nocomment, "-nocomment", 1.4f );
addArgIf( arguments, nohelp, "-nohelp" );
addArgIf( arguments, noindex, "-noindex" );
addArgIf( arguments, nonavbar, "-nonavbar" );
addArgIfNotEmpty( arguments, "-noqualifier", quotedArgument( noqualifier ), 1.4f );
addArgIf( arguments, nosince, "-nosince" );
addArgIf( arguments, notree, "-notree" );
addArgIf( arguments, serialwarn, "-serialwarn" );
addArgIf( arguments, splitindex, "-splitindex" );
addArgIfNotEmpty( arguments, "-stylesheetfile", quotedPathArgument( stylesheetfile ) );
addArgIfNotEmpty( arguments, "-tag", quotedArgument( tag ), 1.4f, true );
addArgIfNotEmpty( arguments, "-taglet", quotedArgument( taglet ), 1.4f );
addArgIfNotEmpty( arguments, "-tagletpath", quotedPathArgument( tagletpath ), 1.4f );
addArgIf( arguments, use, "-use" );
addArgIf( arguments, version, "-version" );
addArgIfNotEmpty( arguments, "-windowtitle", quotedArgument( windowtitle ) );
}
}
if ( options.length() > 0 )
if ( !StringUtils.isEmpty( minmemory ) )
{
// Allow '128' or '128m'
if ( NumberUtils.isDigits( minmemory ) )
{
File optionsFile = new File( javadocDirectory, "options" );
for ( Iterator it = arguments.iterator(); it.hasNext(); )
addArgIf( arguments, true, "-J-Xms" + minmemory + "m" );
}
else
{
if ( ( NumberUtils.isDigits( minmemory.substring( 0, minmemory.length() - 1 ) ) ) &&
( minmemory.toLowerCase().endsWith( "m" ) ) )
{
options.append( " " );
options.append( (String) it.next() );
addArgIf( arguments, true, "-J-Xms" + minmemory );
}
FileUtils.fileWrite( optionsFile.getAbsolutePath(), options.toString() );
cmd.createArgument().setValue( "@options" );
optionsFile.deleteOnExit();
else
{
getLog().error( "The minmemory '" + minmemory + "' is not a valid number. Ignore this option." );
}
}
}
if ( old && SystemUtils.isJavaVersionAtLeast( 1.4f ) )
{
getLog().warn( "Javadoc 1.4 doesn't support the -1.1 switch anymore. Ignore this option." );
}
else
{
addArgIf( arguments, old, "-1.1" );
}
addArgIfNotEmpty( arguments, "-overview", quotedArgument( overview ) );
addArgIf( arguments, showPackage, "-package" );
addArgIf( arguments, showPrivate, "-private" );
addArgIf( arguments, showProtected, "-protected" );
addArgIf( arguments, public_, "-public" );
addArgIf( arguments, quiet, "-quiet", 1.4f );
addArgIfNotEmpty( arguments, "-source", quotedArgument( source ), 1.4f );
addArgIf( arguments, verbose, "-verbose" );
addArgIfNotEmpty( arguments, "-additionalparam", quotedArgument( additionalparam ) );
addArgIfNotEmpty( arguments, "-sourcePath", quotedPathArgument( sourcePath.toString() ) );
// javadoc arguments for default doclet
if ( StringUtils.isEmpty( doclet ) )
{
bottom = StringUtils.replace( bottom, "{currentYear}", year );
if ( project.getInceptionYear() != null )
{
bottom = StringUtils.replace( bottom, "{inceptionYear}", project.getInceptionYear() );
}
else
{
bottom = StringUtils.replace( bottom, "{inceptionYear}-", "" );
}
cmd.createArgument().setValue( "@files" );
if ( StringUtils.isEmpty( stylesheetfile ) )
{
stylesheetfile = javadocDirectory + File.separator + DEFAULT_CSS_NAME;
}
// End Specify default values
getLog().info( Commandline.toString( cmd.getCommandline() ) );
addArgIf( arguments, author, "-author" );
addArgIfNotEmpty( arguments, "-bottom", quotedArgument( bottom ) );
addArgIf( arguments, breakiterator, "-breakiterator", 1.4f );
addArgIfNotEmpty( arguments, "-charset", quotedArgument( charset ) );
addArgIfNotEmpty( arguments, "-d", quotedPathArgument( javadocDirectory.toString() ) );
addArgIf( arguments, docfilessubdirs, "-docfilessubdirs", 1.4f );
addArgIfNotEmpty( arguments, "-docencoding", quotedArgument( docencoding ) );
addArgIfNotEmpty( arguments, "-doctitle", quotedArgument( doctitle ) );
addArgIfNotEmpty( arguments, "-excludedocfilessubdir", quotedPathArgument( excludedocfilessubdir ), 1.4f );
addArgIfNotEmpty( arguments, "-footer", quotedArgument( footer ) );
addArgIfNotEmpty( arguments, "-group", quotedArgument( group ), true );
addArgIfNotEmpty( arguments, "-header", quotedArgument( header ) );
addArgIfNotEmpty( arguments, "-helpfile", quotedPathArgument( helpfile ) );
addArgIfNotEmpty( arguments, "-link", quotedPathArgument( link ), true );
addArgIfNotEmpty( arguments, "-linkoffline", quotedPathArgument( linkoffline ), true );
addArgIf( arguments, linksource, "-linksource", 1.4f );
addArgIf( arguments, nodeprecated, "-nodeprecated" );
addArgIf( arguments, nodeprecatedlist, "-nodeprecatedlist" );
addArgIf( arguments, nocomment, "-nocomment", 1.4f );
addArgIf( arguments, nohelp, "-nohelp" );
addArgIf( arguments, noindex, "-noindex" );
addArgIf( arguments, nonavbar, "-nonavbar" );
addArgIfNotEmpty( arguments, "-noqualifier", quotedArgument( noqualifier ), 1.4f );
addArgIf( arguments, nosince, "-nosince" );
addArgIf( arguments, notree, "-notree" );
addArgIf( arguments, serialwarn, "-serialwarn" );
addArgIf( arguments, splitindex, "-splitindex" );
addArgIfNotEmpty( arguments, "-stylesheetfile", quotedPathArgument( stylesheetfile ) );
addArgIfNotEmpty( arguments, "-tag", quotedArgument( tag ), 1.4f, true );
addArgIfNotEmpty( arguments, "-taglet", quotedArgument( taglet ), 1.4f );
addArgIfNotEmpty( arguments, "-tagletpath", quotedPathArgument( tagletpath ), 1.4f );
addArgIf( arguments, use, "-use" );
addArgIf( arguments, version, "-version" );
addArgIfNotEmpty( arguments, "-windowtitle", quotedArgument( windowtitle ) );
}
int exitCode = CommandLineUtils.executeCommandLine( cmd, new DefaultConsumer(), new DefaultConsumer() );
if ( options.length() > 0 )
{
File optionsFile = new File( javadocDirectory, "options" );
for ( Iterator it = arguments.iterator(); it.hasNext(); )
{
options.append( " " );
options.append( (String) it.next() );
}
try
{
FileUtils.fileWrite( optionsFile.getAbsolutePath(), options.toString() );
}
catch ( IOException e )
{
throw new MavenReportException( "Unable to write temporary file for command execution", e );
}
cmd.createArgument().setValue( "@options" );
optionsFile.deleteOnExit();
}
cmd.createArgument().setValue( "@files" );
getLog().info( Commandline.toString( cmd.getCommandline() ) );
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
try
{
int exitCode = CommandLineUtils.executeCommandLine( cmd, new DefaultConsumer(), err );
if ( exitCode != 0 )
{
throw new MavenReportException( "Exit code: " + exitCode );
throw new MavenReportException( "Exit code: " + exitCode + " - " + err.getOutput() );
}
}
catch ( Exception e )
catch ( CommandLineException e )
{
getLog().debug( e );
throw new MavenReportException( "An error has occurred in javadoc report generation.", e );
throw new MavenReportException( "Unable to execute javadoc command", e );
}
}
@ -1034,10 +1061,8 @@ public class JavadocReport
* @param resource the resource
* @return InputStream An input stream for reading the resource, or <tt>null</tt>
* if the resource could not be found
* @throws Exception if any
*/
private static InputStream getStream( String resource )
throws Exception
{
return JavadocReport.class.getClassLoader().getResourceAsStream( resource );
}
@ -1047,14 +1072,14 @@ public class JavadocReport
* loader to the output directory.
*
* @param outputDirectory the output directory
* @throws Exception if any
* @throws IOException if any
* @see #DEFAULT_CSS_NAME
*/
private void copyDefaultStylesheet( File outputDirectory )
throws Exception
throws IOException
{
if ( ( outputDirectory == null ) || ( !outputDirectory.exists() ) )
if ( outputDirectory == null || !outputDirectory.exists() )
{
throw new IOException( "The outputDirectory " + outputDirectory + " doesn't exists." );
}
@ -1084,6 +1109,6 @@ public class JavadocReport
public boolean isExternalReport()
{
return true;
return true && super.isExternalReport();
}
}

View File

@ -22,7 +22,6 @@ import org.apache.maven.model.Notifier;
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.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.StringUtils;
@ -107,7 +106,6 @@ public class CimReport
}
public void executeReport( Locale locale )
throws MavenReportException
{
CimRenderer r = new CimRenderer( getSink(), getProject().getModel(), locale );

View File

@ -24,7 +24,6 @@ import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
@ -151,7 +150,6 @@ public class DependenciesReport
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject(), locale, mavenProjectBuilder,
artifactFactory, localRepository );

View File

@ -21,7 +21,6 @@ import org.apache.maven.model.Model;
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.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.StringUtils;
@ -117,7 +116,6 @@ public class IssueTrackingReport
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
IssueTrackingRenderer r = new IssueTrackingRenderer( getSink(), getProject().getModel(), locale );

View File

@ -21,7 +21,6 @@ import org.apache.maven.model.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.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.IOUtil;
@ -128,7 +127,6 @@ public class LicenseReport
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
LicenseRenderer r = new LicenseRenderer( getSink(), getProject(), locale );

View File

@ -21,7 +21,6 @@ import org.apache.maven.model.Model;
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.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.StringUtils;
@ -119,7 +118,6 @@ public class MailingListsReport
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
MailingListsRenderer r = new MailingListsRenderer( getSink(), getProject().getModel(), locale );

View File

@ -21,7 +21,6 @@ import org.apache.maven.model.Scm;
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.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository;
@ -135,7 +134,6 @@ public class ScmReport
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
ScmRenderer r = new ScmRenderer( scmManager, getSink(), getProject().getModel(), locale );

View File

@ -22,7 +22,6 @@ import org.apache.maven.model.Model;
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.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.StringUtils;
@ -121,7 +120,6 @@ public class TeamListReport
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
TeamListRenderer r = new TeamListRenderer( getSink(), getProject().getModel(), locale );

View File

@ -18,6 +18,7 @@ package org.apache.maven.plugins.site;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.reporting.MavenReportException;
@ -44,6 +45,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -51,7 +53,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Comparator;
/**
* Generates the project site.
@ -150,7 +151,7 @@ public class SiteMojo
/**
* Internationalization.
*
* @component
* @component
*/
private I18N i18n;
@ -178,7 +179,7 @@ public class SiteMojo
* @see org.apache.maven.plugin.Mojo#execute()
*/
public void execute()
throws MojoExecutionException
throws MojoExecutionException, MojoFailureException
{
if ( templateDirectory == null )
{
@ -289,11 +290,7 @@ public class SiteMojo
}
// Exception if a file is duplicate
String msg = createDuplicateExceptionMsg( duplicate, locale );
if ( msg != null )
{
throw new MavenReportException( msg );
}
checkDuplicates( duplicate, locale );
String siteDescriptor = getSiteDescriptor( reports, locale, projectInfos, projectReports );
@ -1132,13 +1129,13 @@ public class SiteMojo
}
/**
* Create an <code>Exception</code> message if a file is duplicate.
* Throw an exception if a file is duplicate.
*
* @param duplicate a map of duplicate files
* @param locale the current locale
* @return the Message to throw
*/
private String createDuplicateExceptionMsg( Map duplicate, Locale locale )
private void checkDuplicates( Map duplicate, Locale locale )
throws MojoFailureException
{
if ( duplicate.size() > 0 )
{
@ -1182,11 +1179,9 @@ public class SiteMojo
if ( sb != null )
{
return sb.toString();
throw new MojoFailureException( sb.toString() );
}
}
return null;
}
/**