Skip to content

Commit

Permalink
chore: Cleanup examples-grails-hibernate-groovy-proxy
Browse files Browse the repository at this point in the history
- `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`.
  • Loading branch information
matrei committed Nov 7, 2024
1 parent a1f9269 commit cf563bf
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 42 deletions.
34 changes: 16 additions & 18 deletions examples/grails-hibernate-groovy-proxy/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
group "examples"

dependencies {
implementation "org.yakworks:hibernate-groovy-proxy:$hibernateGroovyProxy"
plugins {
id 'groovy'
id 'org.grails.grails-web'
}

implementation "org.springframework.boot:spring-boot-starter-logging"
implementation "org.springframework.boot:spring-boot-autoconfigure"
implementation "org.grails:grails-core"
implementation "org.grails:grails-dependencies", {
exclude module:'grails-datastore-simple'
}
implementation "org.grails:grails-web-boot"
implementation project(":grails-plugin")
version = rootProject.version
group = 'examples'

implementation "org.hibernate:hibernate-core-jakarta:$hibernateVersion"
dependencies {

runtimeOnly "com.h2database:h2"
runtimeOnly "org.yaml:snakeyaml"
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
implementation project(':grails-plugin')
implementation 'org.grails:grails-core'
implementation "org.yakworks:hibernate-groovy-proxy:$yakworksHibernateGroovyProxyVersion"

testImplementation "org.grails:grails-gorm-testing-support"
runtimeOnly 'org.springframework.boot:spring-boot-starter-logging'
runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.zaxxer:HikariCP'

}
testImplementation 'org.grails:grails-gorm-testing-support'
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
---
grails:
profile: web
codegen:
defaultPackage: datasources
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
groovy:
template:
check-template-location: false
main:
allow-circular-references: true

profile: web
codegen:
defaultPackage: datasources
---
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
dbCreate: create-drop
url: jdbc:h2:mem:books;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<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>
<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>
</encoder>
</appender>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class Customer implements Serializable {

String name

@SuppressWarnings('unused')
Customer() {
// no-args constructor for proxying.
// Usually added by ControllerDomainTransformer
// from 'org.grails:grails-plugin-controllers'
}

Customer(Long id, String name) {
this.id = id
this.name = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package datasources
import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
import groovy.transform.CompileStatic
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration

//@EnableAutoConfiguration(exclude = DataSourceTransactionManagerAutoConfiguration)
@CompileStatic
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.hibernate.Hibernate

import grails.gorm.transactions.Rollback
import grails.test.hibernate.HibernateSpec
import spock.lang.Ignore

/**
* Tests Proxy with hibernate-groovy-proxy
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ groovydocGradlePluginVersion=1.0.1
groovyVersion=4.0.24-SNAPSHOT
hibernateVersion=5.6.15.Final
hibernateValidatorVersion=8.0.1.Final
hibernateGroovyProxy=1.1
yakworksHibernateGroovyProxyVersion=1.1
jansiVersion=2.4.1
javaParserCoreVersion=3.26.2
junitJupiterVersion=5.11.3
Expand Down
2 changes: 1 addition & 1 deletion grails-datastore-gorm-hibernate5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
testImplementation "org.hibernate:hibernate-ehcache:$hibernateVersion"

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

testImplementation "org.apache.tomcat:tomcat-jdbc:$tomcatVersion"
testRuntimeOnly "org.springframework:spring-aop"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ByteBuddyProxySpec extends GormDatastoreSpec {
static HibernateProxyHandler proxyHandler = new HibernateProxyHandler()

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

@Override
Expand Down

0 comments on commit cf563bf

Please sign in to comment.