diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index 08d9e958..9c2f9acb 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -203,6 +203,14 @@ public abstract class AbstractJavadocMojo */ protected static final String FILES_FILE_NAME = "files"; + /** + * The errors file name in the output directory containing the errors and warnings returned by + * javadoc.exe(or .sh). + *
+ * This won't exist if javadoc.exe(or .sh) didn't return any warnings or errors. + */ + protected static final String ERRORS_FILE_NAME = "errors"; + /** * Default css file name, used as file name in the output directory for the temporary custom stylesheet file * loaded from classloader resources. @@ -5848,6 +5856,11 @@ && isJavadocVMInitError( output ) ) getLog().info( output ); } + if ( StringUtils.isNotEmpty( err.getOutput() ) ) + { + writeErrorFile( err.getOutput(), javadocOutputDirectory ); + } + StringBuilder msg = new StringBuilder( "\nExit code: " ); msg.append( exitCode ); if ( StringUtils.isNotEmpty( err.getOutput() ) ) @@ -6702,6 +6715,28 @@ private void writeDebugJavadocScript( String cmdLine, File javadocOutputDirector } } + /** + * Write a files containing the javadoc errors and warnings. + * + * @param errorsAndWarnings the javadoc errors and warnings as string, not null. + * @param javadocOutputDirectory the output dir, not null. + * @since 3.4.2-SNAPSHOT + */ + private void writeErrorFile( String errorsAndWarnings, File javadocOutputDirectory ) + { + File commandLineFile = new File( javadocOutputDirectory, ERRORS_FILE_NAME ); + commandLineFile.getParentFile().mkdirs(); + + try + { + FileUtils.fileWrite( commandLineFile.getAbsolutePath(), null /* platform encoding */, errorsAndWarnings ); + } + catch ( IOException e ) + { + logError( "Unable to write '" + commandLineFile.getName() + "' errors file", e ); + } + } + /** * Check if the Javadoc JVM is correctly started or not. * diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocJar.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocJar.java index 73cdf745..680be32d 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocJar.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocJar.java @@ -67,10 +67,11 @@ public class JavadocJar * @see AbstractJavadocMojo#PACKAGES_FILE_NAME * @see AbstractJavadocMojo#ARGFILE_FILE_NAME * @see AbstractJavadocMojo#FILES_FILE_NAME + * @see AbstractJavadocMojo#ERRORS_FILE_NAME */ private static final String[] DEFAULT_EXCLUDES = new String[]{ DEBUG_JAVADOC_SCRIPT_NAME, OPTIONS_FILE_NAME, PACKAGES_FILE_NAME, ARGFILE_FILE_NAME, - FILES_FILE_NAME }; + FILES_FILE_NAME, ERRORS_FILE_NAME }; // ---------------------------------------------------------------------- // Mojo components diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java index eb46b6c2..d3cb9f28 100644 --- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java +++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java @@ -42,7 +42,7 @@ public class JavadocJarTest extends AbstractMojoTestCase { - + private JavadocJar lookupMojo( File testPom ) throws Exception { @@ -51,13 +51,13 @@ private JavadocJar lookupMojo( File testPom ) MojoExecution mojoExec = new MojoExecution( new Plugin(), "javadoc", null ); setVariableValueToObject( mojo, "mojo", mojoExec ); - + MavenProject currentProject = new MavenProjectStub(); currentProject.setGroupId( "GROUPID" ); currentProject.setArtifactId( "ARTIFACTID" ); - + setVariableValueToObject( mojo, "session", newMavenSession( currentProject ) ); - + return mojo; } @@ -126,6 +126,7 @@ else if ( javadocVersion.isBefore( "1.8" ) ) assertFalse( set.contains( AbstractJavadocMojo.FILES_FILE_NAME ) ); assertFalse( set.contains( AbstractJavadocMojo.OPTIONS_FILE_NAME ) ); assertFalse( set.contains( AbstractJavadocMojo.PACKAGES_FILE_NAME ) ); + assertFalse( set.contains( AbstractJavadocMojo.ERRORS_FILE_NAME ) ); //check if the javadoc files were created generatedFile =