You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2019/10/28 04:54:34 UTC
[maven-javadoc-plugin] branch MJAVADOC-612 updated: more fix for
java11 and empty classpath
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch MJAVADOC-612
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
The following commit(s) were added to refs/heads/MJAVADOC-612 by this push:
new 76d7d5a more fix for java11 and empty classpath
76d7d5a is described below
commit 76d7d5a1006316a25cc8700f3546bc13d3247c6a
Author: olivier lamy <ol...@apache.org>
AuthorDate: Mon Oct 28 14:54:11 2019 +1000
more fix for java11 and empty classpath
Signed-off-by: olivier lamy <ol...@apache.org>
---
.../projects/MJAVADOC-526_aggr-managedDeps/pom.xml | 11 ++--
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 61 ++++++++++++++++------
2 files changed, 53 insertions(+), 19 deletions(-)
diff --git a/src/it/projects/MJAVADOC-526_aggr-managedDeps/pom.xml b/src/it/projects/MJAVADOC-526_aggr-managedDeps/pom.xml
index e44f89f..8f5e3e8 100644
--- a/src/it/projects/MJAVADOC-526_aggr-managedDeps/pom.xml
+++ b/src/it/projects/MJAVADOC-526_aggr-managedDeps/pom.xml
@@ -27,16 +27,19 @@
<artifactId>javadoc-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
-
+
<url>https://issues.apache.org/jira/browse/MJAVADOC-526</url>
-
+
<build>
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
+ <configuration>
+ <debug>true</debug>
+ </configuration>
</plugin>
</plugins>
</pluginManagement>
@@ -45,4 +48,4 @@
<modules>
<module>javadoc-child</module>
</modules>
-</project>
\ No newline at end of file
+</project>
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 ccfa791..8122dc4 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -5207,10 +5207,22 @@ public abstract class AbstractJavadocMojo
}
}
- String classpath = StringUtils.join( classPathElements.iterator(), File.pathSeparator );
- addArgIfNotEmpty( arguments, "--class-path", JavadocUtil.quotedPathArgument( classpath ), false,
- false );
-
+ if ( !classPathElements.isEmpty() )
+ {
+ String classpath = StringUtils.join( classPathElements.iterator(), File.pathSeparator );
+ addArgIfNotEmpty( arguments, "--class-path", JavadocUtil.quotedPathArgument( classpath )
+ , false,
+ false );
+ }
+ else if ( !result.getPathExceptions().isEmpty() )
+ {
+ String classpath = StringUtils.join( result.getPathExceptions().keySet().iterator(),
+ File.pathSeparator );
+ addArgIfNotEmpty( arguments, "--class-path",
+ JavadocUtil.quotedPathArgument( classpath ),
+ false,
+ false );
+ }
String modulepath =
StringUtils.join( modulePathElements.iterator(), File.pathSeparator );
addArgIfNotEmpty( arguments, "--module-path", JavadocUtil.quotedPathArgument( modulepath ), false,
@@ -5747,17 +5759,17 @@ public abstract class AbstractJavadocMojo
}
String cmdLine = null;
- if ( debug )
- {
- cmdLine = CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" );
-
- writeDebugJavadocScript( cmdLine, javadocOutputDirectory );
- }
CommandLineUtils.StringStreamConsumer err = new JavadocUtil.JavadocOutputStreamConsumer();
CommandLineUtils.StringStreamConsumer out = new JavadocUtil.JavadocOutputStreamConsumer();
try
{
+
+ if ( debug )
+ {
+ writeDebugJavadocScript( cmd, javadocOutputDirectory );
+ }
+
int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err );
String output = ( StringUtils.isEmpty( out.getOutput() ) ? null : '\n' + out.getOutput().trim() );
@@ -5768,7 +5780,7 @@ public abstract class AbstractJavadocMojo
{
cmdLine = CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" );
}
- writeDebugJavadocScript( cmdLine, javadocOutputDirectory );
+ writeDebugJavadocScript( cmd, javadocOutputDirectory );
if ( StringUtils.isNotEmpty( output ) && StringUtils.isEmpty( err.getOutput() )
&& isJavadocVMInitError( output ) )
@@ -6508,26 +6520,45 @@ public abstract class AbstractJavadocMojo
/**
* Write a debug javadoc script in case of command line error or in debug mode.
*
- * @param cmdLine the current command line as string, not null.
+ * @param commandline the current command line not null.
* @param javadocOutputDirectory the output dir, not null.
* @see #executeJavadocCommandLine(Commandline, File)
* @since 2.6
*/
- private void writeDebugJavadocScript( String cmdLine, File javadocOutputDirectory )
+ private void writeDebugJavadocScript( Commandline commandline, File javadocOutputDirectory )
{
File commandLineFile = new File( javadocOutputDirectory, DEBUG_JAVADOC_SCRIPT_NAME );
commandLineFile.getParentFile().mkdirs();
try
{
- FileUtils.fileWrite( commandLineFile.getAbsolutePath(), null /* platform encoding */, cmdLine );
+
+ StringBuilder cmdLine = new StringBuilder();
+
+ if ( !SystemUtils.IS_OS_WINDOWS )
+ {
+ cmdLine.append( "cd " )
+ .append( commandline.getWorkingDirectory().getAbsolutePath() )
+ .append( SystemUtils.LINE_SEPARATOR );
+ }
+
+ for ( String envVar : commandline.getEnvironmentVariables() )
+ {
+ cmdLine.append( envVar )
+ .append( SystemUtils.LINE_SEPARATOR );
+ }
+ cmdLine.append( CommandLineUtils.toString( commandline.getCommandline() )
+ .replaceAll( "'", "" ) )
+ .append( SystemUtils.LINE_SEPARATOR );
+
+ FileUtils.fileWrite( commandLineFile.getAbsolutePath(), null /* platform encoding */, cmdLine.toString() );
if ( !SystemUtils.IS_OS_WINDOWS )
{
Runtime.getRuntime().exec( new String[]{ "chmod", "a+x", commandLineFile.getAbsolutePath() } );
}
}
- catch ( IOException e )
+ catch ( IOException | CommandLineException e )
{
logError( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
}