Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 7c1506e

Browse files
committed
chore: Cleanup examples-grails-hibernate-groovy-proxy
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config. - `logback.xml`: Correct faulty pattern - `Customer`: Add no-args constructor needed for proxying - `ProxySpec`: Remove unused imports - `Application`: Remove unused imports and old comment - `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied. Change version variable name from `hibernateGroovyProxy` to `yakworksHibernateGroovyProxyVersion`.
1 parent b248f4e commit 7c1506e

File tree

9 files changed

+35
-42
lines changed

9 files changed

+35
-42
lines changed
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
group "examples"
2-
3-
dependencies {
4-
implementation "org.yakworks:hibernate-groovy-proxy:$hibernateGroovyProxy"
1+
plugins {
2+
id 'groovy'
3+
id 'org.grails.grails-web'
4+
}
55

6-
implementation "org.springframework.boot:spring-boot-starter-logging"
7-
implementation "org.springframework.boot:spring-boot-autoconfigure"
8-
implementation "org.grails:grails-core"
9-
implementation "org.grails:grails-dependencies", {
10-
exclude module:'grails-datastore-simple'
11-
}
12-
implementation "org.grails:grails-web-boot"
13-
implementation project(":grails-plugin")
6+
version = rootProject.version
7+
group = 'examples'
148

15-
implementation "org.hibernate:hibernate-core-jakarta:$hibernateVersion"
9+
dependencies {
1610

17-
runtimeOnly "com.h2database:h2"
18-
runtimeOnly "org.yaml:snakeyaml"
19-
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
11+
implementation project(':grails-plugin')
12+
implementation 'org.grails:grails-core'
13+
implementation "org.yakworks:hibernate-groovy-proxy:$yakworksHibernateGroovyProxyVersion"
2014

21-
testImplementation "org.grails:grails-gorm-testing-support"
15+
runtimeOnly 'com.h2database:h2'
16+
runtimeOnly 'com.zaxxer:HikariCP'
17+
runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure'
18+
runtimeOnly 'org.springframework.boot:spring-boot-starter-logging'
2219

23-
}
20+
testImplementation 'org.grails:grails-testing-support'
21+
}

examples/grails-hibernate-groovy-proxy/grails-app/conf/application.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1+
info:
2+
app:
3+
name: '@info.app.name@'
4+
version: '@info.app.version@'
5+
grailsVersion: '@info.app.grailsVersion@'
16
---
27
grails:
3-
profile: web
4-
codegen:
5-
defaultPackage: datasources
6-
info:
7-
app:
8-
name: '@info.app.name@'
9-
version: '@info.app.version@'
10-
grailsVersion: '@info.app.grailsVersion@'
11-
spring:
12-
groovy:
13-
template:
14-
check-template-location: false
15-
main:
16-
allow-circular-references: true
17-
8+
profile: web
9+
codegen:
10+
defaultPackage: datasources
1811
---
1912
dataSource:
2013
pooled: true
21-
jmxExport: true
2214
driverClassName: org.h2.Driver
2315
dbCreate: create-drop
2416
url: jdbc:h2:mem:books;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE

examples/grails-hibernate-groovy-proxy/grails-app/conf/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
88
<encoder>
99
<charset>UTF-8</charset>
10-
<pattern>'%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex'</pattern>
10+
<pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
1111
</encoder>
1212
</appender>
1313

examples/grails-hibernate-groovy-proxy/grails-app/domain/example/Customer.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ class Customer implements Serializable {
99

1010
String name
1111

12+
@SuppressWarnings('unused')
13+
Customer() {
14+
// no-args constructor for proxying.
15+
// Usually added by ControllerDomainTransformer
16+
// from 'org.grails:grails-plugin-controllers'
17+
}
18+
1219
Customer(Long id, String name) {
1320
this.id = id
1421
this.name = name

examples/grails-hibernate-groovy-proxy/grails-app/init/datasources/Application.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ package datasources
33
import grails.boot.GrailsApp
44
import grails.boot.config.GrailsAutoConfiguration
55
import groovy.transform.CompileStatic
6-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
7-
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
86

9-
//@EnableAutoConfiguration(exclude = DataSourceTransactionManagerAutoConfiguration)
107
@CompileStatic
118
class Application extends GrailsAutoConfiguration {
129
static void main(String[] args) {

examples/grails-hibernate-groovy-proxy/src/test/groovy/example/ProxySpec.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.hibernate.Hibernate
44

55
import grails.gorm.transactions.Rollback
66
import grails.test.hibernate.HibernateSpec
7-
import spock.lang.Ignore
87

98
/**
109
* Tests Proxy with hibernate-groovy-proxy

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ groovydocGradlePluginVersion=1.0.1
1111
groovyVersion=4.0.24-SNAPSHOT
1212
hibernateVersion=5.6.15.Final
1313
hibernateValidatorVersion=8.0.1.Final
14-
hibernateGroovyProxy=1.1
14+
yakworksHibernateGroovyProxyVersion=1.1
1515
jansiVersion=2.4.1
1616
javaParserCoreVersion=3.26.2
1717
junitJupiterVersion=5.11.3

grails-datastore-gorm-hibernate5/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies {
4343
testImplementation "org.hibernate:hibernate-ehcache:$hibernateVersion"
4444

4545
// groovy proxy fixes bytebuddy to be a bit smarter when it comes to groovy metaClass
46-
testImplementation "org.yakworks:hibernate-groovy-proxy:$hibernateGroovyProxy"
46+
testImplementation "org.yakworks:hibernate-groovy-proxy:$yakworksHibernateGroovyProxyVersion"
4747

4848
testImplementation "org.apache.tomcat:tomcat-jdbc:$tomcatVersion"
4949
testRuntimeOnly "org.springframework:spring-aop"

grails-datastore-gorm-hibernate5/src/test/groovy/grails/gorm/tests/proxy/ByteBuddyProxySpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ByteBuddyProxySpec extends GormDatastoreSpec {
1717
static HibernateProxyHandler proxyHandler = new HibernateProxyHandler()
1818

1919
//to show test that fail that should succeed set this to true. or uncomment the
20-
// testImplementation "org.yakworks:hibernate-groovy-proxy:$hibernateGroovyProxy" to see pass
20+
// testImplementation "org.yakworks:hibernate-groovy-proxy:$yakworksHibernateGroovyProxy" to see pass
2121
boolean runPending = ClassUtils.isPresent("yakworks.hibernate.proxy.ByteBuddyGroovyInterceptor")
2222

2323
@Override

0 commit comments

Comments
 (0)