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

Commit 177da0a

Browse files
committed
chore: Cleanup examples-grails3-multiple-datasources
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config. - `logback.xml`: Correct faulty pattern - `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. Use `astTransformation` configuration for dependencies that needs to be both `compileOnly` and `integrationTestCompileOnly`.
1 parent 218d480 commit 177da0a

File tree

4 files changed

+100
-106
lines changed

4 files changed

+100
-106
lines changed
Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
group "examples"
1+
plugins {
2+
id 'groovy'
3+
}
24

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-
}
5+
version = rootProject.version
6+
group = 'examples'
7+
8+
configurations {
9+
astTransformation
10+
}
1311

14-
implementation "org.grails:grails-web-boot"
15-
implementation project(":grails-plugin")
12+
dependencies {
1613

17-
implementation "org.hibernate:hibernate-core-jakarta:$hibernateVersion"
14+
astTransformation 'jakarta.servlet:jakarta.servlet-api'
15+
astTransformation 'org.grails:grails-plugin-controllers'
1816

19-
runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails"
20-
runtimeOnly "com.h2database:h2"
21-
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
22-
runtimeOnly "org.grails.plugins:fields"
23-
runtimeOnly "org.grails.plugins:scaffolding"
17+
implementation project(':grails-plugin')
18+
implementation 'org.grails:grails-core'
19+
implementation 'org.grails:grails-plugin-domain-class'
2420

25-
testImplementation "org.grails:grails-gorm-testing-support"
21+
runtimeOnly 'com.h2database:h2'
22+
runtimeOnly 'com.zaxxer:HikariCP'
23+
runtimeOnly 'org.grails:grails-plugin-databinding'
24+
runtimeOnly 'org.grails:grails-plugin-controllers'
25+
runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure'
26+
runtimeOnly 'org.springframework.boot:spring-boot-starter-logging'
27+
runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'
2628

29+
testImplementation 'org.grails:grails-testing-support'
2730

28-
integrationTestImplementation testFixtures("org.grails.plugins:geb")
31+
testRuntimeOnly 'org.grails:grails-web-testing-support'
2932
}
3033

34+
sourceSets {
35+
main {
36+
compileClasspath += configurations.astTransformation
37+
}
38+
integrationTest {
39+
compileClasspath += configurations.astTransformation
40+
}
41+
}
Lines changed: 67 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,72 @@
1-
---
2-
grails:
3-
profile: web
4-
codegen:
5-
defaultPackage: datasources
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-
rss: application/rss+xml
44-
text: text/plain
45-
hal:
46-
- application/hal+json
47-
- application/hal+xml
48-
xml:
49-
- text/xml
50-
- application/xml
51-
urlmapping:
52-
cache:
53-
maxsize: 1000
54-
controllers:
55-
defaultScope: singleton
56-
converters:
57-
encoding: UTF-8
58-
hibernate:
59-
cache:
60-
queries: false
61-
views:
62-
default:
63-
codec: html
64-
gsp:
65-
encoding: UTF-8
66-
htmlcodec: xml
67-
codecs:
68-
expression: html
69-
scriptlets: html
70-
taglib: none
71-
staticparts: none
72-
8+
profile: web
9+
codegen:
10+
defaultPackage: datasources
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+
rss: application/rss+xml
35+
text: text/plain
36+
hal:
37+
- application/hal+json
38+
- application/hal+xml
39+
xml:
40+
- text/xml
41+
- application/xml
42+
urlmapping:
43+
cache:
44+
maxsize: 1000
45+
converters:
46+
encoding: UTF-8
47+
hibernate:
48+
cache:
49+
queries: false
50+
views:
51+
default:
52+
codec: html
53+
gsp:
54+
encoding: UTF-8
55+
htmlcodec: xml
56+
codecs:
57+
expression: html
58+
scriptlets: html
59+
taglib: none
60+
staticparts: none
7361
---
7462
dataSources:
75-
dataSource:
76-
pooled: true
77-
jmxExport: true
78-
driverClassName: org.h2.Driver
79-
dbCreate: create-drop
80-
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
81-
secondary:
82-
pooled: true
83-
jmxExport: true
84-
driverClassName: org.h2.Driver
85-
dbCreate: create-drop
86-
url: jdbc:h2:mem:devDb2;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
63+
dataSource:
64+
pooled: true
65+
driverClassName: org.h2.Driver
66+
dbCreate: create-drop
67+
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
68+
secondary:
69+
pooled: true
70+
driverClassName: org.h2.Driver
71+
dbCreate: create-drop
72+
url: jdbc:h2:mem:devDb2;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE

examples/grails3-multiple-datasources/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-multiple-datasources/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) {

0 commit comments

Comments
 (0)