From 3b5a5d5c80e18e3285c51bdb67244d458f140404 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Thu, 26 Jun 2025 09:18:18 -0400 Subject: [PATCH] Upgrade to the latest version of Grails & provide forward compatibility for future Grails Versions without the need to release this plugin. --- .sdkmanrc | 2 +- README.md | 2 +- build.gradle | 23 +++--- buildSrc/build.gradle | 27 +++++++ docs/build.gradle | 2 +- docs/src/docs/installation.adoc | 13 +++- examples/alternativeConfig/build.gradle | 89 ++++++++++-------------- examples/bookStore/build.gradle | 87 ++++++++++------------- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- plugin/build.gradle | 47 +++++-------- 11 files changed, 148 insertions(+), 150 deletions(-) create mode 100644 buildSrc/build.gradle diff --git a/.sdkmanrc b/.sdkmanrc index 96e716d..48cc71b 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,2 +1,2 @@ # Enable auto-env through the sdkman_auto_env config - https://sdkman.io/usage#env -java=17.0.12-librca +java=17.0.15-librca diff --git a/README.md b/README.md index 18b8146..883e8ee 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build Test Data ## Build Test Data Grails Plugin ### Grails 7.x or later -`testImplementation 'io.github.longwa:build-test-data:6.0.0-M1'` +`testImplementation 'io.github.longwa:build-test-data:6.0.0-M2'` http://longwa.github.io/build-test-data/index diff --git a/build.gradle b/build.gradle index f38f6bc..adb6b32 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,3 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core/" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:${grailsGradlePluginVersion}" - } -} - plugins { id 'com.adarshr.test-logger' version '4.0.0' } @@ -14,6 +5,18 @@ plugins { allprojects { repositories { maven { url "https://repo.grails.org/grails/core" } + maven { + url = 'https://central.sonatype.com/repository/maven-snapshots' + content { + includeVersionByRegex('cloud[.]wondrify', '.*', '.*-SNAPSHOT') + } + } + maven { + url = 'https://repository.apache.org/content/groups/snapshots' + content { + includeVersionByRegex 'org[.]apache[.]((grails)|(groovy)).*', '.*', '.*-SNAPSHOT' + } + } } } @@ -52,7 +55,7 @@ subprojects { } if (project.name == 'build-test-data') { - apply plugin: "org.grails.grails-publish" + apply plugin: "org.apache.grails.gradle.grails-publish" grailsPublish { githubSlug = 'longwa/build-test-data' artifactId = 'build-test-data' diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..b5c3eb8 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,27 @@ +file('../gradle.properties').withInputStream { + Properties props = new Properties() + props.load(it) + project.ext.gradleProperties = props +} + +repositories { + maven { url "https://repo.grails.org/grails/restricted" } + maven { + url = 'https://central.sonatype.com/repository/maven-snapshots' + content { + includeVersionByRegex('cloud[.]wondrify', '.*', '.*-SNAPSHOT') + } + } + maven { + url = 'https://repository.apache.org/content/groups/snapshots' + content { + includeVersionByRegex 'org[.]apache[.]((grails)|(groovy)).*', '.*', '.*-SNAPSHOT' + } + } +} + +dependencies { + implementation platform("org.apache.grails:grails-bom:${gradleProperties.grailsVersion}") + implementation "org.apache.grails:grails-gradle-plugins" + implementation "cloud.wondrify:asset-pipeline-gradle" +} \ No newline at end of file diff --git a/docs/build.gradle b/docs/build.gradle index 4a40fd4..98e2e97 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -24,7 +24,7 @@ def asciidoctorAttributes = [ version : project.version, projectUrl : "https://github.com/longwa/build-test-data", sourcedir : "${rootProject.allprojects.find { it.name == 'build-test-data' }.projectDir}/src/main/groovy", - gormDetailedLink : "https://gorm.grails.org/${getGrailsDocumentationVersion(project['gorm.version'] as String)}/hibernate/manual/index.html", + gormDetailedLink : "https://gorm.grails.org/${getGrailsDocumentationVersion(project.grailsVersion)}/hibernate/manual/index.html", gormSummaryLink : "https://docs.grails.org/${getGrailsDocumentationVersion(project.grailsVersion)}/guide/GORM.html", grailsDocBase : "https://docs.grails.org/${getGrailsDocumentationVersion(project.grailsVersion)}" ] diff --git a/docs/src/docs/installation.adoc b/docs/src/docs/installation.adoc index 769289d..e9b5e44 100644 --- a/docs/src/docs/installation.adoc +++ b/docs/src/docs/installation.adoc @@ -2,11 +2,22 @@ == Installation The test framework and testing methodology for Grails has undergone several major revisions over the past few releases. -Unfortunately, this makes it impossible to have one plugin which is compatible with all prior versions. +Unfortunately, this makes it impossible to have one plugin which is compatible with all prior versions. Please see the below sections to determine which version of the plugin you should use for your Grails version. === Grails 7.0 or later `testImplementation "io.github.longwa:build-test-data:{version}"` +Build Test Data versions after 6.0.0-M1 no longer export dependencies that are available to a Grails application: + + "org.apache.grails:grails-core" + "org.apache.grails:grails-testing-support-datamapping" + "org.apache.grails.databinding:grails-databinding-core" + "org.apache.grails.data:grails-datamapping-core" + "org.apache.grails:grails-web-boot" + "org.apache.grails:grails-testing-support-web" + +If these dependencies are missing from your `build.gradle`, build test data may not function correctly. Not exporting these dependencies ensures the plugin is forward compatible with Grails Versions and minimizes the need to release this plugin for minor changes to Grails. + === Grails 5.0 or Grails 6.0 `testImplementation "io.github.longwa:build-test-data:5.0.0"` diff --git a/examples/alternativeConfig/build.gradle b/examples/alternativeConfig/build.gradle index 4324139..24e8cf8 100644 --- a/examples/alternativeConfig/build.gradle +++ b/examples/alternativeConfig/build.gradle @@ -1,22 +1,6 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "org.grails.plugins:hibernate5:${project.'gorm.version' - ".RELEASE"}" - } -} - plugins { - id "groovy" - id "org.grails.grails-web" - id "org.grails.grails-gsp" - id "war" - id "idea" - // Not needed because no /assets directory - // id "com.bertramlabs.asset-pipeline" version "${assetPipelineVersion}" - id "eclipse" + id "org.apache.grails.gradle.grails-web" + id "org.apache.grails.gradle.grails-gsp" } version "0.1" @@ -25,40 +9,41 @@ group "alternativeconfig" dependencies { implementation project(':build-test-data') - profile("org.grails.profiles:web") - - implementation("org.grails:grails-core") - implementation("org.grails:grails-logging") - implementation("org.grails:grails-plugin-databinding") - implementation("org.grails:grails-plugin-i18n") - implementation("org.grails:grails-plugin-interceptors") - implementation("org.grails:grails-plugin-rest") - implementation("org.grails:grails-plugin-services") - implementation("org.grails:grails-plugin-url-mappings") - implementation("org.grails:grails-web-boot") - implementation("org.grails.plugins:gsp") - implementation("org.grails.plugins:hibernate5") - implementation("org.grails.plugins:scaffolding") - implementation("org.sitemesh:grails-plugin-sitemesh3:${grailsVersion}") - implementation("org.springframework.boot:spring-boot-autoconfigure") - implementation("org.springframework.boot:spring-boot-starter") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-logging") - implementation("org.springframework.boot:spring-boot-starter-tomcat") - implementation("org.springframework.boot:spring-boot-starter-validation") - - console("org.grails:grails-console") - - runtimeOnly("com.bertramlabs.plugins:asset-pipeline-grails") - runtimeOnly("com.h2database:h2") - runtimeOnly("org.apache.tomcat:tomcat-jdbc") - runtimeOnly("org.fusesource.jansi:jansi") - - integrationTestImplementation testFixtures("org.grails.plugins:geb") - - testImplementation("org.grails:grails-gorm-testing-support") - testImplementation("org.grails:grails-web-testing-support") - testImplementation("org.spockframework:spock-core") + profile("org.apache.grails.profiles:web") + + implementation platform("org.apache.grails:grails-bom:$grailsVersion") + + implementation "org.apache.grails:grails-core" + implementation "org.apache.grails:grails-data-hibernate5" + implementation "org.apache.grails:grails-databinding" + implementation "org.apache.grails:grails-gsp" + implementation "org.apache.grails:grails-i18n" + implementation "org.apache.grails:grails-interceptors" + implementation "org.apache.grails:grails-logging" + implementation "org.apache.grails:grails-rest-transforms" + implementation "org.apache.grails:grails-scaffolding" + implementation "org.apache.grails:grails-services" + implementation "org.apache.grails:grails-url-mappings" + implementation "org.apache.grails:grails-web-boot" + implementation "org.springframework.boot:spring-boot-autoconfigure" + implementation "org.springframework.boot:spring-boot-starter" + implementation "org.springframework.boot:spring-boot-starter-actuator" + implementation "org.springframework.boot:spring-boot-starter-logging" + implementation "org.springframework.boot:spring-boot-starter-tomcat" + implementation "org.springframework.boot:spring-boot-starter-validation" + + console "org.apache.grails:grails-console" + + runtimeOnly "cloud.wondrify:asset-pipeline-grails" + runtimeOnly "com.h2database:h2" + runtimeOnly "com.zaxxer:HikariCP" + runtimeOnly "org.fusesource.jansi:jansi" + + integrationTestImplementation testFixtures("org.apache.grails:grails-geb") + + testImplementation "org.apache.grails:grails-testing-support-datamapping" + testImplementation "org.apache.grails:grails-testing-support-web" + testImplementation "org.spockframework:spock-core" } // No assets in test project diff --git a/examples/bookStore/build.gradle b/examples/bookStore/build.gradle index 724bb0b..0218ccb 100644 --- a/examples/bookStore/build.gradle +++ b/examples/bookStore/build.gradle @@ -1,60 +1,47 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - } -} - plugins { - id "groovy" - id "org.grails.grails-web" - id "org.grails.grails-gsp" - id "war" - id "idea" - // Not needed because no /assets directory - // id "com.bertramlabs.asset-pipeline" version "${assetPipelineVersion}" - id "eclipse" + id "org.apache.grails.gradle.grails-web" + id "org.apache.grails.gradle.grails-gsp" } version "0.1" group "bookStore" dependencies { - profile("org.grails.profiles:web") - - implementation("org.grails:grails-core") - implementation("org.grails:grails-logging") - implementation("org.grails:grails-plugin-databinding") - implementation("org.grails:grails-plugin-i18n") - implementation("org.grails:grails-plugin-interceptors") - implementation("org.grails:grails-plugin-rest") - implementation("org.grails:grails-plugin-services") - implementation("org.grails:grails-plugin-url-mappings") - implementation("org.grails:grails-web-boot") - implementation("org.grails.plugins:gsp") - implementation("org.grails.plugins:hibernate5") - implementation("org.grails.plugins:scaffolding") - implementation("org.springframework.boot:spring-boot-autoconfigure") - implementation("org.springframework.boot:spring-boot-starter") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-logging") - implementation("org.springframework.boot:spring-boot-starter-tomcat") - implementation("org.springframework.boot:spring-boot-starter-validation") - - console("org.grails:grails-console") - - runtimeOnly("com.bertramlabs.plugins:asset-pipeline-grails") - runtimeOnly("com.h2database:h2") - runtimeOnly("org.apache.tomcat:tomcat-jdbc") - runtimeOnly("org.fusesource.jansi:jansi") - - integrationTestImplementation testFixtures("org.grails.plugins:geb") - - testImplementation("org.grails:grails-gorm-testing-support") - testImplementation("org.grails:grails-web-testing-support") - testImplementation("org.spockframework:spock-core") + profile("org.apache.grails.profiles:web") + + implementation platform("org.apache.grails:grails-bom:$grailsVersion") + + implementation "org.apache.grails:grails-core" + implementation "org.apache.grails:grails-data-hibernate5" + implementation "org.apache.grails:grails-databinding" + implementation "org.apache.grails:grails-gsp" + implementation "org.apache.grails:grails-i18n" + implementation "org.apache.grails:grails-interceptors" + implementation "org.apache.grails:grails-logging" + implementation "org.apache.grails:grails-rest-transforms" + implementation "org.apache.grails:grails-scaffolding" + implementation "org.apache.grails:grails-services" + implementation "org.apache.grails:grails-url-mappings" + implementation "org.apache.grails:grails-web-boot" + implementation "org.springframework.boot:spring-boot-autoconfigure" + implementation "org.springframework.boot:spring-boot-starter" + implementation "org.springframework.boot:spring-boot-starter-actuator" + implementation "org.springframework.boot:spring-boot-starter-logging" + implementation "org.springframework.boot:spring-boot-starter-tomcat" + implementation "org.springframework.boot:spring-boot-starter-validation" + + console "org.apache.grails:grails-console" + + runtimeOnly "cloud.wondrify:asset-pipeline-grails" + runtimeOnly "com.h2database:h2" + runtimeOnly "com.zaxxer:HikariCP" + runtimeOnly "org.fusesource.jansi:jansi" + + integrationTestImplementation testFixtures("org.apache.grails:grails-geb") + + testImplementation "org.apache.grails:grails-testing-support-datamapping" + testImplementation "org.apache.grails:grails-testing-support-web" + testImplementation "org.spockframework:spock-core" testImplementation project(':build-test-data') } diff --git a/gradle.properties b/gradle.properties index 66168d4..94bfdc2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,6 @@ projectVersion=6.0.0-SNAPSHOT -grailsVersion=7.0.0-M1 -grailsGradlePluginVersion=7.0.0-M3 -gorm.version=9.0.0-M3 +grailsVersion=7.0.0-SNAPSHOT org.gradle.daemon=true org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 94113f2..ff23a68 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/plugin/build.gradle b/plugin/build.gradle index 4ac7a37..9acfe4f 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -1,47 +1,34 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - } +plugins { + id 'org.apache.grails.gradle.grails-plugin' } -group "org.grails.plugins" -apply plugin: "eclipse" -apply plugin: "idea" -apply plugin: "org.grails.grails-plugin" +group 'io.github.longwa' dependencies { - implementation "org.springframework.boot:spring-boot-starter-logging" - implementation "org.springframework.boot:spring-boot-autoconfigure" + implementation platform("org.apache.grails:grails-bom:$grailsVersion") implementation "dk.brics:automaton:1.12-4" - implementation "org.grails:grails-core" - implementation "org.grails:grails-gorm-testing-support" - implementation "org.grails:grails-databinding" - implementation "org.grails:grails-datastore-gorm" - implementation "org.grails:grails-console" - - // So we can run 'grails' and/or 'grails test-app' inside build-test-data - profile "org.grails.profiles:web-plugin" - - implementation "org.springframework.boot:spring-boot-starter-actuator" - implementation "org.springframework.boot:spring-boot-starter-tomcat" - implementation "org.grails:grails-web-boot" + // Use compileOnly for dependencies that are provided by the Grails runtime to allow us to depend on a grails snapshot and + // and not have any users of this library use a snapshot dependency + compileOnly "org.apache.grails:grails-core" + compileOnly "org.apache.grails:grails-testing-support-datamapping" + compileOnly "org.apache.grails.databinding:grails-databinding-core" + compileOnly "org.apache.grails.data:grails-datamapping-core" + compileOnly "org.apache.grails:grails-web-boot" runtimeOnly 'org.apache.groovy:groovy-dateutil' - testImplementation "org.grails.plugins:hibernate5" + testImplementation "org.apache.grails:grails-data-hibernate5" testImplementation "com.h2database:h2" testImplementation "org.apache.tomcat:tomcat-jdbc" - testImplementation "org.grails:grails-gorm-testing-support" - testImplementation "org.grails:grails-web-testing-support" + testImplementation "org.apache.grails:grails-testing-support-datamapping" + testImplementation "org.apache.grails:grails-testing-support-web" } -// Enable if you wish to package this plugin as a standalone application -bootJar.enabled = false +grails { + springDependencyManagement = false +} //this makes the groovy docs much more readable by shorting packages and providing links groovydoc {