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

Commit 6f9d931

Browse files
matreicodeconsole
andauthored
Use versions from grails-bom in example apps (#920)
* fix(deps): Use versions from `grails-bom` in example apps And remove unused versions from `gradle.properties` * build: Remove `webdriver-binaries-gradle-plugin` As `ContainerGebSpec` is used now, `webdriver-binaries-gradle-plugin` can be removed. * chore: Remove outdated comment * chore: Cleanup `examples-grails3-database-per-tenant` - `AnotherBookService`: Make `save()` method use passed book title - `Application`: Remove unused imports and old comment - `application.yml`: Format properly with 2 spaces and group config settings better - `logback.xml`: Correct faulty pattern - `build.gradle`: Use correct dependencies and narrow the scopes. 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. * 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`. - `UrlMappings`: Move to package so it is pickup up. * 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`. * chore: Cleanup `examples-grails3-partitioned-multi-tenancy` - `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config. - `logback.xml`: Correct faulty pattern - `AnotherBookService`: Make `save()` method use passed book title - `PartionedMultiTenancySpec`: 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. * chore: Cleanup `examples-grails3-schema-per-tenant` - `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config. - `logback.xml`: Correct faulty pattern - `AnotherBookService`: Make `save()` method use passed book title - `SchemaPerTenantSpec`: 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. * 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`. * chore: Cleanup `examples-spring-boot-hibernate5` - `application.yml`: Format properly with 2 spaces remove unused config. - `Application`: Exclude `HibernateJpaAutoConfiguration` to avoid duplicate transaction managers: java.lang.ClassCastException: class org.springframework.orm.jpa.EntityManagerHolder cannot be cast to class org.springframework.orm.hibernate5.SessionHolder (org.springframework.orm.jpa.EntityManagerHolder and org.springframework.orm.hibernate5.SessionHolder are in unnamed module of loader 'app') - `BookController`: Add `@ReadOnly` to `books()` action to get a session for the `Book.list()` method. - `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. Add version variable `springBootGradlePluginVersion`. * test: Extract test for issue 450 from `examples-grails-data-service` The fix for #450 did not really fit in `examples-grails-data-service`. This commit adds a new example project, that shows the problem and that it now works (taken from https://github.com/grails-core-issues-forks/multitenantcomposite). * chore: Cleanup `examples-grails-data-service` - `MultitenantBook.groovy`: Remove as extracted to examples-issue-450 - `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config. - `ClassUsingAService`: Remove dependency on `grails-spring-security-rest`. No need to depend on outside plugins for this test. New test `ServiceInjectionSpec` exercising issue 202. - `TestService`: Remove unused `transactionService` property - `logback.xml`: Correct faulty pattern * chore: Cleanup `examples-standalone-hibernate5` 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. --------- Co-authored-by: Scott Murphy <[email protected]>
1 parent 56026e5 commit 6f9d931

File tree

115 files changed

+24864
-868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+24864
-868
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
2929
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
3030
with:
31-
arguments: build -Dgeb.env=chromeHeadless
31+
arguments: build
3232
publish:
3333
if: github.event_name == 'push'
3434
runs-on: ubuntu-latest

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ buildscript {
88
classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
99
classpath "org.grails.plugins:views-gradle:$viewsGradleVersion"
1010
classpath "org.asciidoctor:asciidoctor-gradle-jvm:$asciidoctorGradleVersion"
11-
classpath "com.github.erdi:webdriver-binaries-gradle-plugin:$webdriverBinariesPluginVersion"
1211
}
1312
}
1413

@@ -90,7 +89,6 @@ subprojects { Project subproject ->
9089
if (subproject.name != "examples-grails-data-service") {
9190
apply plugin:"org.grails.grails-web"
9291
apply plugin:"org.grails.grails-gsp"
93-
apply plugin:"com.github.erdi.webdriver-binaries"
9492
}
9593
}
9694

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
group "examples"
1+
plugins {
2+
id 'groovy'
3+
id 'org.grails.grails-web'
4+
id 'org.grails.plugins.views-json'
5+
}
6+
27

