matrei commented on code in PR #14160:
URL: https://github.com/apache/grails-core/pull/14160#discussion_r2048639969


##########
.github/workflows/release.yml:
##########
@@ -543,35 +543,39 @@ jobs:
           RELEASE_SCRIPT_PATH: '.github/scripts/setSnapshotGrailsVersion.sh'
   docs:
     environment: docs
+    name: "Publish Documentation"
     needs: publish
-    runs-on: ubuntu-latest
-    permissions:
-      contents: read # limit to read access
+    runs-on: ubuntu-24.04
     steps:
-      - name: "⚙️ Prepare Input"
-        id: prep_inputs
-        run: |
-          echo "value={\"grails_version\":\"$RELEASE_VERSION\"}" >> 
$GITHUB_OUTPUT
-        env:
-          RELEASE_VERSION: ${{ needs.publish.outputs.release_version }}
-      - name: "📡 Invoke grails-doc release workflow"
-        uses: actions/github-script@v7
+      - name: "📥 Checkout repository"
+        uses: actions/checkout@v4
         with:
-          github-token: ${{ secrets.GH_TOKEN }}
-          script: |
-            try {
-              const result = await github.rest.actions.createWorkflowDispatch({
-                owner: 'apache',
-                repo: 'grails-doc',
-                workflow_id: 'release.yml',
-                ref: '${{ needs.publish.outputs.target_branch }}',
-                inputs: ${{ steps.prep_inputs.outputs.value }}
-              });
-              console.log(result);
-            } catch(error) {
-              console.error(error);
-              core.setFailed(error);
-            }
+          ref: v${{ needs.publish.outputs.release_version }}
+      - name: "☕️ Setup JDK"
+        uses: actions/setup-java@v4
+        with:
+          java-version: 17
+          distribution: liberica
+      - name: "🐘 Setup Gradle"
+        uses: gradle/actions/setup-gradle@v4
+        with:
+          develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
+      - name: "🔀 Get Target Branch name"
+        run: |
+          TARGET_BRANCH="${GITHUB_REF:11}"
+          echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV
+          echo "Target Branch: $TARGET_BRANCH"
+      - name: "📖 Generate Documentation"
+        working-directory: 'grails-doc'
+        run: ../gradlew build -PgithubBranch=${{ env.TARGET_BRANCH }}

Review Comment:
   Skip `working-directory` and do `./gradlew grails-doc:build 
-PgithubBranch=...`?



