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

Commit 3c7c79e

Browse files
committed
chore: Cleanup examples-grails3-hibernate5
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config. - `logback.xml`: Correct faulty pattern - `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. - `BookControllerUnitSpec`: Remove unused imports and bean definition of deprecated `MimeTypesGrailsPlugin`.
1 parent 27c6e40 commit 3c7c79e

File tree

6 files changed

+106
-152
lines changed

6 files changed

+106
-152
lines changed
Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
1-
group "examples"
2-
3-
dependencies {
4-
implementation "org.springframework.boot:spring-boot-starter-logging"
5-
implementation "org.springframework.boot:spring-boot-autoconfigure"
6-
implementation "org.springframework.boot:spring-boot-starter-actuator"
7-
implementation "org.springframework.boot:spring-boot-starter-tomcat"
8-
implementation "jakarta.servlet:jakarta.servlet-api"
9-
implementation "org.grails:grails-core"
10-
implementation "org.grails:grails-dependencies", {
11-
exclude module:'grails-datastore-simple'
12-
}
13-
14-
implementation "org.grails:grails-web-boot"
15-
implementation project(":grails-plugin")
16-
17-
implementation "org.hibernate:hibernate-core-jakarta:$hibernateVersion"
18-
implementation "org.hibernate:hibernate-ehcache:$hibernateVersion"
19-
20-
runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails"
21-
runtimeOnly "com.h2database:h2"
22-
runtimeOnly "org.yaml:snakeyaml"
23-
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
24-
runtimeOnly "org.grails.plugins:fields"
25-
runtimeOnly "org.grails.plugins:scaffolding"
26-
27-
testImplementation("org.grails:grails-gorm-testing-support") {
28-
exclude group: "org.spockframework", module: "spock-core"
29-
}
30-
testImplementation("org.grails:grails-web-testing-support") {
31-
exclude group: "org.spockframework", module: "spock-core"
32-
}
33-
34-
integrationTestImplementation testFixtures("org.grails.plugins:geb")
1+
plugins {
2+
id 'com.bertramlabs.asset-pipeline' version '5.0.1'
3+
id 'groovy'
4+
id 'org.grails.grails-gsp'
5+
id 'org.grails.grails-web'
356
}
367

8+
version = rootProject.version
9+
group = 'examples'
10+
11+
dependencies {
3712

38-
//compileGroovy.groovyOptions.fork = true
39-
//compileGroovy.groovyOptions.forkOptions.jvmArgs = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005']
13+
implementation project(':grails-plugin')
14+
implementation 'jakarta.persistence:jakarta.persistence-api'
15+
implementation 'jakarta.validation:jakarta.validation-api'
16+
implementation 'org.grails:grails-core'
17+
implementation 'org.grails:grails-plugin-rest'
18+
implementation 'org.grails.plugins:gsp'
19+
20+
runtimeOnly 'com.bertramlabs.plugins:asset-pipeline-grails'
21+
runtimeOnly 'com.h2database:h2'
22+
runtimeOnly 'com.zaxxer:HikariCP'
23+
runtimeOnly 'org.grails.plugins:fields'
24+
runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure'
25+
runtimeOnly 'org.springframework.boot:spring-boot-starter-logging'
26+
runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'
27+
28+
testImplementation 'org.grails:grails-testing-support'
29+
testImplementation 'org.grails:grails-gorm-testing-support'
30+
testImplementation 'org.grails:grails-web-testing-support'
31+
32+
integrationTestImplementation testFixtures('org.grails.plugins:geb')
33+
}
Lines changed: 73 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,87 @@
1-
---
2-
grails:
3-
profile: web
4-
codegen:
5-
defaultPackage: functional.tests
61
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-
2+
app:
3+
name: '@info.app.name@'
4+
version: '@info.app.version@'
5+
grailsVersion: '@info.app.grailsVersion@'
186
---
197
grails:
20-
mime:
21-
disable:
22-
accept:
23-
header:
24-
userAgents:
25-
- Gecko
26-
- WebKit
27-
- Presto
28-
- Trident
29-
types:
30-
all: '*/*'
31-
atom: application/atom+xml
32-
css: text/css
33-
csv: text/csv
34-
form: application/x-www-form-urlencoded
35-
html:
36-
- text/html
37-
- application/xhtml+xml
38-
js: text/javascript
39-
json:
40-
- application/json
41-
- text/json
42-
multipartForm: multipart/form-data
43-
pdf: application/pdf
44-
rss: application/rss+xml
45-
text: text/plain
46-
hal:
47-
- application/hal+json
48-
- application/hal+xml
49-
xml:
50-
- text/xml
51-
- application/xml
8+
profile: web
9+
codegen:
10+
defaultPackage: functional.tests
11+
mime:
12+
disable:
13+
accept:
14+
header:
15+
userAgents:
16+
- Gecko
17+
- WebKit
18+
- Presto
19+
- Trident
20+
types:
21+
all: '*/*'
22+
atom: application/atom+xml
23+
css: text/css
24+
csv: text/csv
25+
form: application/x-www-form-urlencoded
26+
html:
27+
- text/html
28+
- application/xhtml+xml
29+
js: text/javascript
30+
json:
31+
- application/json
32+
- text/json
33+
multipartForm: multipart/form-data
34+
pdf: application/pdf
35+
rss: application/rss+xml
36+
text: text/plain
37+
hal:
38+
- application/hal+json
39+
- application/hal+xml
40+
xml:
41+
- text/xml
42+
- application/xml
5243
urlmapping:
53-
cache:
54-
maxsize: 1000
55-
controllers:
56-
defaultScope: singleton
44+
cache:
45+
maxsize: 1000
5746
converters:
58-
encoding: UTF-8
47+
encoding: UTF-8
5948
views:
60-
default:
61-
codec: html
62-
gsp:
63-
encoding: UTF-8
64-
htmlcodec: xml
65-
codecs:
66-
expression: html
67-
scriptlets: html
68-
taglib: none
69-
staticparts: none
49+
default:
50+
codec: html
51+
gsp:
52+
encoding: UTF-8
53+
htmlcodec: xml
54+
codecs:
55+
expression: html
56+
scriptlets: html
57+
taglib: none
58+
staticparts: none
7059
---
7160
hibernate:
7261
configClass: functional.tests.CustomHibernateMappingContextConfiguration
7362
packagesToScan:
7463
- another
7564
cache:
76-
queries: false
77-
use_second_level_cache: true
78-
use_query_cache: false
79-
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
80-
endpoints:
81-
jmx:
82-
unique-names: true
83-
65+
queries: false
66+
use_second_level_cache: true
67+
use_query_cache: false
68+
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
69+
---
8470
dataSource:
85-
pooled: true
86-
jmxExport: true
87-
driverClassName: org.h2.Driver
88-
username: sa
89-
password:
90-
71+
pooled: true
72+
driverClassName: org.h2.Driver
73+
username: sa
74+
password:
9175
environments:
92-
development:
93-
dataSource:
94-
dbCreate: create-drop
95-
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
96-
test:
97-
dataSource:
98-
dbCreate: update
99-
url: jdbc:h2:mem:testDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
100-
production:
101-
dataSource:
102-
dbCreate: update
103-
url: jdbc:h2:./prodDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
104-
properties:
105-
jmxEnabled: true
106-
initialSize: 5
107-
maxActive: 50
108-
minIdle: 5
109-
maxIdle: 25
110-
maxWait: 10000
111-
maxAge: 600000
112-
timeBetweenEvictionRunsMillis: 5000
113-
minEvictableIdleTimeMillis: 60000
114-
validationQuery: SELECT 1
115-
validationQueryTimeout: 3
116-
validationInterval: 15000
117-
testOnBorrow: true
118-
testWhileIdle: true
119-
testOnReturn: false
120-
jdbcInterceptors: ConnectionState
121-
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
76+
development:
77+
dataSource:
78+
dbCreate: create-drop
79+
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
80+
test:
81+
dataSource:
82+
dbCreate: update
83+
url: jdbc:h2:mem:testDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
84+
production:
85+
dataSource:
86+
dbCreate: update
87+
url: jdbc:h2:./prodDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE

examples/grails3-hibernate5/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/grails3-hibernate5/grails-app/domain/functional/tests/Business.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package functional.tests
22

33
class Business {
4+
45
String name
56

67
static hasMany = [

examples/grails3-hibernate5/grails-app/domain/functional/tests/Product.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package functional.tests
22

3-
import grails.gorm.annotation.JpaEntity
4-
53
import jakarta.persistence.Entity
64
import jakarta.persistence.GeneratedValue
75
import jakarta.persistence.Id
@@ -12,6 +10,7 @@ import jakarta.validation.constraints.Digits
1210
*/
1311
@Entity
1412
class Product {
13+
1514
@Id
1615
@GeneratedValue
1716
Long myId

examples/grails3-hibernate5/src/test/groovy/functional/tests/BookControllerUnitSpec.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ package functional.tests
22

33
import grails.test.hibernate.HibernateSpec
44
import grails.testing.web.controllers.ControllerUnitTest
5-
import org.grails.plugins.web.mime.MimeTypesGrailsPlugin
6-
import spock.lang.Ignore
75

86
/**
97
* Created by graemerocher on 24/10/16.
108
*/
119
class BookControllerUnitSpec extends HibernateSpec implements ControllerUnitTest<BookController> {
1210

13-
def setupSpec() {
14-
defineBeans(new MimeTypesGrailsPlugin())
15-
}
16-
1711
def setup() {
1812
def bookService = Mock(BookService)
1913
bookService.getBook(_) >> { args ->

0 commit comments

Comments
 (0)