jdaugherty commented on code in PR #15012:
URL: https://github.com/apache/grails-core/pull/15012#discussion_r2300914076
##########
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 ->
Review Comment:
Won't this recurse into every descendant directory while you only need 2 of
these? Seems like we should optimize this so it doesn't slow down the build.
##########
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:
These packages look like test packages, but tests should not be in the
groovydoc. Do you have an example of which file was causing this problem?
This doesn't seem right to me.
--
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]