##########
grails-gradle/plugins/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy:
##########
@@ -137,7 +137,7 @@ class GrailsPublishPluginSpec extends GradleSpecification {
         assertBuildSuccess(result, ["compileJava", "compileGroovy", 
"processResources", "classes", "jar", "groovydoc", "javadoc", "javadocJar", 
"sourcesJar"])
 
         !result.output.contains("Project subproject2 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")
-        result.output.contains("Project subproject1 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")
+        !result.output.contains("Project subproject1 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")

Review Comment:
   Are these assertions still valuable/necessary?



##########
.github/workflows/gradle.yml:
##########
@@ -163,29 +165,44 @@ jobs:
     needs: [skip_check, publish]
     runs-on: ubuntu-latest
     permissions:
-      contents: read # limit to read access
+      contents: write
     steps:
-      - name: "📝 Store the target branch"
-        id: extract_branch
+      - name: "📥 Checkout the repository"
+        uses: actions/checkout@v4
+      - name: "🔀 Store current branch name"
         run: |
-          echo "Determining Target Branch"
-          TARGET_BRANCH=${GITHUB_REF#refs/heads/}
-          echo $TARGET_BRANCH
-          echo "value=${TARGET_BRANCH}" >> $GITHUB_OUTPUT
-      - name: "📡 Invoke the grails-doc release workflow"
-        uses: actions/github-script@v7
+          TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}"
+          echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV
+          echo "Target Branch: ${TARGET_BRANCH}"
+      - name: "📅 Set current date as env variable"
+        run: |
+          NOW=$(date +'%Y-%m-%dT%H%M%S')
+          echo "NOW=${NOW}" >> $GITHUB_ENV
+          echo "Current date: ${NOW}"
+      - name: "☕️ Setup JDK"
+        uses: actions/setup-java@v4
         with:
-          github-token: ${{ secrets.GRAILS_GH_TOKEN }}
-          script: |
-            try {
-              const result = await github.rest.actions.createWorkflowDispatch({
-                owner: 'apache',
-                repo: 'grails-doc',
-                workflow_id: 'gradle.yml',
-                ref: '${{ steps.extract_branch.outputs.value }}'
-              });
-              console.log(result);
-            } catch(error) {
-              console.error(error);
-              core.setFailed(error);
-            }
+          java-version: 17
+          distribution: liberica
+      - name: "🐘 Setup Gradle"
+        uses: gradle/actions/setup-gradle@v4
+        with:
+          develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

Review Comment:
   This should be `GRAILS_DEVELOCITY_ACCESS_KEY`



##########
.github/workflows/gradle.yml:
##########
@@ -9,6 +9,8 @@ on:
       - '[4-9]+.[0-9]+.x'
       - '[3-9]+.[3-9]+.x'
   workflow_dispatch:
+env:
+  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Review Comment:
   Can we add a comment explaining the use of this env var?
   `Used to avoid throttling when the build is using GitHub API endpoints` (or 
something)



##########
grails-gradle/plugins/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy:
##########
@@ -152,7 +152,7 @@ class GrailsPublishPluginSpec extends GradleSpecification {
         assertBuildSuccess(result, ["compileJava", "compileGroovy", 
"processResources", "classes", "jar", "groovydoc", "javadoc", "javadocJar", 
"sourcesJar"])
 
         !result.output.contains("Project subproject2 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")
-        result.output.contains("Project subproject1 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")
+        !result.output.contains("Project subproject1 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")

Review Comment:
   Are these assertions still valuable/necessary?



##########
grails-doc/build.gradle:
##########
@@ -0,0 +1,229 @@
+import org.apache.tools.ant.taskdefs.condition.Os
+
+plugins {
+    id 'base'
+    id 'org.asciidoctor.jvm.convert'
+    id 'groovy'
+}
+
+repositories {
+    maven { url = "https://repo.grails.org/grails/core"; }
+}
+
+compileJava.options.release = javaVersion.toInteger()
+
+version = projectVersion
+
+ext {
+    grailsCheckOutDir = 
project.layout.buildDirectory.dir('grails-core/checkout').get().asFile.absolutePath
+    grailsTestsCheckOutDir = 
project.layout.buildDirectory.dir('grails-functional-tests/checkout').get().asFile.absolutePath
+    outputDir = layout.buildDirectory.file("docs").get().asFile.absolutePath
+    githubBranch = project.findProperty("githubBranch")
+    guidePage = "/docs/guide/single.html"
+    indexPage = "/docs/index.html"
+}
+
+dependencies {
+    implementation platform(project(':grails-bom'))
+    implementation "org.apache.grails:grails-docs-core"
+    implementation "org.apache.groovy:groovy"
+
+    // Used to surface versions for AsciiDoc
+    implementation project(':grails-dependencies')
+    implementation project(':grails-testing-support-core')
+    implementation 'org.apache.grails:grails-data-hibernate5'
+    implementation 'org.apache.grails:grails-gradle-plugins'
+}
+
+// use jsoup in PdfBuilder for cleaning input html
+System.setProperty('grails.docs.clean.html', 'true')
+// creates single.html.before.xml and single.html.after.xml files for 
debugging pdf input when enabled
+//System.setProperty('grails.docs.debug.pdf','true')
+
+asciidoctor {
+    resources {
+        from('resources')
+    }
+
+    options template_dirs: ["${projectDir}/src/docs/templates"]
+    attributes 'experimental': 'true',
+            'compat-mode': 'true',
+            'icons': 'font',
+            'linkcss': 'true',
+            'docinfo1': '',
+            'toc': 'left',
+            'version': project.version,
+            'sourcedir': rootProject.projectDir.absolutePath
+}
+
+asciidoctor.dependsOn(":aggregateGroovydoc")
+
+tasks.withType(org.gradle.api.tasks.javadoc.Groovydoc) {
+    configure {
+        access = GroovydocAccess.PRIVATE
+        processScripts = false
+        includeMainForScripts = false
+    }
+}
+
+tasks.register("dist", Zip) {
+    dependsOn "docs"
+    from outputDir
+}
+
+tasks.register("createReleaseDropdown", grails.doc.AddReleaseDropDown) {
+    dependsOn "publishGuide", "publishPdf"
+    inputFiles = 
[project.layout.buildDirectory.file("manual/guide/single.html").get().asFile, 
project.layout.buildDirectory.file("manual/index.html").get().asFile]
+
+    inputs.files(inputFiles)
+    outputs.dir(outputDir)
+}
+
+tasks.register('resolveGroovyVersion') {
+    group = 'documentation'
+    description = 'Resolve Groovy Version from the BOM'
+    ext.resolved = configurations.compileClasspath
+            .resolvedConfiguration
+            .resolvedArtifacts
+            .find {
+                it.moduleVersion.id.group == 'org.apache.groovy' &&
+                        it.moduleVersion.id.name.contains('groovy')
+            }.moduleVersion.id.version
+    logger.lifecycle('Resolved Groovy version for Guide links: {}', 
ext.resolved)
+}
+
+String getVersion(String artifact) {
+    configurations.runtimeClasspath
+            .resolvedConfiguration
+            .resolvedArtifacts
+            .find {
+                it.moduleVersion.id.name == artifact
+            }?.moduleVersion?.id?.version
+}
+
+tasks.register('publishGuide', grails.doc.gradle.PublishGuide) {
+    dependsOn(['generateBomDocumentation', ':aggregateGroovydoc', 'jar', 
'resolveGroovyVersion', 'processTestResources', 'compileTestJava', 
'compileTestGroovy', 'test'])
+    targetDir = project.layout.buildDirectory.dir("manual").get().asFile
+
+    doFirst {
+        def searchDirs = rootProject.projectDir.listFiles().findAll {
+            new File(it, "src/main/groovy/org/grails").exists()
+        }.collect {
+            new File(it, "src/main/groovy/org/grails")
+        }
+
+        // No language setting because we want the English guide to be
+        // generated with a 'en' in the path, but the source is in 'en'
+        // so that it's easy to track with git.
+        sourceRepo = 
"https://github.com/apache/grails-core/edit/$githubBranch/grails-doc/src/en";
+        sourceDir = project.layout.projectDirectory.dir('src/en').asFile
+        propertiesFiles = 
[rootProject.layout.projectDirectory.file('gradle.properties').asFile]
+        asciidoc = true
+
+        ext.springVersion = getVersion("spring-core")
+        ext.springBootVersion = getVersion("spring-boot")
+        ext.gspVersion = getVersion("grails-gsp")
+        ext.gormVersion = getVersion("grails-datamapping-core")

Review Comment:
   Do we need these in `ext`. Can we use regular variables with `def`?



##########
grails-gradle/plugins/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy:
##########
@@ -167,7 +167,7 @@ class GrailsPublishPluginSpec extends GradleSpecification {
         assertBuildSuccess(result, ["compileJava", "compileGroovy", 
"processResources", "classes", "jar", "groovydoc", "javadoc", "javadocJar", 
"sourcesJar"])
 
         !result.output.contains("Project subproject2 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")
-        result.output.contains("Project subproject1 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")
+        !result.output.contains("Project subproject1 does not have a version 
defined. Using the gradle property `projectVersion` to assume version is 
0.0.1-SNAPSHOT.")

Review Comment:
   Are these assertions still valuable/necessary?



-- 
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