@@ -2022,7 +2022,7 @@ protected void executeReport(Locale unusedLocale) throws MavenReportException {
20222022 getLog ().warn ("sourceFileIncludes and sourceFileExcludes have no effect when subpackages are specified!" );
20232023 includesExcludesActive = false ;
20242024 }
2025- if (!packageNames .isEmpty () && !includesExcludesActive ) {
2025+ if (!packageNames .isEmpty () && !includesExcludesActive && ! legacyMode ) {
20262026 addCommandLinePackages (cmd , javadocOutputDirectory , packageNames );
20272027
20282028 // ----------------------------------------------------------------------
@@ -2093,23 +2093,26 @@ protected Map<Path, Collection<String>> getFiles(Collection<Path> sourcePaths) t
20932093 if (subpackages == null || subpackages .isEmpty ()) {
20942094 Collection <String > excludedPackages = getExcludedPackages ();
20952095
2096- final boolean autoExclude ;
2097- if (release != null ) {
2098- autoExclude = JavaVersion .parse (release ).isBefore ("9" );
2099- } else if (source != null ) {
2100- autoExclude = JavaVersion .parse (source ).isBefore ("9" );
2101- } else {
2102- // if legacy mode is active, treat it like pre-Java 9 (exclude module-info),
2103- // otherwise don't auto-exclude anything.
2104- autoExclude = legacyMode ;
2096+ // if legacy mode is active, treat it like pre-Java 9 (exclude module-info),
2097+ // otherwise don't auto-exclude anything. Do this regardless of the release
2098+ // or source values specified
2099+ boolean autoExclude = legacyMode ;
2100+ if (!autoExclude ) {
2101+ if (release != null ) {
2102+ autoExclude = JavaVersion .parse (release ).isBefore ("9" );
2103+ } else if (source != null ) {
2104+ autoExclude = JavaVersion .parse (source ).isBefore ("9" );
2105+ }
21052106 }
21062107
21072108 for (Path sourcePath : sourcePaths ) {
21082109 File sourceDirectory = sourcePath .toFile ();
2109- List <String > files = new ArrayList <>(JavadocUtil .getFilesFromSource (
2110+ ArrayList <String > files = new ArrayList <>(JavadocUtil .getFilesFromSource (
21102111 sourceDirectory , sourceFileIncludes , sourceFileExcludes , excludedPackages ));
21112112
2112- if (autoExclude && files .remove ("module-info.java" )) {
2113+ // in the aggregate goal (and theoretically in others too), there can be
2114+ // more then one module-info.java. Filter out all of them.
2115+ if (autoExclude && files .removeIf (s -> s .endsWith ("module-info.java" ))) {
21132116 getLog ().debug ("Auto exclude module-info.java due to source value" );
21142117 }
21152118 mappedFiles .put (sourcePath , files );
@@ -4603,7 +4606,7 @@ private void addJavadocOptions(
46034606 }
46044607
46054608 if (moduleSourceDir == null ) {
4606- if (!disableSourcepathUsage ) {
4609+ if (!disableSourcepathUsage && ! legacyMode ) {
46074610 addArgIfNotEmpty (
46084611 arguments ,
46094612 "-sourcepath" ,
0 commit comments