1
- description = ' Hibernate Reactive Session Example'
1
+ // Optional: We configure the repositories to ease development and CI builds
2
+ buildscript {
3
+ repositories {
4
+ // Optional: Enables the maven local repository
5
+ // Example: ./gradlew build -PenableMavenLocalRepo
6
+ if ( project. hasProperty( ' enableMavenLocalRepo' ) ) {
7
+ // Useful for local development, it should be disabled otherwise
8
+ mavenLocal()
9
+ }
10
+ mavenCentral()
11
+ }
12
+ }
13
+
14
+ plugins {
15
+ // Optional: Hibernate Gradle plugin to enable bytecode enhancements
16
+ id " org.hibernate.orm" version " ${ hibernateOrmGradlePluginVersion} "
17
+ }
18
+
19
+ description = ' Hibernate Reactive Session Examples'
2
20
3
21
dependencies {
4
- implementation project(' :hibernate-reactive-core' )
22
+ implementation project( ' :hibernate-reactive-core' )
5
23
6
24
// Hibernate Validator (optional)
7
25
implementation ' org.hibernate.validator:hibernate-validator:7.0.2.Final'
@@ -21,76 +39,40 @@ dependencies {
21
39
runtimeOnly ' com.ongres.scram:client:2.1'
22
40
}
23
41
24
- // All of the remaining configuration is only necessary to enable
25
- // the Hibernate bytecode enhancer and field-level lazy fetching.
26
- // (This is very optional!)
27
-
28
- buildscript {
29
- repositories {
30
- // Example: ./gradlew build -PenableMavenLocalRepo
31
- if ( project. hasProperty( ' enableMavenLocalRepo' ) ) {
32
- // Useful for local development, it should be disabled otherwise
33
- mavenLocal()
34
- }
35
- maven {
36
- url ' https://plugins.gradle.org/m2/'
37
- }
38
- mavenCentral()
39
- }
40
- dependencies {
41
- classpath " org.hibernate.orm:hibernate-gradle-plugin:${ hibernateOrmGradlePluginVersion} "
42
- }
43
- }
44
-
45
-
46
- // Hibernate Gradle plugin to enable bytecode enhancements
47
- apply plugin : ' org.hibernate.orm'
42
+ // Optional: enable the bytecode enhancements
43
+ hibernate { enhancement }
48
44
49
- hibernate {
50
- enhancement {
51
- lazyInitialization(true )
52
- dirtyTracking(true )
53
- associationManagement(false )
54
- }
55
- }
56
-
57
- // The following rules define a task to run
58
- // the different API available.
45
+ // Create tasks to run the different API available.
59
46
//
60
- // They require the selected db ready
61
- // to accept connections.
47
+ // They require the selected db ready to accept connections.
62
48
//
63
- // Examples:
64
- // gradle runExampleMySQLMain runExamplePostgreSQLMutinyMain
65
- def mainClasses = [' Main' , ' MutinyMain' ]
49
+ // Examples, in the session-example folder :
50
+ // gradle runExampleOnMySQLMain runExampleOnPostgreSQLMutinyMain
51
+ def mainJavaClasses = [' Main' , ' MutinyMain' ]
66
52
def dbs = [' PostgreSQL' , ' MySQL' ]
67
-
68
- dbs. each { db ->
69
- tasks. addRule( " Pattern runExampleOn${ db} <mainClass>" ) { String taskName ->
70
- if ( taskName. startsWith( " runExampleOn${ db} " ) ) {
71
- task( type : JavaExec , taskName ) {
72
- def mainClass = taskName. substring( " runExampleOn${ db} " . length() )
73
- group = " Execution"
74
- description = " Run ${ mainClass} on ${ db} "
75
- classpath = sourceSets. main. runtimeClasspath
76
- main = " org.hibernate.reactive.example.session.${ mainClass} "
77
- // The persistence unit name defined in resources/META-INF/persistence.xml
78
- args db. toLowerCase() + ' -example'
79
- }
53
+ mainJavaClasses. each { String mainJavaClass ->
54
+ dbs. each { String db ->
55
+ tasks. register( " runExampleOn${ db}${ mainJavaClass} " , JavaExec ) {
56
+ description = " Run ${ mainJavaClass} on ${ db} "
57
+ classpath = sourceSets. main. runtimeClasspath
58
+ mainClass = " org.hibernate.reactive.example.session.${ mainJavaClass} "
59
+ // The persistence unit name defined in resources/META-INF/persistence.xml
60
+ args db. toLowerCase() + ' -example'
80
61
}
81
62
}
82
63
}
83
64
84
- task runAllExamplesOnPostgreSQL (
85
- dependsOn : mainClasses . collect( [] as HashSet ) { mainClass -> " runExampleOnPostgreSQL${ mainClass} " } ) {
86
- description = " Run ${ mainClasses } on PostgreSQL"
65
+ tasks . register( " runAllExamplesOnPostgreSQL" ) {
66
+ dependsOn = mainJavaClasses . collect( [] as HashSet ) { mainClass -> " runExampleOnPostgreSQL${ mainClass} " }
67
+ description = " Run ${ mainJavaClasses } on PostgreSQL"
87
68
}
88
69
89
- task runAllExamplesOnMySQL (
90
- dependsOn : mainClasses . collect( [] as HashSet ) { mainClass -> " runExampleOnMySQL${ mainClass} " } ) {
91
- description = " Run ${ mainClasses } on MySQL"
70
+ tasks . register( " runAllExamplesOnMySQL" ) {
71
+ dependsOn = mainJavaClasses . collect( [] as HashSet ) { mainClass -> " runExampleOnMySQL${ mainClass} " }
72
+ description = " Run ${ mainJavaClasses } on MySQL"
92
73
}
93
74
94
- task runAllExamples ( dependsOn : [" runAllExamplesOnPostgreSQL" , " runAllExamplesOnMySQL" ] ) {
95
- description = " Run examples on ${ mainClasses} "
75
+ tasks. register( " runAllExamples" ) {
76
+ dependsOn = [" runAllExamplesOnPostgreSQL" , " runAllExamplesOnMySQL" ]
77
+ description = " Run all examples on ${ dbs} "
96
78
}
0 commit comments