-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathbuild.gradle
169 lines (136 loc) · 5.95 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
ext {
mavenPomName = 'Hibernate Reactive Core'
}
description = 'The core module of Hibernate Reactive'
apply from: publishScript
dependencies {
api "org.hibernate.orm:hibernate-core:${hibernateOrmVersion}"
api 'io.smallrye.reactive:mutiny:2.7.0'
//Logging
implementation 'org.jboss.logging:jboss-logging:3.6.1.Final'
annotationProcessor 'org.jboss.logging:jboss-logging:3.6.1.Final'
compileOnly 'org.jboss.logging:jboss-logging-annotations:3.0.3.Final'
annotationProcessor 'org.jboss.logging:jboss-logging-annotations:3.0.3.Final'
annotationProcessor 'org.jboss.logging:jboss-logging-processor:3.0.3.Final'
//Specific implementation details of Hibernate Reactive:
implementation "io.vertx:vertx-sql-client:${vertxSqlClientVersion}"
// Testing
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation "io.vertx:vertx-junit5:${vertxSqlClientVersion}"
// Drivers
testImplementation "io.vertx:vertx-pg-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-mysql-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-db2-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-mssql-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-oracle-client:${vertxSqlClientVersion}"
// Metrics
testImplementation "io.vertx:vertx-micrometer-metrics:${vertxSqlClientVersion}"
// Optional dependency of vertx-pg-client, essential when connecting via SASL SCRAM
testImplementation 'com.ongres.scram:scram-client:3.1'
// JUnit Jupiter
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
// JDBC driver to test with ORM and PostgreSQL
testRuntimeOnly "org.postgresql:postgresql:42.7.4"
// JDBC driver for Testcontainers with MS SQL Server
testRuntimeOnly "com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11"
// JDBC driver for Testcontainers with MariaDB Server
testRuntimeOnly "org.mariadb.jdbc:mariadb-java-client:3.5.1"
// JDBC driver for Testcontainers with MYSQL Server
testRuntimeOnly "com.mysql:mysql-connector-j:9.1.0"
// JDBC driver for Db2 server, for testing
testRuntimeOnly "com.ibm.db2:jcc:12.1.0.0"
// EHCache
testRuntimeOnly ("org.ehcache:ehcache:3.10.8") {
capabilities {
requireCapability 'org.ehcache.modules:ehcache-xml-jakarta'
}
}
testRuntimeOnly ("org.hibernate.orm:hibernate-jcache:${hibernateOrmVersion}")
// log4j
testRuntimeOnly 'org.apache.logging.log4j:log4j-core:2.20.0'
// Testcontainers
testImplementation "org.testcontainers:postgresql:${testcontainersVersion}"
testImplementation "org.testcontainers:mysql:${testcontainersVersion}"
testImplementation "org.testcontainers:mariadb:${testcontainersVersion}"
testImplementation "org.testcontainers:db2:${testcontainersVersion}"
testImplementation "org.testcontainers:cockroachdb:${testcontainersVersion}"
testImplementation "org.testcontainers:mssqlserver:${testcontainersVersion}"
testImplementation "org.testcontainers:oracle-xe:${testcontainersVersion}"
}
// Reproducible Builds
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
// Configure archive tasks to produce reproducible archives:
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
// Print a summary of the results of the tests (number of failures, successes and skipped)
def loggingSummary(db, result, desc) {
if ( !desc.parent ) { // will match the outermost suite
def output = "${db} results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def repeatLength = output.length() + 1
logger.lifecycle '\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength)
}
}
// Example:
// gradle test -Pdb=MySQL
test {
def selectedDb = project.hasProperty( 'db' )
? project.properties['db']
: 'PostgreSQL'
doFirst {
systemProperty 'db', selectedDb
}
afterSuite { desc, result ->
loggingSummary( selectedDb, result, desc )
}
}
// Configuration for the tests
tasks.withType( Test ).configureEach {
defaultCharacterEncoding = "UTF-8"
useJUnitPlatform()
testLogging {
showStandardStreams = project.hasProperty('showStandardOutput')
showStackTraces = true
exceptionFormat = 'full'
displayGranularity = 1
events = ['PASSED', 'FAILED', 'SKIPPED']
}
systemProperty 'docker', project.hasProperty( 'docker' ) ? 'true' : 'false'
systemProperty 'org.hibernate.reactive.common.InternalStateAssertions.ENFORCE', 'true'
if ( project.hasProperty( 'includeTests' ) ) {
// Example: ./gradlew testAll -PincludeTests=DefaultPortTest
filter {
includeTestsMatching project.properties['includeTests'] ?: '*' as String
}
}
}
def createTestDbTask(dbName) {
tasks.register( "testDb${dbName}", Test ) {
description = "Run tests for ${dbName}"
doFirst() {
systemProperty 'db', dbName
}
afterSuite { desc, result ->
loggingSummary( dbName, result, desc )
}
}
}
// Rule to recognize calls to testDb<dbName>
// and run the tests on the selected db
// Example:
// gradle testDbMySQL testDbDB2
tasks.addRule( "Pattern testDb<id>" ) { String taskName ->
if ( taskName.startsWith( "testDb" ) ) {
def dbName = taskName.substring( "testDb".length() )
createTestDbTask( dbName )
}
}
// The dbs we want to test when running testAll
def dbs = ['MariaDB', 'MySQL', 'PostgreSQL', 'DB2', 'CockroachDB', 'MSSQLServer', 'Oracle']
dbs.forEach { createTestDbTask it }
tasks.register( "testAll", Test ) {
description = "Run tests for ${dbs}"
dependsOn = dbs.collect( [] as HashSet ) { db -> "testDb${db}" }
}