3-
apply plugin:"org.grails.grails-web"
4-
apply plugin:"org.grails.plugins.views-json"
5-
apply plugin: 'java'
8+
version = rootProject.version
9+
group = 'examples'
610

711
dependencies {
8-
implementation "org.springframework.boot:spring-boot-starter-logging"
9-
implementation "org.springframework.boot:spring-boot-autoconfigure"
10-
implementation "org.grails:grails-core"
11-
implementation "org.springframework.boot:spring-boot-starter-actuator"
12-
implementation "org.springframework.boot:spring-boot-starter-tomcat"
13-
implementation "org.grails:grails-dependencies"
14-
implementation "org.grails:grails-plugin-codecs"
15-
implementation "org.grails:grails-plugin-services"
16-
implementation "org.grails:grails-plugin-datasource"
17-
implementation "org.grails:grails-web-boot"
18-
implementation "org.grails:grails-logging"
19-
implementation "org.grails.plugins:cache"
20-
implementation "org.grails.plugins:events"
21-
implementation project(":grails-plugin")
22-
implementation "org.hibernate:hibernate-core-jakarta:$hibernateVersion"
23-
implementation "org.grails.plugins:views-json"
24-
implementation "org.grails.plugins:views-json-templates"
25-
implementation "org.grails.plugins:spring-security-rest:$grailsSpringSecurityRestVersion"
26-
profile "org.grails.profiles:rest-api"
27-
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
28-
testImplementation "org.grails:grails-gorm-testing-support:$testingSupportVersion"
29-
testImplementation "org.grails:grails-web-testing-support:$testingSupportVersion"
12+
13+
implementation project(':grails-plugin')
14+
implementation 'org.grails:grails-core'
15+
implementation 'org.grails.plugins:views-json'
16+
17+
runtimeOnly 'com.h2database:h2'
18+
runtimeOnly 'com.zaxxer:HikariCP'
19+
runtimeOnly 'org.grails:grails-plugin-databinding'
20+
runtimeOnly 'org.grails:grails-plugin-i18n'
21+
runtimeOnly 'org.grails:grails-plugin-services'
22+
runtimeOnly 'org.grails:grails-plugin-url-mappings'
23+
runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure'
24+
runtimeOnly 'org.springframework.boot:spring-boot-starter-logging'
25+
runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'
26+
27+
integrationTestImplementation 'org.grails:grails-testing-support'
3028
}

