Skip to content

Commit

Permalink
build: resolve Groovy version for guide links
Browse files Browse the repository at this point in the history
Since the project now relies on the BOM for the `groovyVersion` instead of specifying it explicitly, the version must be resolved dynamically to ensure guide links point to the correct Groovy API documentation.
  • Loading branch information
matrei committed Jan 14, 2025
1 parent dc0d621 commit 04110df
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ buildscript {

apply plugin: 'groovy'

dependencies {
implementation platform("org.grails:grails-bom:$grailsVersion")
implementation 'org.apache.groovy:groovy'
}

tasks.register('resolveGroovyVersion') {
group = 'documentation'
description = 'Resolve Groovy Version from the BOM'
ext.resolved = configurations.compileClasspath
.resolvedConfiguration
.resolvedArtifacts
.find {
// Look for your Groovy artifact by group and name
it.moduleVersion.id.group == 'org.apache.groovy' &&
it.moduleVersion.id.name.contains('groovy')
}.moduleVersion.id.version
logger.info("Resolved Groovy Version for Guide: $resolved")
}


// TODO: PublishGuide should eventually ensure the build directory exists
tasks.register('docsBuild') {
doFirst {
Expand All @@ -23,7 +43,7 @@ tasks.register('docsBuild') {
tasks.register('publishGuide', PublishGuide) {
group = 'documentation'
description = 'Generate Guide'
dependsOn('docsBuild')
dependsOn('docsBuild', 'resolveGroovyVersion')

targetDir = project.layout.buildDirectory.dir('docs').get().asFile
outputs.dir(targetDir) // ensure gradle understands what this task generates
Expand All @@ -42,8 +62,8 @@ tasks.register('publishGuide', PublishGuide) {
'javaee' : 'https://docs.oracle.com/javaee/7/api/',
'jakartaee' : 'https://jakarta.ee/specifications/platform/10/apidocs/',
'javase' : 'https://docs.oracle.com/en/java/javase/17/docs/api/index.html',
'groovyapi' : "https://docs.groovy-lang.org/latest/html/gapi/",
'groovyjdk' : "https://docs.groovy-lang.org/latest/html/groovy-jdk/",
'groovyapi' : "https://docs.groovy-lang.org/${resolveGroovyVersion.resolved}/html/gapi/",
'groovyjdk' : "https://docs.groovy-lang.org/${resolveGroovyVersion.resolved}/html/groovy-jdk/",
'grailsapi' : "https://docs.grails.org/$grailsVersion/api/",
'grailsdocs' : "https://docs.grails.org/$grailsVersion/",
'gormapi' : 'https://gorm.grails.org/latest/api/',
Expand Down

0 comments on commit 04110df

Please sign in to comment.