jamesfredley commented on code in PR #15012:
URL: https://github.com/apache/grails-core/pull/15012#discussion_r2301355757


##########
grails-doc/build.gradle:
##########
@@ -82,13 +82,36 @@ combinedGroovydoc.configure { Groovydoc gdoc ->
                 possibleSources
             }
             .flatten()
-    gdoc.source(sources.collect { SourceSet it -> [it.allSource.srcDirs, 
it.allSource.srcDirs] }.flatten().findAll { File srcDir ->
-        if (!(srcDir.name in ['java', 'groovy'])) {
-            return false
-        }
 
-        srcDir.exists()
-    }.unique())
+    List<File> baseSourceDirs = sources
+            .collect { SourceSet it -> it.allSource.srcDirs }
+            .flatten()
+            .findAll { File srcDir ->
+                if (!(srcDir.name in ['java', 'groovy'])) {
+                    return false
+                }
+                srcDir.exists()
+            }
+
+    // Collect source directories from included builds (composite builds)
+    // Gradle will not provide the included build projects or source sets, so 
we inspect the file system
+    List<File> includedBuildSourceDirs = gradle.includedBuilds
+            .collectMany { includedBuild ->
+                def sourceDirs = []
+                includedBuild.projectDir.eachDirRecurse { File dir ->
+                    ['src/main/java', 'src/main/groovy'].each { rel ->
+                        File sourceDir = new File(dir, rel)
+                        if (sourceDir.isDirectory()) {
+                            sourceDirs << sourceDir
+                        }
+                    }
+                }
+                sourceDirs
+            }
+
+    gdoc.source(project.files((baseSourceDirs + 
includedBuildSourceDirs).unique()))
+    // Exclude files that are not part of the public API and cause duplicate 
class errors when combined with other source sets
+    gdoc.exclude('org/grails/example/**', 'org.grails.example/**', 
'another/**', 'TestJava**')

Review Comment:
   This was resolved by going from eachDirRecurse to .eachDir.  That's where 
the pollution was coming from.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to