From 11714b6515ff91973c940bba44bbf3514375f45c Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Tue, 3 Dec 2024 14:46:52 -0500 Subject: [PATCH] Grails 7 updates: 1. switch to new grails publish 2. Convert to ContainerGebSpec 3. fix old layout issues --- .github/workflows/gradle.yml | 7 +- .github/workflows/release.yml | 16 +- build.gradle | 54 +----- gradle.properties | 17 +- gradle/docs.gradle | 158 ++++++++++++++++++ grails-app/views/demo/blockCache.gsp | 2 +- grails-app/views/demo/blockCacheTTL.gsp | 2 +- grails-app/views/demo/renderTag.gsp | 2 +- grails-app/views/demo/renderTagTTL.gsp | 2 +- .../com/demo/CacheTagIntegrationSpec.groovy | 7 +- .../demo/CachingServiceIntegrationSpec.groovy | 10 +- .../resources/GebConfig.groovy | 42 ----- 12 files changed, 191 insertions(+), 128 deletions(-) create mode 100644 gradle/docs.gradle delete mode 100644 src/integration-test/resources/GebConfig.groovy diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 0f600f9c..10ee84b9 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -59,10 +59,11 @@ jobs: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + MAVEN_PUBLISH_USERNAME: ${{ secrets.MAVEN_PUBLISH_USERNAME }} + MAVEN_PUBLISH_PASSWORD: ${{ secrets.MAVEN_PUBLISH_PASSWORD }} + MAVEN_PUBLISH_URL: ${{ secrets.MAVEN_PUBLISH_SNAPSHOT_URL }} with: - arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish + arguments: publish docs: if: github.event_name == 'push' needs: build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4643658b..ea9379fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,10 +54,10 @@ jobs: id: publish uses: gradle/gradle-build-action@v3 env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_NEXUS_URL: ${{ secrets.SONATYPE_NEXUS_URL }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} + NEXUS_PUBLISH_NEXUS_URL: ${{ secrets.NEXUS_PUBLISH_RELEASE_URL }} + NEXUS_PUBLISH_STAGING_PROFILE_ID: ${{ secrets.NEXUS_PUBLISH_STAGING_PROFILE_ID }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} SECRING_FILE: ${{ secrets.SECRING_FILE }} @@ -86,10 +86,10 @@ jobs: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_NEXUS_URL: ${{ secrets.SONATYPE_NEXUS_URL }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} + NEXUS_PUBLISH_NEXUS_URL: ${{ secrets.NEXUS_PUBLISH_RELEASE_URL }} + NEXUS_PUBLISH_STAGING_PROFILE_ID: ${{ secrets.NEXUS_PUBLISH_STAGING_PROFILE_ID }} with: arguments: | findSonatypeStagingRepository diff --git a/build.gradle b/build.gradle index dd22f55f..94b1ab98 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ buildscript { dependencies { classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" classpath "org.asciidoctor:asciidoctor-gradle-plugin:$asciidoctorGradlePlugin" - classpath "com.github.erdi:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion" } } @@ -14,26 +13,15 @@ version project.projectVersion apply plugin:"eclipse" apply plugin:"idea" -apply plugin: "com.github.erdi.webdriver-binaries" -apply from:"https://raw.githubusercontent.com/grails/grails-common-build/v2.0.3/common-docs.gradle" +apply from:"./gradle/docs.gradle" apply plugin:"org.grails.grails-plugin" -apply plugin:"org.grails.internal.grails-plugin-publish" +apply plugin:"org.grails.grails-publish" repositories { mavenCentral() maven { url "https://repo.grails.org/grails/core" } } -configurations { - all { - resolutionStrategy.eachDependency { DependencyResolveDetails details-> - if (details.requested.group == 'org.seleniumhq.selenium') { - details.useVersion(seleniumVersion) - } - } - } -} - dependencies { api "org.springframework.boot:spring-boot-starter-logging" api "org.springframework.boot:spring-boot-autoconfigure" @@ -61,43 +49,16 @@ dependencies { testImplementation "org.grails:grails-gorm-testing-support" testImplementation "org.grails:grails-web-testing-support" testImplementation "org.mockito:mockito-core" - testImplementation("org.grails.plugins:geb") { - exclude group: 'org.gebish', module: 'geb-spock' - } - - testImplementation "org.gebish:geb-spock:$gebVersion" - - testRuntimeOnly "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion" - testRuntimeOnly "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion" - testRuntimeOnly "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion" - - testImplementation "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion" - testImplementation "org.seleniumhq.selenium:selenium-api:$seleniumVersion" - testImplementation "org.seleniumhq.selenium:selenium-support:$seleniumVersion" + integrationTestImplementation testFixtures("org.grails.plugins:geb:5.0.0-SNAPSHOT") api "com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:$concurrentlinkedhashmapLruVersion" } apply from: rootProject.file('gradle/testVerbose.gradle') -webdriverBinaries { - if (!System.getenv().containsKey('CI')) { - chromedriver "$chromeDriverVersion" - geckodriver "$geckodriverVersion" - } -} - -tasks.withType(Test) { - systemProperty "geb.env", System.getProperty('geb.env') - systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest") - if (!System.getenv().containsKey('CI')) { - systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver') - systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver') - } else { - systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver" - systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver" - } -} +//tasks.withType(Test) { +// systemProperty 'grails.geb.recording.mode', 'RECORD_FAILING' +//} bootRun { jvmArgs( @@ -111,8 +72,7 @@ bootRun { } grailsPublish { - userOrg = 'grails' - githubSlug = 'grails/grails-cache' + githubSlug = project.githubSlug license { name = 'Apache-2.0' } diff --git a/gradle.properties b/gradle.properties index 27542716..e56f9951 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,20 +6,15 @@ grailsVersion=7.0.0-SNAPSHOT grailsGradlePluginVersion=7.0.0-SNAPSHOT gormVersion=9.0.0-SNAPSHOT gparsVersion=1.2.1 -groovyVersion=4.0.23 -githubSlug=grails/grails-cache -githubBranch=8.0.x -title=Cache Plugin -projectDesc=Provides AST transformations for caching method calls +groovyVersion=4.0.24 guide=../../guide tags=../ref/Tags -gebVersion=7.0 -seleniumVersion=4.25.0 -webdriverBinariesVersion=3.2 -chromeDriverVersion=126.0.6478.126 -geckodriverVersion=0.32.2 -seleniumSafariDriverVersion=4.25.0 +# Docs +title=Grails Cache Plugin +githubSlug=grails/grails-cache +githubBranch=8.0.x +projectDesc="Provides AST transformations for caching method calls" org.gradle.daemon=true org.gradle.caching=true diff --git a/gradle/docs.gradle b/gradle/docs.gradle new file mode 100644 index 00000000..9ace9a6d --- /dev/null +++ b/gradle/docs.gradle @@ -0,0 +1,158 @@ +buildscript { + repositories { + maven { url "https://repo.grails.org/grails/core" } + } + dependencies { + classpath "org.grails:grails-docs:${project.ext.properties.grailsDocsVersion ?: grailsVersion}" + } +} + +apply plugin: 'java-library' +apply plugin: 'groovy' + +def DOCUMENTATION_GROUP = 'Documentation' + +def commonGithubOrg = 'grails' +def commonGithubSlug = 'grails-common-build' +def commonBranch = 'master' +def docResourcesDir = "${buildDir}/resources/${commonGithubSlug}-${commonBranch}/src/main/resources" + +task prepareDocResources { + group = DOCUMENTATION_GROUP + description = 'Downloads common documentation resoruces and unzips them to build folder' + doLast { + ant.mkdir(dir:buildDir) + ant.get(src:"https://github.com/${commonGithubOrg}/${commonGithubSlug}/archive/${commonBranch}.zip", dest:"${buildDir}/resources.zip") + ant.unzip(src:"${buildDir}/resources.zip", dest:"${buildDir}/resources") + } +} + +task copyLocalDocResources(type: Copy, dependsOn:prepareDocResources) { + group = DOCUMENTATION_GROUP + description = 'Copy local resources to build folder' + mustRunAfter prepareDocResources + from ('src/main/docs/resources') + into docResourcesDir +} + +configurations { + documentation +} + +dependencies { + if (configurations.find { it.name == 'documentation' }) { + documentation 'info.picocli:picocli:3.8.0' + documentation "org.fusesource.jansi:jansi:1.18" + documentation "jline:jline:2.14.6" + documentation "com.github.javaparser:javaparser-core:3.15.14" + documentation "org.codehaus.groovy:groovy:${groovyVersion}" + documentation "org.codehaus.groovy:groovy-ant:$groovyVersion" + documentation "org.codehaus.groovy:groovy-cli-picocli:$groovyVersion" + } +} + +subprojects { + + configurations { + documentation + } + + dependencies { + if (configurations.find { it.name == 'documentation' }) { + documentation "org.fusesource.jansi:jansi:1.18" + documentation "jline:jline:2.14.6" + documentation "com.github.javaparser:javaparser-core:3.15.14" + documentation "org.codehaus.groovy:groovy:${groovyVersion}" + documentation "org.codehaus.groovy:groovy-ant:$groovyVersion" + documentation "org.codehaus.groovy:groovy-dateutil:$groovyVersion" + documentation "org.codehaus.groovy:groovy-cli-picocli:$groovyVersion" + } + } + + groovydoc.classpath += configurations.documentation +} + +def cleanTask = project.tasks.findByName("clean") +if(cleanTask == null) { + task clean(type: Delete) { + delete(buildDir) + } +} +else { + cleanTask.doLast { + ant.delete(dir:"build/docs") + } +} + +tasks.withType(Groovydoc) { + group = DOCUMENTATION_GROUP + docTitle = "${project.title} - ${project.version}" + destinationDir = project.file("build/docs/api") + def files = [] + project.rootProject.subprojects + .findAll { !it.name != 'docs' && !it.name.startsWith('examples') } + .each { subproject -> + if(subproject.file('src/main/groovy').exists()) { + files += subproject.files("src/main/groovy") + } + } + if(project.file('src/main/groovy').exists()) { + files += project.files("src/main/groovy") + } + source = files + classpath += configurations.documentation +} + +task publishGuide(type: grails.doc.gradle.PublishGuide) { + group = DOCUMENTATION_GROUP + description = 'Generate Guide' + dependsOn copyLocalDocResources + + targetDir = project.file("${buildDir}/docs") + sourceRepo = "https://github.com/${githubSlug}/edit/${githubBranch}/src/main/docs" + sourceDir = new File(projectDir, "src/main/docs") + propertiesFiles = [ new File(rootProject.projectDir, "gradle.properties") ] + asciidoc = true + resourcesDir = project.file(docResourcesDir) + properties = [ + 'safe':'UNSAFE', + 'version': project.version, + 'subtitle': project.projectDesc, + 'api': '../api', + 'sourceDir':rootProject.projectDir.absolutePath, + 'sourcedir':rootProject.projectDir.absolutePath, + 'javaee': 'https://docs.oracle.com/javaee/7/api/', + 'javase': 'https://docs.oracle.com/javase/7/docs/api/', + 'groovyapi': 'http://docs.groovy-lang.org/latest/html/gapi/', + 'grailsapi': 'http://docs.grails.org/latest/api/', + 'gormapi': 'http://gorm.grails.org/latest/api/', + 'springapi': 'https://docs.spring.io/spring/docs/current/javadoc-api/' + ] + doLast { + ant.move(file:"${project.buildDir}/docs/guide/single.html", + tofile:"${project.buildDir}/docs/guide/index.html", overwrite:true) + new File(project.buildDir, "docs/index.html").text = ''' + + + + + + + + +''' + } +} + +task docs(dependsOn:[groovydoc, publishGuide]) { + group = DOCUMENTATION_GROUP +} + +def assembleTask = project.tasks.findByName("assemble") +if(assembleTask == null) { + task assemble(dependsOn: docs, type:Zip) { + baseName = "${project.name}-${project.version}" + destinationDir = new File(project.buildDir, "distributions") + from project.files("${buildDir}/docs") + } +} diff --git a/grails-app/views/demo/blockCache.gsp b/grails-app/views/demo/blockCache.gsp index dda50f55..31006d05 100644 --- a/grails-app/views/demo/blockCache.gsp +++ b/grails-app/views/demo/blockCache.gsp @@ -1,6 +1,6 @@ - + diff --git a/grails-app/views/demo/blockCacheTTL.gsp b/grails-app/views/demo/blockCacheTTL.gsp index d156607f..44a0de29 100644 --- a/grails-app/views/demo/blockCacheTTL.gsp +++ b/grails-app/views/demo/blockCacheTTL.gsp @@ -1,6 +1,6 @@ - + diff --git a/grails-app/views/demo/renderTag.gsp b/grails-app/views/demo/renderTag.gsp index 90c57a21..2c432494 100644 --- a/grails-app/views/demo/renderTag.gsp +++ b/grails-app/views/demo/renderTag.gsp @@ -1,6 +1,6 @@ - + diff --git a/grails-app/views/demo/renderTagTTL.gsp b/grails-app/views/demo/renderTagTTL.gsp index f976ebb8..075d587a 100644 --- a/grails-app/views/demo/renderTagTTL.gsp +++ b/grails-app/views/demo/renderTagTTL.gsp @@ -1,6 +1,6 @@ - + diff --git a/src/integration-test/groovy/com/demo/CacheTagIntegrationSpec.groovy b/src/integration-test/groovy/com/demo/CacheTagIntegrationSpec.groovy index fcb06285..b5d127ba 100644 --- a/src/integration-test/groovy/com/demo/CacheTagIntegrationSpec.groovy +++ b/src/integration-test/groovy/com/demo/CacheTagIntegrationSpec.groovy @@ -1,14 +1,12 @@ package com.demo -import geb.spock.GebSpec +import grails.plugin.geb.ContainerGebSpec import grails.testing.mixin.integration.Integration -import spock.lang.Requires import java.util.concurrent.TimeUnit @Integration -class CacheTagIntegrationSpec extends GebSpec { +class CacheTagIntegrationSpec extends ContainerGebSpec { - @Requires({sys['geb.env']}) void 'test clear cache'() { when: go '/demo/clearBlocksCache' @@ -23,7 +21,6 @@ class CacheTagIntegrationSpec extends GebSpec { browser.driver.pageSource.contains 'cleared templates cache' } - @Requires({sys['geb.env']}) void 'test block tag'() { when: go '/demo/blockCache?counter=5' diff --git a/src/integration-test/groovy/com/demo/CachingServiceIntegrationSpec.groovy b/src/integration-test/groovy/com/demo/CachingServiceIntegrationSpec.groovy index b5c5a550..bf0ecdc9 100644 --- a/src/integration-test/groovy/com/demo/CachingServiceIntegrationSpec.groovy +++ b/src/integration-test/groovy/com/demo/CachingServiceIntegrationSpec.groovy @@ -1,13 +1,11 @@ package com.demo -import geb.spock.GebSpec +import grails.plugin.geb.ContainerGebSpec import grails.testing.mixin.integration.Integration -import spock.lang.Requires @Integration -class CachingServiceIntegrationSpec extends GebSpec { +class CachingServiceIntegrationSpec extends ContainerGebSpec { - @Requires({sys['geb.env']}) void 'test caching service with method params'() { when: go '/demo/basicCachingServiceInvocationCount' @@ -110,7 +108,6 @@ class CachingServiceIntegrationSpec extends GebSpec { browser.driver.pageSource.contains 'Basic Caching Service Invocation Count Is 100.' } - @Requires({sys['geb.env']}) void 'test basic caching service'() { when: go '/demo/basicCachingServiceInvocationCount' @@ -149,7 +146,6 @@ class CachingServiceIntegrationSpec extends GebSpec { browser.driver.pageSource.contains 'Basic Caching Service Invocation Count Is 1.' } - @Requires({sys['geb.env']}) void 'test basic cache put service'() { when: go '/demo/cacheGet?key=band' @@ -206,7 +202,6 @@ class CachingServiceIntegrationSpec extends GebSpec { browser.driver.pageSource.contains 'Result: ** Thin Lizzy' } - @Requires({sys['geb.env']}) void 'test basic cache evict key service'() { when: go '/demo/cachePut?key=band&value=Thin+Lizzy' @@ -221,7 +216,6 @@ class CachingServiceIntegrationSpec extends GebSpec { browser.driver.pageSource.contains 'Result: null' } - @Requires({sys['geb.env']}) void 'test basic cache evict all service'() { when: go '/demo/cachePut?key=band&value=Thin+Lizzy' diff --git a/src/integration-test/resources/GebConfig.groovy b/src/integration-test/resources/GebConfig.groovy deleted file mode 100644 index ab1439ff..00000000 --- a/src/integration-test/resources/GebConfig.groovy +++ /dev/null @@ -1,42 +0,0 @@ -import org.openqa.selenium.chrome.ChromeDriver -import org.openqa.selenium.chrome.ChromeOptions -import org.openqa.selenium.firefox.FirefoxDriver -import org.openqa.selenium.firefox.FirefoxOptions -import org.openqa.selenium.safari.SafariDriver - -environments { - - // You need to configure in Safari -> Develop -> Allowed Remote Automation - safari { - driver = { new SafariDriver() } - } - - // run via “./gradlew -Dgeb.env=chrome iT” - chrome { - driver = { new ChromeDriver() } - } - - // run via “./gradlew -Dgeb.env=chromeHeadless iT” - chromeHeadless { - driver = { - ChromeOptions o = new ChromeOptions() - o.addArguments('headless') - o.addArguments('--remote-allow-origins=*') - new ChromeDriver(o) - } - } - - // run via “./gradlew -Dgeb.env=firefoxHeadless iT” - firefoxHeadless { - driver = { - FirefoxOptions o = new FirefoxOptions() - o.addArguments('-headless') - new FirefoxDriver(o) - } - } - - // run via “./gradlew -Dgeb.env=firefox iT” - firefox { - driver = { new FirefoxDriver() } - } -} \ No newline at end of file