Skip to content

Commit

Permalink
[MJAVADOC] Improve split package issue with Manifest base modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfscholte committed Feb 16, 2019
1 parent f09e0c8 commit 5250cba
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@
<artifactId>maven-plugin-api</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

/**
* This is also a comment.
*/
@Mojo(name = "my-mojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class TestcaseMojo extends AbstractMojo
{

@Parameter( defaultValue="${project}", readonly=true, required = true )
private MavenProject project;

public Testcase createTestcase()
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4949,6 +4949,8 @@ private void addJavadocOptions( File javadocOutputDirectory,

ResolvePathResult mainResolvePathResult = null;

Map<String, Collection<Path>> patchModules = new HashMap<>();

Path moduleSourceDir = null;
if ( supportModulePath && !allModuleDescriptors.isEmpty() )
{
Expand Down Expand Up @@ -5008,9 +5010,7 @@ private void addJavadocOptions( File javadocOutputDirectory,

additionalModules.add( result.getModuleDescriptor().name() );

addArgIfNotEmpty( arguments, "--patch-module", result.getModuleDescriptor().name() + '='
+ JavadocUtil.quotedPathArgument( getSourcePath( projectSourcepaths.getValue() ) ),
false, false );
patchModules.put( result.getModuleDescriptor().name(), projectSourcepaths.getValue() );

Path modulePath = moduleSourceDir.resolve( result.getModuleDescriptor().name() );
if ( !Files.isDirectory( modulePath ) )
Expand Down Expand Up @@ -5072,11 +5072,21 @@ private void addJavadocOptions( File javadocOutputDirectory,
}
}

final ModuleNameSource mainModuleNameSource;
if ( mainResolvePathResult != null )
{
mainModuleNameSource = mainResolvePathResult.getModuleNameSource();
}
else
{
mainModuleNameSource = null;
}

if ( supportModulePath
&& ( isAggregator() || ( mainResolvePathResult != null
&& ( ModuleNameSource.MODULEDESCRIPTOR.equals( mainResolvePathResult.getModuleNameSource() )
|| ModuleNameSource.MANIFEST.equals( mainResolvePathResult.getModuleNameSource() ) ) ) )
&& !isTest() )
&& !isTest()
&& ( isAggregator()
|| ModuleNameSource.MODULEDESCRIPTOR.equals( mainModuleNameSource )
|| ModuleNameSource.MANIFEST.equals( mainModuleNameSource ) ) )
{
List<File> pathElements = new ArrayList<>( getPathElements() );
File artifactFile = getArtifactFile( project );
Expand All @@ -5088,9 +5098,11 @@ private void addJavadocOptions( File javadocOutputDirectory,
ResolvePathsRequest<File> request =
ResolvePathsRequest.ofFiles( pathElements );

String mainModuleName = null;
if ( mainResolvePathResult != null )
{
request.setModuleDescriptor( mainResolvePathResult.getModuleDescriptor() );
mainModuleName = mainResolvePathResult.getModuleDescriptor().name();
}

request.setAdditionalModules( additionalModules );
Expand All @@ -5101,26 +5113,34 @@ private void addJavadocOptions( File javadocOutputDirectory,

Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() ) ;

Set<File> directDependencyArtifactFiles = new HashSet<>( project.getDependencyArtifacts().size() );
for ( Artifact depArt : project.getDependencyArtifacts() )
{
directDependencyArtifactFiles.add( depArt.getFile() );
}

Collection<File> classPathElements = new ArrayList<>( result.getClasspathElements().size() );

for ( File file : result.getClasspathElements() )
{
if ( directDependencyArtifactFiles.contains( file )
|| ( file.isDirectory() && new File( file, "module-info.class" ).exists() ) )
if ( file.isDirectory() && new File( file, "module-info.class" ).exists() )
{
modulePathElements.add( file );
}
else if ( ModuleNameSource.MANIFEST.equals( mainModuleNameSource ) )
{
ModuleNameSource depModuleNameSource =
locationManager.resolvePath( ResolvePathRequest.ofFile( file ) ).getModuleNameSource();
if ( ModuleNameSource.MODULEDESCRIPTOR.equals( depModuleNameSource )
|| ModuleNameSource.MANIFEST.equals( depModuleNameSource ) )
{
modulePathElements.add( file );
}
else
{
patchModules.get( mainModuleName ).add( file.toPath() );
}
}
else
{
classPathElements.add( file );
}
}

String classpath = StringUtils.join( classPathElements.iterator(), File.pathSeparator );
addArgIfNotEmpty( arguments, "--class-path", JavadocUtil.quotedPathArgument( classpath ), false,
false );
Expand All @@ -5145,7 +5165,14 @@ else if ( supportModulePath && moduleDescriptorSource && !isTest() )
String classpath = StringUtils.join( getPathElements().iterator(), File.pathSeparator );
addArgIfNotEmpty( arguments, "-classpath", JavadocUtil.quotedPathArgument( classpath ) , false, false );
}


for ( Entry<String, Collection<Path>> entry : patchModules.entrySet() )
{
addArgIfNotEmpty( arguments, "--patch-module", entry.getKey() + '='
+ JavadocUtil.quotedPathArgument( getSourcePath( entry.getValue() ) ),
false, false );
}

if ( StringUtils.isNotEmpty( doclet ) )
{
addArgIfNotEmpty( arguments, "-doclet", JavadocUtil.quotedArgument( doclet ) );
Expand Down

0 comments on commit 5250cba

Please sign in to comment.