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()}