This is an automated email from the ASF dual-hosted git repository.

jamesfredley pushed a commit to branch include-grails-gradle-groovydocs
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit f1febacd2839240b477f8605f9068201b7d20b60
Author: James Fredley <[email protected]>
AuthorDate: Mon Aug 25 12:53:19 2025 -0400

    Include sources from composite builds in Groovydoc
    
    Updated the Groovydoc configuration to collect source directories from 
included (composite) builds by inspecting the file system. This ensures 
documentation generation includes sources from all relevant projects, and adds 
exclusions to prevent duplicate class errors.
---
 grails-doc/build.gradle | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/grails-doc/build.gradle b/grails-doc/build.gradle
index 32b86776a3..cafd9edca8 100644
--- a/grails-doc/build.gradle
+++ b/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**')
 
     gdoc.classpath = files(sources.collect { SourceSet it -> 
it.compileClasspath.filter(File.&isDirectory) }.flatten().unique())
     gdoc.destinationDir = 
project.layout.buildDirectory.dir('combined-api/api').get().asFile

Reply via email to