diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 26f4c67..fe4c0c7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -19,8 +19,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: 11 + distribution: 'liberica' + java-version: 17 - name: Setup Redis uses: supercharge/redis-github-action@1.8.0 with: @@ -31,7 +31,7 @@ jobs: env: REDIS_HOST: redis REDIS_PORT: 6379 - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} with: arguments: build -Dgeb.env=chromeHeadless publish: @@ -42,8 +42,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: 11 + distribution: 'liberica' + java-version: 17 - name: Publish Artifacts (repo.grails.org) id: publish uses: gradle/gradle-build-action@v2 @@ -70,5 +70,5 @@ jobs: BRANCH: gh-pages FOLDER: plugin/build/docs DOC_FOLDER: gh-pages - COMMIT_EMAIL: behlp@unityfoundation.io - COMMIT_NAME: Puneet Behl \ No newline at end of file + COMMIT_EMAIL: 'grails-build@users.noreply.github.com' + COMMIT_NAME: 'grails-build' \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5aab3ef..a2178aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,8 @@ jobs: release: runs-on: ubuntu-latest env: - GIT_USER_NAME: puneetbehl - GIT_USER_EMAIL: behlp@unityfoundation.io + GIT_USER_NAME: 'grails-build' + GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' steps: - name: Checkout repository uses: actions/checkout@v4 @@ -16,8 +16,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '11' + distribution: 'liberica' + java-version: '17' - name: Set the current release version id: release_version run: echo ::set-output name=release_version::${GITHUB_REF:11} @@ -60,8 +60,8 @@ jobs: BRANCH: gh-pages FOLDER: plugin/build/docs DOC_FOLDER: gh-pages - COMMIT_EMAIL: behlp@unityfoundation.io - COMMIT_NAME: Puneet Behl + COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} + COMMIT_NAME: ${{ env.GIT_USER_NAME }} VERSION: ${{ steps.release_version.outputs.release_version }} - name: Run post-release if: success() diff --git a/build.gradle b/build.gradle index 1e6bd7e..53ffbde 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,13 @@ + plugins { - id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' + id "java-library" + id "org.grails.internal.grails-plugin-publish" + id "org.grails.grails-gsp" + id "org.grails.grails-plugin" } -ext.isSnapshot = project.projectVersion.endsWith('-SNAPSHOT') -ext.isReleaseVersion = !isSnapshot -ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY') -ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg" -ext."signing.password" = project.hasProperty("signing.password") ? project.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE') - version = project.projectVersion +group = 'org.grails.plugins' allprojects { @@ -24,21 +23,13 @@ allprojects { } } -if (isReleaseVersion) { - apply plugin: "io.github.gradle-nexus.publish-plugin" - - nexusPublishing { - repositories { - sonatype { - def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : '' - def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : '' - def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : '' - nexusUrl = uri("https://s01.oss.sonatype.org/service/local/") - snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") - username = ossUser - password = ossPass - stagingProfileId = ossStagingProfileId - } - } +grailsPublish { + userOrg = 'grails' + githubSlug = 'grails/redis' + license { + name = 'Apache-2.0' } -} + title = 'Grails Redis Plugin' + desc = 'This Plugin provides access to Redis and various utilities(service, annotations, etc) for caching.' + developers = [puneetbehl: 'Puneet Behl'] +} \ No newline at end of file diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..672c1a8 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,15 @@ +apply from: "./loadProps.gradle" + +repositories { + mavenCentral() + maven { url "https://repo.grails.org/grails/core" } + maven { + url = 'https://repo.gradle.org/gradle/libs-releases' + description = 'Needed for Gradle Tooling API' + } +} +dependencies { + implementation "com.bertramlabs.plugins:asset-pipeline-gradle:${assetPipelineGrailVersion}" + implementation "org.grails:grails-gradle-plugin:${grailsVersion}" + implementation "org.gradle:gradle-tooling-api:${gradleToolingApiVersion}" +} \ No newline at end of file diff --git a/buildSrc/loadProps.gradle b/buildSrc/loadProps.gradle new file mode 100644 index 0000000..dd52697 --- /dev/null +++ b/buildSrc/loadProps.gradle @@ -0,0 +1,8 @@ +Properties properties = new Properties() +FileInputStream input = new FileInputStream(file("${rootDir.parentFile}/gradle.properties")) +properties.load(input) +input.close() + +for (String key : properties.stringPropertyNames()) { + ext.set(key, properties.getProperty(key)) +} diff --git a/examples/redis-demo/build.gradle b/examples/redis-demo/build.gradle index ebf23cb..415ea08 100644 --- a/examples/redis-demo/build.gradle +++ b/examples/redis-demo/build.gradle @@ -1,28 +1,27 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "com.bertramlabs.plugins:asset-pipeline-gradle:4.3.0" - } -} - -version "0.1" -group "com.example" -apply plugin: "war" -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: "org.grails.grails-web" -apply plugin:"com.bertramlabs.asset-pipeline" -apply plugin: "org.grails.grails-gsp" +plugins { + id "war" + id 'eclipse' + id 'idea' + id "org.grails.grails-web" + id "com.bertramlabs.asset-pipeline" + id "org.grails.grails-gsp" + id "application" +} +version = project.projectVersion +group = "com.example" assets { minifyJs = true minifyCss = true } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + repositories { mavenCentral() maven { url "https://repo.grails.org/grails/core" } @@ -31,9 +30,10 @@ repositories { dependencies { implementation "org.springframework.boot:spring-boot-starter-logging" implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "org.grails:grails-core" implementation "org.springframework.boot:spring-boot-starter-actuator" implementation "org.springframework.boot:spring-boot-starter-tomcat" + implementation "org.grails:grails-core" + implementation "org.grails:grails-web-boot" implementation "org.grails:grails-logging" implementation "org.grails:grails-plugin-rest" @@ -43,42 +43,35 @@ dependencies { implementation "org.grails:grails-plugin-url-mappings" implementation "org.grails:grails-plugin-interceptors" - implementation "org.grails.plugins:cache:5.0.1" - implementation "org.grails.plugins:async" - implementation "org.grails.plugins:scaffolding" - implementation "org.grails.plugins:events" - implementation "org.grails.plugins:hibernate5" - implementation "org.hibernate:hibernate-core:5.4.18.Final" + implementation "org.grails.plugins:cache:$cacheVersion" + implementation "org.grails.plugins:async:$asyncVersion" + implementation "org.grails.plugins:hibernate5:$gormVersion" + implementation "org.hibernate:hibernate-core-jakarta:$hibernate5Version" implementation project(':grails-redis') implementation "org.grails.plugins:gsp" console "org.grails:grails-console" profile "org.grails.profiles:web" - runtimeOnly "org.glassfish.web:el-impl:2.1.2-b03" - runtimeOnly "com.h2database:h2" + runtimeOnly "org.glassfish.expressly:expressly:$expresslyVersion" + runtimeOnly "com.h2database:h2:$h2Version" runtimeOnly "org.apache.tomcat:tomcat-jdbc" - runtimeOnly "javax.xml.bind:jaxb-api:2.3.1" - runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:4.3.0" - + runtimeOnly "jakarta.xml.bind:jakarta.xml.bind-api:$xmlBindApiVersion" + runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:$assetPipelineGrailVersion" testImplementation "org.grails:grails-gorm-testing-support" testImplementation "org.mockito:mockito-core" testImplementation "org.grails:grails-web-testing-support" } -bootRun { - ignoreExitValue true - jvmArgs( - '-Dspring.output.ansi.enabled=always', - '-noverify', - '-XX:TieredStopAtLevel=1', - '-Xmx1024m') - sourceResources sourceSets.main - String springProfilesActive = 'spring.profiles.active' - systemProperty springProfilesActive, System.getProperty(springProfilesActive) +application { + mainClass.set("com.example.Application") } assets { minifyJs = true minifyCss = true } + +test { + useJUnitPlatform() +} diff --git a/examples/redis-demo/grails-app/conf/application.yml b/examples/redis-demo/grails-app/conf/application.yml index dac862c..9ef6b14 100644 --- a/examples/redis-demo/grails-app/conf/application.yml +++ b/examples/redis-demo/grails-app/conf/application.yml @@ -87,21 +87,22 @@ dataSource: jmxExport: true driverClassName: org.h2.Driver username: sa - password: + password: '' + dialect: org.hibernate.dialect.H2Dialect environments: development: dataSource: - dbCreate: create-drop - url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE + dbCreate: create-drop + url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE test: dataSource: dbCreate: update - url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE + url: jdbc:h2:mem:testDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE production: dataSource: dbCreate: update - url: jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE + url: jdbc:h2:prodDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE properties: jmxEnabled: true initialSize: 5 diff --git a/examples/redis-demo/grails-app/conf/logback-spring.xml b/examples/redis-demo/grails-app/conf/logback-spring.xml new file mode 100644 index 0000000..725d75e --- /dev/null +++ b/examples/redis-demo/grails-app/conf/logback-spring.xml @@ -0,0 +1,13 @@ + + + + + UTF-8 + %level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/examples/redis-demo/grails-app/conf/logback.groovy b/examples/redis-demo/grails-app/conf/logback.groovy deleted file mode 100644 index 5b2d1e3..0000000 --- a/examples/redis-demo/grails-app/conf/logback.groovy +++ /dev/null @@ -1,28 +0,0 @@ -import grails.util.BuildSettings -import grails.util.Environment - - -// See http://logback.qos.ch/manual/groovy.html for details on configuration -appender('STDOUT', ConsoleAppender) { - encoder(PatternLayoutEncoder) { - pattern = "%level %logger - %msg%n" - } -} - -root(ERROR, ['STDOUT']) - -if(Environment.current == Environment.DEVELOPMENT) { - def targetDir = BuildSettings.TARGET_DIR - if(targetDir) { - - appender("FULL_STACKTRACE", FileAppender) { - - file = "${targetDir}/stacktrace.log" - append = true - encoder(PatternLayoutEncoder) { - pattern = "%level %logger - %msg%n" - } - } - logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false ) - } -} diff --git a/examples/redis-demo/grails-app/controllers/com/example/IndexController.groovy b/examples/redis-demo/grails-app/controllers/com/example/IndexController.groovy new file mode 100644 index 0000000..8ba8a11 --- /dev/null +++ b/examples/redis-demo/grails-app/controllers/com/example/IndexController.groovy @@ -0,0 +1,11 @@ +package com.example + +class IndexController { + + BookCreateService bookCreateService + + def index() { + render view: "/index", model: [book:bookCreateService.createOrGetBook()] + } + +} diff --git a/examples/redis-demo/grails-app/controllers/com/example/UrlMappings.groovy b/examples/redis-demo/grails-app/controllers/com/example/UrlMappings.groovy index 9979bfb..efc2a2b 100644 --- a/examples/redis-demo/grails-app/controllers/com/example/UrlMappings.groovy +++ b/examples/redis-demo/grails-app/controllers/com/example/UrlMappings.groovy @@ -9,7 +9,7 @@ class UrlMappings { } } - "/"(view:"/index") + "/"(controller: "index", action: "index") "500"(view:'/error') } } diff --git a/examples/redis-demo/grails-app/domain/com/example/Book.groovy b/examples/redis-demo/grails-app/domain/com/example/Book.groovy index b217b2f..2178b69 100644 --- a/examples/redis-demo/grails-app/domain/com/example/Book.groovy +++ b/examples/redis-demo/grails-app/domain/com/example/Book.groovy @@ -1,55 +1,28 @@ package com.example +import grails.plugins.redis.RedisService import groovy.transform.ToString +import java.time.LocalDate -@ToString(includes = "id") +@ToString(includes = "id,createDate") class Book { - transient redisService + RedisService redisService String title = '' - Date createDate = new Date() + LocalDate createDate = LocalDate.now() + static transients = ['redisService'] + + static mapping = { + autowire true + } //todo: FIX THESE ASAP! // @Memoize(key = '#{title}') - def getMemoizedTitle(Date date) { - "$title $date" + def getMemoizedTitle(LocalDate date) { + redisService?.memoize(title) { + println 'cache miss' + "$title $date" + } } -} - -//todo: get the ast to do this because this seems to work. -//import grails.plugins.redis.RedisService -//import grails.util.Holders -// -//class Book { -// -// RedisService redisService -// -// static transients = ['redisService', 'redisTitle'] -// -// String title = '' -// Date createDate = new Date() -// String redisTitle = getMemoizedTitle(createDate) -// -// def getMemoizedTitle(Date date) { -// getRedisService()?.memoize(title) { -// println 'cache miss' -// "$title $date" -// } -// } -// -// def getRedisService() { -// return Holders?.findApplicationContext()?.getBean('redisService') -// } -// -// -// @Override -// public String toString() { -// return "Book{" + -// "redisTitle='" + redisTitle + '\'' + -// ", createDate=" + createDate + -// ", title='" + title + '\'' + -// ", id=" + id + -// '}'; -// } -//} +} \ No newline at end of file diff --git a/examples/redis-demo/grails-app/init/com/example/Application.groovy b/examples/redis-demo/grails-app/init/com/example/Application.groovy index 1c6520d..f88e4ca 100644 --- a/examples/redis-demo/grails-app/init/com/example/Application.groovy +++ b/examples/redis-demo/grails-app/init/com/example/Application.groovy @@ -2,7 +2,9 @@ package com.example import grails.boot.GrailsApp import grails.boot.config.GrailsAutoConfiguration +import groovy.transform.CompileStatic +@CompileStatic class Application extends GrailsAutoConfiguration { static void main(String[] args) { GrailsApp.run(Application) diff --git a/examples/redis-demo/grails-app/services/com/example/BookCreateService.groovy b/examples/redis-demo/grails-app/services/com/example/BookCreateService.groovy new file mode 100644 index 0000000..3ebd051 --- /dev/null +++ b/examples/redis-demo/grails-app/services/com/example/BookCreateService.groovy @@ -0,0 +1,12 @@ +package com.example + +import grails.gorm.transactions.Transactional + +@Transactional +class BookCreateService { + Book createOrGetBook() { + Book b = Book.findOrCreateByTitle('some title') + b.save(flush:true) + } + +} diff --git a/examples/redis-demo/grails-app/services/com/example/BookService.groovy b/examples/redis-demo/grails-app/services/com/example/BookService.groovy index cf1fc3c..d62f0cd 100644 --- a/examples/redis-demo/grails-app/services/com/example/BookService.groovy +++ b/examples/redis-demo/grails-app/services/com/example/BookService.groovy @@ -1,6 +1,7 @@ package com.example import grails.plugins.redis.* +import java.time.LocalDate class BookService { @@ -32,12 +33,13 @@ class BookService { @MemoizeDomainObject(key = '#{title}', clazz = Book.class) - def createDomainObject(String title, Date date) { + def createDomainObject(String title, LocalDate date) { println 'cache miss createDomainObject' def book = new Book(title: title, createDate: date).save(flush: true) book } + @MemoizeDomainList(key = 'getDomainListWithKeyClass:#{title}', clazz = Book.class) def getDomainListWithKeyClass(String title, Date date) { redisService.domainListWithKeyClassKey = "$title $date" diff --git a/examples/redis-demo/grails-app/views/error.gsp b/examples/redis-demo/grails-app/views/error.gsp index e95a720..a101156 100644 --- a/examples/redis-demo/grails-app/views/error.gsp +++ b/examples/redis-demo/grails-app/views/error.gsp @@ -10,8 +10,8 @@ - - + +
    diff --git a/examples/redis-demo/grails-app/views/index.gsp b/examples/redis-demo/grails-app/views/index.gsp index 19b6e45..4b31dce 100644 --- a/examples/redis-demo/grails-app/views/index.gsp +++ b/examples/redis-demo/grails-app/views/index.gsp @@ -6,10 +6,6 @@ Welcome to Grails - <% - def book = new Book(title: 'some title') - book.save(flush: true) - %> ${book.toString()} diff --git a/examples/redis-demo/src/test/groovy/com/example/MemoizeAnnotationSpec.groovy b/examples/redis-demo/src/test/groovy/com/example/MemoizeAnnotationSpec.groovy index d3502d9..ded28b6 100644 --- a/examples/redis-demo/src/test/groovy/com/example/MemoizeAnnotationSpec.groovy +++ b/examples/redis-demo/src/test/groovy/com/example/MemoizeAnnotationSpec.groovy @@ -36,10 +36,10 @@ class TestClass{ String testExpire = "1000" when: - def testInstance = testClass.newInstance() + def testInstance = testClass.getDeclaredConstructor().newInstance() // inject redis service -// testInstance.redisService = redisService + testInstance.redisService = redisService testInstance.key = testKey testInstance.expire = testExpire diff --git a/examples/redis-demo/src/test/groovy/com/example/ProxyAwareSpec.groovy b/examples/redis-demo/src/test/groovy/com/example/ProxyAwareSpec.groovy index c23193a..c0a6ac0 100644 --- a/examples/redis-demo/src/test/groovy/com/example/ProxyAwareSpec.groovy +++ b/examples/redis-demo/src/test/groovy/com/example/ProxyAwareSpec.groovy @@ -1,13 +1,10 @@ package com.example -import grails.core.support.proxy.ProxyHandler - trait ProxyAwareSpec { - ProxyHandler proxyHandler Serializable getEntityId(Object obj) { - Serializable identifier = proxyHandler.getIdentifier(obj) + Serializable identifier = proxyHandler.unwrapIfProxy(obj)?.ident() identifier ?: obj?.id } diff --git a/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeDomainSpec.groovy b/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeDomainSpec.groovy index 7679750..885e3c8 100644 --- a/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeDomainSpec.groovy +++ b/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeDomainSpec.groovy @@ -4,12 +4,11 @@ import grails.gorm.transactions.Rollback import grails.plugins.redis.RedisService import grails.testing.mixin.integration.Integration import org.springframework.beans.factory.annotation.Autowired -import spock.lang.Ignore import spock.lang.Specification +import java.time.LocalDate @Integration @Rollback -@Ignore class RedisMemoizeDomainSpec extends Specification { @Autowired RedisService redisService @@ -21,8 +20,8 @@ class RedisMemoizeDomainSpec extends Specification { def "get AST transformed domain object method"() { given: def title = 'all the things' - def date1 = new Date() - def date2 = new Date() + 1 + LocalDate date1 = LocalDate.now() + LocalDate date2 = date1.plusDays(1) Book book = new Book(title: title).save(flush: true) when: diff --git a/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeServiceSpec.groovy b/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeServiceSpec.groovy index de79371..e4207d9 100644 --- a/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeServiceSpec.groovy +++ b/examples/redis-demo/src/test/groovy/com/example/RedisMemoizeServiceSpec.groovy @@ -4,9 +4,9 @@ import grails.gorm.transactions.Rollback import grails.plugins.redis.RedisService import grails.testing.mixin.integration.Integration import groovy.time.TimeCategory -import groovy.transform.CompileStatic import org.springframework.beans.factory.annotation.Autowired import spock.lang.Specification +import java.time.LocalDate @Integration @Rollback @@ -126,7 +126,7 @@ class RedisMemoizeServiceSpec extends Specification { def "get AST transformed domain object using title"() { given: String title = 'ted' - Date date = new Date() + LocalDate date = LocalDate.now() when: Book book = bookService.createDomainObject(title, date) @@ -183,8 +183,8 @@ class RedisMemoizeServiceSpec extends Specification { def "get AST transformed method using object property key"() { given: def title = 'narwhals' - Date date = new Date() - Book book = new Book(title: title, createDate: date).save(flush: true) + LocalDate date = LocalDate.now() + Book book = new Book(title: title, createDate: date).save(flush: true, failOnError:true) def bookString1 = book.toString() when: 'get the initial value and cache it' @@ -269,6 +269,10 @@ class RedisMemoizeServiceSpec extends Specification { value2 != "$text $date2" } + private LocalDate plusDays(LocalDate date, Integer number) { + date.plusDays(number) + } + private Date plusDays(Date date, Integer number) { use(TimeCategory) { return (date + number.days) diff --git a/gradle.properties b/gradle.properties index 9c9a35d..3009bca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,24 @@ projectVersion=5.0.0-SNAPSHOT -grailsVersion=6.1.1 -grailsGradlePluginVersion=6.1.1 + +assetPipelineGrailVersion=5.0.1 +asyncVersion=6.0.0-SNAPSHOT +cacheVersion=8.0.0-SNAPSHOT +commonsPool2Version=2.12.0 +expresslyVersion=5.0.0 +gradleToolingApiVersion=8.10.2 +grailsGradlePluginVersion=7.0.0-SNAPSHOT +grailsVersion=7.0.0-SNAPSHOT +gormVersion=9.0.0-SNAPSHOT +groovyVersion=4.0.23 +gsonVersion=2.11.0 +h2Version=2.3.232 +hibernate5Version=5.6.15.Final +javaParserCoreVersion=3.25.10 +jredisVersion=5.2.0 +scaffoldingVersion=6.0.0-SNAPSHOT +xmlBindApiVersion=4.0.2 + org.gradle.caching=true org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M -commons-pool2.version=2.11.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b1624c4..5c40527 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-7.6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..b218eff 100755 --- a/gradlew +++ b/gradlew @@ -15,7 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # # Gradle start up script for POSIX generated by Gradle. @@ -55,7 +56,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,10 +84,9 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +133,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +147,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +200,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/plugin/build.gradle b/plugin/build.gradle index 1cbcaaa..cdfd099 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -1,33 +1,17 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - } -} - plugins { - id 'maven-publish' - id 'idea' - id 'eclipse' - id 'signing' - id 'java-library' + id "java-library" + id "eclipse" + id "idea" + id "org.grails.grails-plugin" } -apply plugin: 'signing' -apply plugin: "org.grails.grails-plugin" -apply plugin: "org.grails.grails-gsp" - -version project.projectVersion -group "org.grails.plugins" +version = project.projectVersion +group = "org.grails.plugins" -sourceCompatibility = 1.11 -targetCompatibility = 1.11 - -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } } dependencyManagement { @@ -41,11 +25,16 @@ configurations { documentation.extendsFrom compileClasspath all { resolutionStrategy { - force 'org.apache.commons:commons-pool2:2.12.0' + force "org.apache.commons:commons-pool2:$commonsPool2Version" } } } +repositories { + mavenCentral() + maven { url "https://repo.grails.org/grails/core" } +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-logging' implementation "org.springframework.boot:spring-boot-starter-actuator" @@ -56,91 +45,21 @@ dependencies { testImplementation 'org.grails:grails-web-testing-support' - console "org.grails:grails-console" + implementation "org.grails:grails-console" - api 'redis.clients:jedis:5.1.0' - api 'com.google.code.gson:gson:2.10.1' + api "redis.clients:jedis:$jredisVersion" + api "com.google.code.gson:gson:$gsonVersion" - documentation('com.github.javaparser:javaparser-core:3.25.7') { + documentation("com.github.javaparser:javaparser-core:$javaParserCoreVersion") { transitive = false } } -groovydoc { - groovyClasspath += configurations.documentation +test { + useJUnitPlatform() } jar { exclude "application.groovy" exclude "src/test/projects/**" } - -publishing { - - if (isSnapshot) { - repositories { - maven { - credentials { - def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : '' - def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : '' - username = u - password = p - } - url "https://repo.grails.org/grails/plugins3-snapshots-local" - } - } - } - - publications { - maven(MavenPublication) { - - groupId = project.group - version = project.version - - from components.java - - artifact sourcesJar - artifact javadocJar - - pom { - name = 'Grails Redis Plugin' - description = 'This Plugin provides access to Redis and various utilities(service, annotations, etc) for caching.' - url = 'https://github.com/grails/grails-redis' - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id = 'ctoestreich' - name = 'Christian Oestreich' - } - developer { - id = 'puneetbehl' - name = 'Puneet Behl' - email = 'behlp@unityfoundation.io' - } - } - scm { - connection = 'scm:git:git://github.com/grails/grails-redis.git' - developerConnection = 'scm:git:ssh://github.com:/grails/grails-redis.git' - url = 'https://github.com/grails/grails-redis/' - } - } - } - } -} - -if (isReleaseVersion) { - afterEvaluate { - signing { - sign publishing.publications.maven - } - } -} - -tasks.withType(Sign) { - onlyIf { isReleaseVersion } -} diff --git a/plugin/grails-app/conf/logback-spring.xml b/plugin/grails-app/conf/logback-spring.xml new file mode 100644 index 0000000..725d75e --- /dev/null +++ b/plugin/grails-app/conf/logback-spring.xml @@ -0,0 +1,13 @@ + + + + + UTF-8 + %level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/plugin/grails-app/conf/logback.groovy b/plugin/grails-app/conf/logback.groovy deleted file mode 100644 index 5b2d1e3..0000000 --- a/plugin/grails-app/conf/logback.groovy +++ /dev/null @@ -1,28 +0,0 @@ -import grails.util.BuildSettings -import grails.util.Environment - - -// See http://logback.qos.ch/manual/groovy.html for details on configuration -appender('STDOUT', ConsoleAppender) { - encoder(PatternLayoutEncoder) { - pattern = "%level %logger - %msg%n" - } -} - -root(ERROR, ['STDOUT']) - -if(Environment.current == Environment.DEVELOPMENT) { - def targetDir = BuildSettings.TARGET_DIR - if(targetDir) { - - appender("FULL_STACKTRACE", FileAppender) { - - file = "${targetDir}/stacktrace.log" - append = true - encoder(PatternLayoutEncoder) { - pattern = "%level %logger - %msg%n" - } - } - logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false ) - } -} diff --git a/plugin/src/main/groovy/redis/RedisGrailsPlugin.groovy b/plugin/src/main/groovy/redis/RedisGrailsPlugin.groovy index 46d2abe..1872099 100644 --- a/plugin/src/main/groovy/redis/RedisGrailsPlugin.groovy +++ b/plugin/src/main/groovy/redis/RedisGrailsPlugin.groovy @@ -10,7 +10,7 @@ import redis.clients.jedis.Protocol class RedisGrailsPlugin extends Plugin { - def grailsVersion = "3.0.0 > *" + def grailsVersion = "7.0.0-SNAPSHOT > *" def pluginExcludes = [ "codenarc.properties", "grails-app/conf/**", @@ -44,7 +44,7 @@ class RedisGrailsPlugin extends Plugin { Closure doWithSpring() { { -> - def redisConfigMap = grailsApplication.config.grails.redis ?: [:] + def redisConfigMap = grailsApplication.config.getProperty('grails.redis') ?: [:] RedisConfigurationUtil.configureService(delegate, redisConfigMap, "", RedisService) redisConfigMap?.connections?.each { connection -> diff --git a/plugin/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy b/plugin/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy index d139552..c5ee188 100644 --- a/plugin/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy +++ b/plugin/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy @@ -21,7 +21,7 @@ class RedisTagLibSpec extends Specification { def setup() { redisService.flushDB() - tagLib = grailsApplication.mainContext.getBean(RedisTagLib) + tagLib= grailsApplication.mainContext.getBean(RedisTagLib) } @Ignore diff --git a/settings.gradle b/settings.gradle index d517cfc..284801e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,35 +1,44 @@ plugins { - id "com.gradle.enterprise" version "3.16.1" - id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.12.1' + id "com.gradle.develocity" version "3.18.1" + id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2' } -gradleEnterprise { +def isCI = System.getenv('CI') != null +def isLocal = !isCI +def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null +def isBuildCacheAuthenticated = + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null && + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null + +develocity { server = 'https://ge.grails.org' buildScan { - publishAlways() - publishIfAuthenticated() - uploadInBackground = System.getenv("CI") == null - capture { - taskInputFiles = true - } + publishing.onlyIf { isAuthenticated } + uploadInBackground = isLocal } - } buildCache { - local { enabled = System.getenv('CI') != 'true' } - remote(gradleEnterprise.buildCache) { - def isAuthenticated = System.getenv('GRADLE_ENTERPRISE_ACCESS_KEY') - push = System.getenv('CI') == 'true' && isAuthenticated + local { enabled = isLocal } + remote(develocity.buildCache) { + push = isCI && isBuildCacheAuthenticated enabled = true - }} + usernameAndPassword( + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '', + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: '' + ) + } +} +rootProject.name = "grails-redis" include "examples-redis-demo" -project(":examples-redis-demo").projectDir = new File(settingsDir, "examples/redis-demo") - include 'plugin' + +project(":examples-redis-demo").projectDir = [settingsDir, 'examples/redis-demo'] as File + + findProject(':plugin').name = 'grails-redis' -rootProject.name = "grails-redis" +