Skip to content

Commit f1febac

Browse files
committed
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.
1 parent 18744d5 commit f1febac

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

grails-doc/build.gradle

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,36 @@ combinedGroovydoc.configure { Groovydoc gdoc ->
8282
possibleSources
8383
}
8484
.flatten()
85-
gdoc.source(sources.collect { SourceSet it -> [it.allSource.srcDirs, it.allSource.srcDirs] }.flatten().findAll { File srcDir ->
86-
if (!(srcDir.name in ['java', 'groovy'])) {
87-
return false
88-
}
8985

90-
srcDir.exists()
91-
}.unique())
86+
List<File> baseSourceDirs = sources
87+
.collect { SourceSet it -> it.allSource.srcDirs }
88+
.flatten()
89+
.findAll { File srcDir ->
90+
if (!(srcDir.name in ['java', 'groovy'])) {
91+
return false
92+
}
93+
srcDir.exists()
94+
}
95+
96+
// Collect source directories from included builds (composite builds)
97+
// Gradle will not provide the included build projects or source sets, so we inspect the file system
98+
List<File> includedBuildSourceDirs = gradle.includedBuilds
99+
.collectMany { includedBuild ->
100+
def sourceDirs = []
101+
includedBuild.projectDir.eachDirRecurse { File dir ->
102+
['src/main/java', 'src/main/groovy'].each { rel ->
103+
File sourceDir = new File(dir, rel)
104+
if (sourceDir.isDirectory()) {
105+
sourceDirs << sourceDir
106+
}
107+
}
108+
}
109+
sourceDirs
110+
}
111+
112+
gdoc.source(project.files((baseSourceDirs + includedBuildSourceDirs).unique()))
113+
// Exclude files that are not part of the public API and cause duplicate class errors when combined with other source sets
114+
gdoc.exclude('org/grails/example/**', 'org.grails.example/**', 'another/**', 'TestJava**')
92115

93116
gdoc.classpath = files(sources.collect { SourceSet it -> it.compileClasspath.filter(File.&isDirectory) }.flatten().unique())
94117
gdoc.destinationDir = project.layout.buildDirectory.dir('combined-api/api').get().asFile

0 commit comments

Comments
 (0)