examples/grails-data-service/grails-app/conf/application.groovy

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 58 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,66 @@
1-
grails:
2-
gorm:
3-
multiTenancy:
4-
mode: DISCRIMINATOR
5-
tenantResolverClass: org.grails.datastore.mapping.multitenancy.web.SessionTenantResolver
6-
---
7-
grails:
8-
profile: rest-api
9-
codegen:
10-
defaultPackage: example
11-
gorm:
12-
reactor:
13-
# Whether to translate GORM events into Reactor events
14-
# Disabled by default for performance reasons
15-
events: false
161
info:
17-
app:
18-
name: '@info.app.name@'
19-
version: '@info.app.version@'
20-
grailsVersion: '@info.app.grailsVersion@'
21-
spring:
22-
jmx:
23-
unique-names: true
24-
main:
25-
banner-mode: "off"
26-
groovy:
27-
template:
28-
check-template-location: false
29-
devtools:
30-
restart:
31-
additional-exclude:
32-
- '*.gsp'
33-
- '**/*.gsp'
34-
- '*.gson'
35-
- '**/*.gson'
36-
- 'logback.groovy'
37-
- '*.properties'
38-
management:
39-
endpoints:
40-
enabled-by-default: false
41-
2+
app:
3+
name: '@info.app.name@'
4+
version: '@info.app.version@'
5+
grailsVersion: '@info.app.grailsVersion@'
426
---
437
grails:
44-
mime:
45-
disable:
46-
accept:
47-
header:
48-
userAgents:
49-
- Gecko
50-
- WebKit
51-
- Presto
52-
- Trident
53-
types:
54-
json:
55-
- application/json
56-
- text/json
57-
hal:
58-
- application/hal+json
59-
- application/hal+xml
60-
xml:
61-
- text/xml
62-
- application/xml
63-
atom: application/atom+xml
64-
css: text/css
65-
csv: text/csv
66-
js: text/javascript
67-
rss: application/rss+xml
68-
text: text/plain
69-
all: '*/*'
70-
urlmapping:
71-
cache:
72-
maxsize: 1000
73-
controllers:
74-
defaultScope: singleton
75-
converters:
76-
encoding: UTF-8
77-
8+
profile: rest-api
9+
codegen:
10+
defaultPackage: example
11+
mime:
12+
disable:
13+
accept:
14+
header:
15+
userAgents:
16+
- Gecko
17+
- WebKit
18+
- Presto
19+
- Trident
20+
types:
21+
json:
22+
- application/json
23+
- text/json
24+
hal:
25+
- application/hal+json
26+
- application/hal+xml
27+
xml:
28+
- text/xml
29+
- application/xml
30+
atom: application/atom+xml
31+
css: text/css
32+
csv: text/csv
33+
js: text/javascript
34+
rss: application/rss+xml
35+
text: text/plain
36+
all: '*/*'
37+
urlmapping:
38+
cache:
39+
maxsize: 1000
40+
converters:
41+
encoding: UTF-8
7842
---
7943
hibernate:
80-
cache:
81-
queries: false
82-
use_second_level_cache: false
83-
use_query_cache: false
44+
cache:
45+
queries: false
46+
use_second_level_cache: false
47+
use_query_cache: false
8448
dataSource:
85-
pooled: true
86-
jmxExport: true
87-
driverClassName: org.h2.Driver
88-
username: sa
89-
password: ''
49+
pooled: true
50+
driverClassName: org.h2.Driver
51+
username: sa
52+
password: ''
9053

9154
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: none
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
55+
development:
56+
dataSource:
57+
dbCreate: create-drop
58+
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
59+
test:
60+
dataSource:
61+
dbCreate: update
62+
url: jdbc:h2:mem:testDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
63+
production:
64+
dataSource:
65+
dbCreate: none
66+
url: jdbc:h2:./prodDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE

examples/grails-data-service/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-data-service/grails-app/conf/spring/resources.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import example.LoginAuthenticationSucessHandler
1+
import example.ClassUsingAService
22
import example.TestBean
33

44
// Place your Spring DSL code here
55
beans = {
66

7-
restAuthenticationSuccessHandler(LoginAuthenticationSucessHandler) {
7+
classUsingAService(ClassUsingAService) {
88
testService = ref('testService')
99
}
1010

examples/grails-data-service/grails-app/domain/example/MultitenantBook.groovy

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/grails-data-service/grails-app/services/example/TestService.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package example
22

3-
import grails.gorm.transactions.TransactionService
4-
53
class TestService {
64

75
LibraryService libraryService
8-
TransactionService transactionService
96

107
Boolean testDataService(Serializable id) {
118
libraryService.bookExists(id)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package example
2+
3+
import grails.testing.mixin.integration.Integration
4+
import spock.lang.Issue
5+
import spock.lang.Specification
6+
7+
@Integration
8+
class ServiceInjectionSpec extends Specification {
9+
10+
ClassUsingAService classUsingAService
11+
12+
@Issue('https://github.com/grails/gorm-hibernate5/issues/202')
13+
void 'data-service is injected correctly'() {
14+
when:
15+
classUsingAService.doSomethingWithTheService()
16+
17+
then:
18+
noExceptionThrown()
19+
}
20+
21+
}

0 commit comments

Comments
 (0)