Skip to content

Commit

Permalink
Groovy 3.0.19 compatibility (#982)
Browse files Browse the repository at this point in the history
* Upgrade to Groovy 3.0.19

* Upgrade to Grails 6.1.1

* Remove explicit gorm.version declaration

* Add ability to resolve Groovy Snapshot versions

* Make compatible with H2 2.2.224

* Make project compatible with Groovy 3.0.19

* Revert to Groovy 3.0.11

* Another compatibility fix for H2 2.2.224

* Templates compatible with Groovy 3.0.19

* Templates compatible with H2 2.2.224

* Templates using updated way to retrieve config values

---------

Co-authored-by: Puneet Behl <[email protected]>
  • Loading branch information
matrei and puneetbehl authored Dec 14, 2023
1 parent f1d0d20 commit f2bb17f
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 15 deletions.
6 changes: 6 additions & 0 deletions examples/functional-test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ group "grails_4_0"
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
if(groovyVersion?.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog Groovy snapshot repo'
url 'https://groovy.jfrog.io/artifactory/libs-snapshot-local/'
}
}
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestUserTestRole implements Serializable {
criteriaFor(testUserId, testRoleId).count()
}

private static DetachedCriteria criteriaFor(long testUserId, long testRoleId) {
private static DetachedCriteria<TestUserTestRole> criteriaFor(long testUserId, long testRoleId) {
TestUserTestRole.where {
testUser == TestUser.load(testUserId) &&
testRole == TestRole.load(testRoleId)
Expand Down
6 changes: 6 additions & 0 deletions examples/integration-test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ group "misc.integration.test.app"
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
if(groovyVersion?.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog Groovy snapshot repo'
url 'https://groovy.jfrog.io/artifactory/libs-snapshot-local/'
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ group "grails.spring.security.group"
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
if(groovyVersion?.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog Groovy snapshot repo'
url 'https://groovy.jfrog.io/artifactory/libs-snapshot-local/'
}
}
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RoleGroupRole implements Serializable {
criteriaFor(roleGroupId, roleId).count()
}

private static DetachedCriteria criteriaFor(long roleGroupId, long roleId) {
private static DetachedCriteria<RoleGroupRole> criteriaFor(long roleGroupId, long roleId) {
RoleGroupRole.where {
roleGroup == RoleGroup.load(roleGroupId) &&
role == Role.load(roleId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class User implements Serializable {
}

static mapping = {
table name: '`user`'
password column: '`password`'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class UserRole implements Serializable {
criteriaFor(userId, roleId).count()
}

private static DetachedCriteria criteriaFor(long userId, long roleId) {
private static DetachedCriteria<UserRole> criteriaFor(long userId, long roleId) {
UserRole.where {
user == User.load(userId) &&
role == Role.load(roleId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UserRoleGroup implements Serializable {
criteriaFor(userId, roleGroupId).count()
}

private static DetachedCriteria criteriaFor(long userId, long roleGroupId) {
private static DetachedCriteria<UserRoleGroup> criteriaFor(long userId, long roleGroupId) {
UserRoleGroup.where {
user == User.load(userId) &&
roleGroup == RoleGroup.load(roleGroupId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ configurations {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
if(groovyVersion?.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog Groovy snapshot repo'
url 'https://groovy.jfrog.io/artifactory/libs-snapshot-local/'
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class User implements Serializable {
}

static mapping = {
table name: '`user`'
password column: '`password`'
}
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ projectVersion=6.1.1-SNAPSHOT
grailsVersion=6.1.1
grailsGradlePluginVersion=6.1.1
groovyVersion=3.0.11
gorm.version=8.0.0
vcsUrl=https://github.com/grails-plugins/grails-spring-security-core
websiteUrl=https://github.com/grails-plugins/grails-spring-security-core
issueTrackerUrl=https://github.com/grails-plugins/grails-spring-security-core/issues
Expand Down
6 changes: 6 additions & 0 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ jar {
repositories {
mavenCentral()
maven { url 'https://repo.grails.org/grails/core' }
if(groovyVersion?.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog Groovy snapshot repo'
url 'https://groovy.jfrog.io/artifactory/libs-snapshot-local/'
}
}
}

dependencyManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ final class SpringSecurityUtils {
continue
}

List<Filter> filters = [] + filterChain.filters // copy
List<Filter> filters = filterChain.filters.collect() // copy
int index = 0
while (index < filters.size() && filterToPosition[filters[index]] < order) {
index++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GrailsSecurityFilterChain implements SecurityFilterChain {
final String matcherPattern

GrailsSecurityFilterChain(String matcherPattern, List<Filter> filters) {
this.filters = [] + filters
this.filters = filters.collect() // copy
this.matcherPattern = matcherPattern
requestMatcher = new AntPathRequestMatcher(matcherPattern, null, false)
log.info 'Creating filter chain: {}, {}', requestMatcher, filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ${groupClassName}${roleClassName} implements Serializable {
criteriaFor(${groupClassProperty}Id, ${roleClassProperty}Id).count()
}

private static DetachedCriteria criteriaFor(long ${groupClassProperty}Id, long ${roleClassProperty}Id) {
private static DetachedCriteria<${groupClassName}${roleClassName}> criteriaFor(long ${groupClassProperty}Id, long ${roleClassProperty}Id) {
${groupClassName}${roleClassName}.where {
${groupClassProperty} == ${groupClassName}.load(${groupClassProperty}Id) &&
${roleClassProperty} == ${roleClassName}.load(${roleClassProperty}Id)
Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/templates/Person.groovy.template
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ${userClassName} implements Serializable {
}

static mapping = {
${'User' == userClassName ? "table name: '`user`'" : ''}
password column: '`password`'
}
}
2 changes: 1 addition & 1 deletion plugin/src/main/templates/PersonAuthority.groovy.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ${userClassName}${roleClassName} implements Serializable {
criteriaFor(${userClassProperty}Id, ${roleClassProperty}Id).count()
}

private static DetachedCriteria criteriaFor(long ${userClassProperty}Id, long ${roleClassProperty}Id) {
private static DetachedCriteria<${userClassName}${roleClassName}> criteriaFor(long ${userClassProperty}Id, long ${roleClassProperty}Id) {
${userClassName}${roleClassName}.where {
${userClassProperty} == ${userClassName}.load(${userClassProperty}Id) &&
${roleClassProperty} == ${roleClassName}.load(${roleClassProperty}Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ${userClassName}${groupClassName} implements Serializable {
criteriaFor(${userClassProperty}Id, ${groupClassProperty}Id).count()
}

private static DetachedCriteria criteriaFor(long ${userClassProperty}Id, long ${groupClassProperty}Id) {
private static DetachedCriteria<${userClassName}${groupClassName}> criteriaFor(long ${userClassProperty}Id, long ${groupClassProperty}Id) {
${userClassName}${groupClassName}.where {
${userClassProperty} == ${userClassName}.load(${userClassProperty}Id) &&
${groupClassProperty} == ${groupClassName}.load(${groupClassProperty}Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ${userClassName}PasswordEncoderListener {

@PostConstruct
void setup() {
algorithm = springSecurityService.grailsApplication.config.get('grails.plugin.springsecurity.password.algorithm')
reflectionSaltProperty = springSecurityService.grailsApplication.config.get('grails.plugin.springsecurity.dao.reflectionSaltSourceProperty')
algorithm = springSecurityService.grailsApplication.config.getProperty('grails.plugin.springsecurity.password.algorithm')
reflectionSaltProperty = springSecurityService.grailsApplication.config.getProperty('grails.plugin.springsecurity.dao.reflectionSaltSourceProperty')
}

@Listener(${userClassName})
Expand Down
5 changes: 3 additions & 2 deletions plugin/src/main/templates/PersonWithSalt.groovy.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class ${userClassName} implements Serializable {
if ( !springSecurityService ) {
return null
}
def algorithm = springSecurityService.grailsApplication.config.grails.plugin.springsecurity.password.algorithm
def algorithm = springSecurityService.grailsApplication.config.getProperty('grails.plugin.springsecurity.password.algorithm')
if ( algorithm == 'bcrypt' || algorithm == 'pbkdf2' ) {
return null
}

def reflectionSaltProperty = springSecurityService.grailsApplication.config.grails.plugin.springsecurity.dao.reflectionSaltSourceProperty
def reflectionSaltProperty = springSecurityService.grailsApplication.config.getProperty('grails.plugin.springsecurity.dao.reflectionSaltSourceProperty')
if ( reflectionSaltProperty ) {
return getProperty(reflectionSaltProperty)
}
Expand All @@ -65,6 +65,7 @@ class ${userClassName} implements Serializable {
}

static mapping = {
${'User' == userClassName ? "table name: '`user`'" : ''}
password column: '`password`'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ${userClassName} implements Serializable {
}

static mapping = {
password column: '`password`'
${'User' == userClassName ? "table name: '`user`'" : ''}
password column: '`password`'
}
}

0 comments on commit f2bb17f

Please sign in to comment.