jamesfredley commented on code in PR #15420:
URL: https://github.com/apache/grails-core/pull/15420#discussion_r2833830338
##########
gradle/docs-dependencies.gradle:
##########
@@ -52,52 +44,30 @@ String resolveProjectVersion(String artifact) {
tasks.withType(Groovydoc).configureEach { Groovydoc gdoc ->
gdoc.exclude('META-INF/**', '*yml', '*properties', '*xml',
'**/Application.groovy', '**/Bootstrap.groovy', '**/resources.groovy')
- gdoc.groovyClasspath = configurations.documentation
gdoc.windowTitle = "${project.findProperty('pomArtifactId') ?:
project.name} - $projectVersion"
gdoc.docTitle = "${project.findProperty('pomArtifactId') ?: project.name}
- $projectVersion"
- gdoc.access = GroovydocAccess.PROTECTED
- gdoc.includeAuthor = false
- gdoc.includeMainForScripts = false
- gdoc.processScripts = false
- gdoc.noTimestamp = true
- gdoc.noVersionStamp = false
- gdoc.footer = '''<!-- Matomo -->
-<script>
- var _paq = window._paq = window._paq || [];
- /* tracker methods like "setCustomDimension" should be called before
"trackPageView" */
- _paq.push(["setDoNotTrack", true]);
- _paq.push(["disableCookies"]);
- _paq.push(['trackPageView']);
- _paq.push(['enableLinkTracking']);
- (function() {
- var u="https://analytics.apache.org/";
- _paq.push(['setTrackerUrl', u+'matomo.php']);
- _paq.push(['setSiteId', '79']);
- var d=document, g=d.createElement('script'),
s=d.getElementsByTagName('script')[0];
- g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
- })();
-</script>
-<!-- End Matomo Code -->'''
- doFirst {
+ gdoc.doFirst {
+ List<Map<String, String>> links = []
def gebVersion = resolveProjectVersion('geb-spock')
- if(gebVersion) {
-
gdoc.link("https://groovy.apache.org/geb/manual/${gebVersion}/api/", 'geb.')
+ if (gebVersion) {
+ links << [packages: 'geb.', href:
"https://groovy.apache.org/geb/manual/${gebVersion}/api/"]
}
Review Comment:
Good catch - this is correct. This was a pre-existing bug on 7.0.x (not
introduced by this PR). The function had an early `return null` for the
not-found case but was missing the implicit return of `version` as the last
expression. In Groovy, the `if` statement evaluates to `null` when the
condition is false and there is no `else`, so the function always returned null.
Fixed in bf365318bb by adding `version` as the last expression in the
function. External groovydoc links (geb, testcontainers, spring, spring-boot)
should now be included correctly.
##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsGroovydocPlugin.groovy:
##########
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.grails.buildsrc
+
+import groovy.transform.CompileDynamic
+import groovy.transform.CompileStatic
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.attributes.Bundling
+import org.gradle.api.attributes.Category
+import org.gradle.api.attributes.Usage
+import org.gradle.api.provider.Provider
+import org.gradle.api.tasks.SourceSet
+import org.gradle.api.tasks.SourceSetContainer
+import org.gradle.api.tasks.javadoc.Groovydoc
+
+@CompileStatic
+class GrailsGroovydocPlugin implements Plugin<Project> {
Review Comment:
Addressed in bf365318bb. The plugin is now split into two layers:
1. **`GroovydocEnhancerPlugin`**
(`org.apache.grails.buildsrc.groovydoc-enhancer`) - Generic base plugin with
all the AntBuilder logic, source resolution, link support, and `documentation`
configuration. No Grails-specific code. Publishable and reusable by anyone.
2. **`GrailsGroovydocPlugin`** (`org.apache.grails.buildsrc.groovydoc`) -
Thin layer that applies the base plugin and sets `footer` to the Matomo
analytics snippet. This is the only Grails-specific piece.
The base extension also includes a `useAntBuilder` flag (default `true`).
When Gradle merges their `javaVersion` support (gradle/gradle#33659), setting
`groovydocEnhancer { useAntBuilder = false }` will skip the AntBuilder action
replacement and let Gradle's built-in task run - no code changes needed to
switch back.
--
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]