forked from aws/amazon-documentdb-jdbc-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
325 lines (298 loc) · 10.7 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
plugins {
id 'java'
id 'com.github.spotbugs' version '4.5.1'
id 'checkstyle'
id 'jacoco'
id 'com.github.hierynomus.license' version '0.15.0'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'org.kordamp.gradle.markdown' version '2.2.0'
id "de.undercouch.download" version "4.1.2"
id "com.github.dkorotych.gradle-maven-exec" version "2.2.1"
}
group 'software.amazon.documentdb.jdbc'
version project.hasProperty("BETA_VERSION") ? "${project.MAJOR_VERSION}.${project.MINOR_VERSION}.${project.PATCH_VERSION}-beta.${project.BETA_VERSION}" : "${project.MAJOR_VERSION}.${project.MINOR_VERSION}.${project.PATCH_VERSION}"
description 'documentdb-jdbc-driver'
tasks.register('licenseAndNotice') {
copy {
from "${rootDir}/LICENSE"
into 'src/main/resources'
}
copy {
from "${rootDir}/NOTICE"
into 'src/main/resources'
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
options.deprecation = true
options.encoding 'UTF-8'
}
// Silently agree to build scan terms.
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
jar {
manifest {
attributes(
'Implementation-Version': archiveVersion.get(),
'Main-Class': 'software.amazon.documentdb.jdbc.DocumentDbMain')
}
}
shadowJar {
dependsOn('licenseAndNotice')
// Exclude driver unnecessary classes.
exclude 'org/apache/calcite/jdbc/Driver*'
exclude 'org/apache/calcite/avatica/remote/Driver*'
exclude 'org/apache/commons/dbcp2/PoolingDriver*'
// NOTE: DO NOT relocate 'javax', 'org.apache.log4j', 'org.sl4j', 'org.codehaus'
// Relocate (shadow) the following packages.
relocate 'com.esri', 'shadow.com.esri'
relocate 'com.fasterxml', 'shadow.com.fasterxml'
relocate 'com.google', 'shadow.com.google'
relocate 'com.jayway', 'shadow.com.jayway'
relocate 'com.jcraft', 'shadow.com.jcraft'
relocate 'com.mongodb', 'shadow.com.mongodb'
relocate 'com.yahoo', 'shadow.com.yahoo'
relocate 'codegen', 'shadow.codegen'
relocate 'net', 'shadow.net'
relocate 'nl', 'shadow.nl'
relocate 'org.apache.calcite', 'shadow.org.apache.calcite'
relocate 'org.apache.commons', 'shadow.org.apache.commons'
relocate 'org.apache.http', 'shadow.org.apache.http'
relocate 'org.apache.logging', 'shadow.org.apache.logging'
relocate 'org.apiguardian', 'shadow.org.apiguardian'
relocate 'org.bson', 'shadow.org.bson'
relocate 'org.checkerframework', 'shadow.org.checkerframework'
relocate 'org.mongodb', 'shadow.org.mongodb'
relocate 'org.objectweb', 'shadow.org.objectweb'
relocate 'org.pentaho', 'shadow.org.pentaho'
relocate 'org.yaml', 'shadow.org.yaml'
// Remove any unused dependencies (excluding Calcite)
minimize {
exclude(dependency('org.apache.calcite::'))
exclude(dependency('org.slf4j.*::'))
exclude(dependency('com.jcraft::'))
}
}
artifacts {
archives shadowJar
}
test {
useJUnitPlatform {
if (project.hasProperty('runRemoteIntegrationTests') && project.property('runRemoteIntegrationTests') == 'false') {
environment "connectionString", project.CONNECTION_STRING_LOCAL
// Ensure to match the enumeration name exactly from DocumentDbTestEnvironmentType.
environment "CONFIGURED_ENVIRONMENTS", "MONGODB40_FLAPDOODLE"
excludeTags 'remote-integration'
} else {
environment "connectionString", project.CONNECTION_STRING_REMOTE
// Ensure to match the enumeration name exactly from DocumentDbTestEnvironmentType.
environment "CONFIGURED_ENVIRONMENTS", "MONGODB40_FLAPDOODLE,DOCUMENTDB40_SSH_TUNNEL"
excludeTags 'local-integration'
}
}
}
/**
* CheckStyle Plugin
*/
apply plugin: 'checkstyle'
checkstyle {
toolVersion '8.37'
configFile file("config/checkstyle/checkstyle-rules.xml")
ignoreFailures = false
}
checkstyleMain {
source = 'src/main/java'
}
checkstyleTest {
source = 'src/test/java'
}
/**
* SpotBugs Plugin
*/
spotbugs {
showStackTraces = false
reportsDir = file("$buildDir/reports/spotbugs")
ignoreFailures = false
excludeFilter = file("config/spotbugs/spotbugs-exclude.xml")
}
spotbugsMain {
// Configure HTML report
reports {
xml {
enabled = true
destination = file("$buildDir/reports/spotbugs/main.xml")
}
}
}
spotbugsTest {
// Configure HTML report
reports {
xml {
enabled = true
destination = file("$buildDir/reports/spotbugs/test.xml")
}
}
}
task checkSpotBugsMainReport {
doLast {
def xmlReport = spotbugsMain.reports.getByName("XML")
def slurped = new XmlSlurper().parse(xmlReport.destination)
def bugsFound = slurped.BugInstance.size()
slurped.BugInstance.each {
println "SpotBugs Error"
println "\tShort Message:\t\t${it.ShortMessage}"
println "\tLong Message:\t\t${it.LongMessage}"
println "\tSource of Error:\t${it.SourceLine.Message}"
}
if (bugsFound > 0) {
throw new Exception("Encountered SpotBugs errors, see above.")
}
}
}
task checkSpotBugsTestReport {
doLast {
def xmlReport = spotbugsTest.reports.getByName("XML")
def slurped = new XmlSlurper().parse(xmlReport.destination)
def bugsFound = slurped.BugInstance.size()
slurped.BugInstance.each {
println "SpotBugs Error"
println "\tShort Message:\t\t${it.ShortMessage}"
println "\tLong Message:\t\t${it.LongMessage}"
println "\tSource of Error:\t${it.SourceLine.Message}"
}
if (bugsFound > 0) {
//TODO Temporary ignoring, as dedicated set of rules should be defined
//throw new Exception("Encountered SpotBugs errors, see above.")
}
}
}
spotbugsMain.finalizedBy checkSpotBugsMainReport
spotbugsTest.finalizedBy checkSpotBugsTestReport
/**
* JaCoCo Plugin
*/
test {
jacoco {
excludes = ['org/codehaus/**', 'org.codehaus.*']
}
}
jacoco {
toolVersion = "0.8.5"
}
jacocoTestReport {
reports {
html.enabled true
csv.enabled true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
project.logger.info('it' + it)
fileTree(dir: it,
exclude: ['**/resources/**', '**janino**', '**commons**'])
}))
}
}
test.finalizedBy(project.tasks.jacocoTestReport)
jacocoTestCoverageVerification {
violationRules {
rule {
element = 'CLASS'
excludes = ['org.codehaus.*']
limit {
counter = 'LINE'
minimum = 0.00
}
limit {
counter = 'BRANCH'
minimum = 0.00
}
}
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['org/codehaus/**'])
}))
}
}
check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification.dependsOn jacocoTestReport
/**
* License Plugin
*/
license {
header = project.file('license-header.txt')
exclude "**/*.properties"
headerDefinitions {
slash_star_with_space {
firstLine = '/*'
endLine = ' *\n */\n'
beforeEachLine = ' * '
firstLineDetectionPattern = '/\\*'
lastLineDetectionPattern = ' \\*\n \\*/\n'
}
}
mapping {
java = 'slash_star_with_space'
}
}
/**
* Write driver version data to properties file under base project.
*/
task writeProperties(type: WriteProperties) {
outputFile("$projectDir/src/main/resources/project.properties")
property("driver.major.version", MAJOR_VERSION)
property("driver.minor.version", MINOR_VERSION)
property("driver.full.version", project.version)
}
/**
* Write default application name to properties file under common.
*/
task writeCommonProperties(type: WriteProperties) {
outputFile("$projectDir/common/src/main/resources/common.properties")
property("default.application.name", "${APPLICATION_NAME} v${project.version}")
}
processResources {
from(writeProperties)
from(writeCommonProperties)
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
repositories {
mavenCentral()
}
dependencies {
implementation project(":calcite-adapter")
implementation project(":common")
implementation group: 'commons-cli', name: 'commons-cli', version: '1.5.0'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.13.1'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava', version: '2.13.0'
implementation group: 'com.google.guava', name: 'guava', version: '29.0-jre'
implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.33'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.9'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
implementation group: 'org.mongodb', name: 'mongodb-driver-sync', version: '4.3.4'
implementation group: 'com.jcraft', name: 'jsch', version: '0.1.55'
compileOnly group: 'com.puppycrawl.tools', name: 'checkstyle', version: '9.2'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
testImplementation(testFixtures(project(':common')))
testCompileOnly group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1'
testCompileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.16'
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.16'
testImplementation group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '3.2.6'
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.2'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.2.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
}