forked from aws/amazon-documentdb-jdbc-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
401 lines (368 loc) · 13.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
plugins {
id 'java'
id 'com.github.spotbugs' version '5.0.13'
id 'checkstyle'
id 'jacoco'
id 'com.github.hierynomus.license' version '0.16.1'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'org.kordamp.gradle.markdown' version '2.2.0'
id "de.undercouch.download" version "5.3.0"
id 'io.franzbecker.gradle-lombok' version '5.0.0'
id 'java-test-fixtures'
id 'maven-publish'
id 'signing'
}
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
withJavadocJar()
withSourcesJar()
}
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.github.mwiede::'))
}
}
artifacts {
archives shadowJar
archives sourcesJar
archives javadocJar
}
test {
useJUnitPlatform {
if (project.hasProperty('runRemoteIntegrationTests') && project.property('runRemoteIntegrationTests') == 'true') {
// Ensure to match the enumeration name exactly from DocumentDbTestEnvironmentType.
environment "CONFIGURED_ENVIRONMENTS", "MONGODB40_FLAPDOODLE,DOCUMENTDB40_SSH_TUNNEL"
excludeTags 'local-integration'
} else {
// Ensure to match the enumeration name exactly from DocumentDbTestEnvironmentType.
environment "CONFIGURED_ENVIRONMENTS", "MONGODB40_FLAPDOODLE"
excludeTags 'remote-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 {
required.set(true)
destination = file("$buildDir/reports/spotbugs/main.xml")
}
html {
required.set(true)
destination = file("$buildDir/reports/spotbugs/main.html")
}
}
}
spotbugsTest {
// Configure HTML report
reports {
xml {
required.set(true)
destination = file("$buildDir/reports/spotbugs/test.xml")
}
html {
required.set(true)
destination = file("$buildDir/reports/spotbugs/test.html")
}
}
}
task checkSpotBugsMainReport {
doLast {
def xmlReport = spotbugsMain.reports.getByName("xml")
def slurped = new groovy.xml.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.8"
}
jacocoTestReport {
reports {
html.required = true
csv.required = 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 {
skipExistingHeaders = true
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)
property("default.application.name", APPLICATION_NAME)
}
import io.franzbecker.gradle.lombok.task.DelombokTask
task delombok(type: DelombokTask, dependsOn: compileJava) {
ext.outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
sourceSets.main.java.srcDirs.each {
inputs.dir(it)
args(it, "-d", outputDir)
}
}
javadoc {
dependsOn delombok
source = delombok.outputDir
}
processResources {
from(writeProperties)
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
repositories {
mavenCentral()
}
dependencies {
implementation group: 'commons-cli', name: 'commons-cli', version: '1.5.0'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.14.1'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava', version: '2.14.1'
implementation group: 'com.google.guava', name: 'guava', version: '31.1-jre'
implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '2.0.6'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.19.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.19.0'
implementation group: 'org.mongodb', name: 'mongodb-driver-sync', version: '4.8.1'
implementation group: 'com.github.mwiede', name: 'jsch', version: '0.2.6'
implementation group: 'org.apache.calcite', name: 'calcite-core', version: '1.32.0'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
implementation 'io.github.hakky54:sslcontext-kickstart:7.4.9'
compileOnly group: 'org.immutables', name: 'value', version: '2.9.3'
compileOnly group: 'com.puppycrawl.tools', name: 'checkstyle', version: '10.6.0'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1'
testCompileOnly group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1'
testCompileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.9.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.9.1'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.11.0'
testRuntimeOnly group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '3.5.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.9.1'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
testFixturesCompileOnly group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '3.5.3'
testFixturesCompileOnly 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testFixturesImplementation group: 'com.google.guava', name: 'guava', version: '29.0-jre'
testFixturesImplementation group: 'org.mongodb', name: 'mongodb-driver-sync', version: '4.8.1'
testFixturesImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.2'
testFixturesImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.2'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'Amazon DocumentDB JDBC Driver'
groupId = project.group
artifactId = project.name
version = version
description = 'The JDBC driver for the Amazon DocumentDB managed document database provides an SQL-relational interface for developers and BI tool users.'
url = 'https://github.com/aws/amazon-documentdb-jdbc-driver'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://aws.amazon.com/apache2.0'
distribution = 'repo'
}
}
scm {
connection = 'scm:git:https://github.com/aws/amazon-documentdb-jdbc-driver.git'
developerConnection = 'scm:git:[email protected]:aws/amazon-documentdb-jdbc-driver.git'
url = 'https://github.com/aws/amazon-documentdb-jdbc-driver'
}
inceptionYear = '2021'
developers {
developer {
id = 'amazonwebservices'
organization {
name = 'Amazon Web Services'
}
organizationUrl = 'https://aws.amazon.com'
}
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}