Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

[MJAVADOC-489] Find the main module descriptor #137

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4653,9 +4653,11 @@ private void addJavadocOptions( List<String> arguments, List<String> sourcePaths
addArgIf( arguments, breakiterator, "-breakiterator", SINCE_JAVADOC_1_5 );
}

File mainDescriptor = new File( "src/main/java/module-info.java" );

if ( mainDescriptor.exists() && !isTest() )
List<String> roots = getProjectSourceRoots( getProject() );

File mainDescriptor = findMainDescriptor( roots );

if ( mainDescriptor != null && !isTest() )
{
LocationManager locationManager = new LocationManager();
ResolvePathsRequest<File> request =
Expand Down Expand Up @@ -4739,6 +4741,24 @@ private void addJavadocOptions( List<String> arguments, List<String> sourcePaths
}
}

private static File findMainDescriptor( List<String> roots )
throws MavenReportException
{
for ( String root : roots )
{
File descriptorFile = new File( root, "module-info.java" ).getAbsoluteFile();
if ( descriptorFile.exists() )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't be better isFile() instead of exists() ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I'll update shortly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm kind of inclined to fail hard and fast if something exists called module-info.java that isn't a regular file. That almost certainly indicates some sort of problem in the build elsewhere.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally makes sense +1

{
if ( !descriptorFile.isFile() )
{
throw new MavenReportException( descriptorFile + " is not a regular file" );
}
return descriptorFile;
}
}
return null;
}

/**
* Add Standard Doclet Options.
* <br/>
Expand Down