Skip to content

Commit

Permalink
Fix Javadoc generation for modular projects
Browse files Browse the repository at this point in the history
Closes #58
  • Loading branch information
mizdebsk committed Jul 1, 2021
1 parent 8cd0810 commit 53d03fd
Showing 1 changed file with 13 additions and 13 deletions.
Expand Up @@ -198,6 +198,18 @@ private List<Path> getClasspath()
public void execute()
throws MojoExecutionException, MojoFailureException
{
Path javadocExecutable;
if ( System.getenv().containsKey( "JAVA_HOME" ) )
{
javadocExecutable = Paths.get( System.getenv( "JAVA_HOME" ) ) //
.resolve( "bin" ) //
.resolve( "javadoc" );
}
else
{
javadocExecutable = Paths.get( "/usr/bin/javadoc" );
}

try
{
if ( StringUtils.isEmpty( encoding ) )
Expand Down Expand Up @@ -242,7 +254,7 @@ public void execute()
opts.add( "-version" );
opts.add( "-Xdoclint:none" );

opts.add( "-classpath" );
opts.add( isJavadocModular( javadocExecutable ) ? "--module-path" : "-classpath" );
opts.add( quoted( StringUtils.join( getClasspath().iterator(), ":" ) ) );
opts.add( "-encoding" );
opts.add( quoted( encoding ) );
Expand All @@ -267,18 +279,6 @@ public void execute()

Files.write( outputDir.resolve( "args" ), opts, StandardOpenOption.CREATE );

Path javadocExecutable;
if ( System.getenv().containsKey( "JAVA_HOME" ) )
{
javadocExecutable = Paths.get( System.getenv( "JAVA_HOME" ) ) //
.resolve( "bin" ) //
.resolve( "javadoc" );
}
else
{
javadocExecutable = Paths.get( "/usr/bin/javadoc" );
}

ProcessBuilder pb = new ProcessBuilder( javadocExecutable.toRealPath().toString(), "@args" );
pb.directory( outputDir.toFile() );
pb.redirectInput( new File( "/dev/null" ) );
Expand Down

0 comments on commit 53d03fd

Please sign in to comment.