forked from mongodb/mongo-jdbc-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
295 lines (250 loc) · 8.93 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
plugins {
id 'java-library'
id "com.diffplug.gradle.spotless" version "3.24.3"
id 'io.codearte.nexus-staging' version '0.21.2'
id "de.marcphilipp.nexus-publish" version "0.3.0"
id "com.github.johnrengelman.shadow" version "5.2.0"
id "org.cyclonedx.bom" version "1.8.2"
}
version = getGitVersion()
ext {
releaseVersion = getReleaseVersion()
javaDataLoader = "com.mongodb.jdbc.integration.testharness.DataLoader"
javaTestGenerator = "com.mongodb.jdbc.integration.testharness.TestGenerator"
aspectjVersion = '1.9.7'
}
spotless {
java {
googleJavaFormat('1.1').aosp()
licenseHeaderFile('resources/license_header.txt')
}
}
cyclonedxBom {
// includeConfigs is the list of configuration names to include when generating the BOM (leave empty to include every configuration), regex is supported
includeConfigs = ["runtimeClasspath"]
// skipConfigs is a list of configuration names to exclude when generating the BOM, regex is supported
skipConfigs = ["testCompileClasspath", "testRuntimeClass", "testRuntimeOnly"]
// skipProjects is a list of project names to exclude when generating the BOM
skipProjects = ["integration-test", "demo", "smoketest"]
// Specified the type of project being built. Defaults to 'library'
projectType = "library"
// Specified the version of the CycloneDX specification to use. Defaults to '1.5'
schemaVersion = "1.5"
// Boms destination directory. Defaults to 'build/reports'
destination = file(cyclonedxBomDestination)
// The file name for the generated BOMs (before the file format suffix). Defaults to 'bom'
outputName = cyclonedxBomName
// The file format generated, can be xml, json or all for generating both. Defaults to 'all'
outputFormat = "json"
// Exclude BOM Serial Number. Defaults to 'true'
includeBomSerialNumber = false
// Exclude License Text. Defaults to 'true'
includeLicenseText = false
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
allprojects {
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = sourceCompatibility
repositories {
mavenCentral()
}
configurations {
ajc
aspects
compile {
extendsFrom aspects
}
sbom
}
dependencies {
// MongoDB
ajc "org.aspectj:aspectjtools:$aspectjVersion"
implementation "org.aspectj:aspectjrt:$aspectjVersion"
implementation group: 'org.mongodb', name: 'mongodb-driver-sync', version: mongodbDriverVersion
implementation group: 'com.google.guava', name: 'guava', version: guavaVersion
implementation group: 'org.apache.commons', name: 'commons-lang3', version: lang3Version
ajc "org.aspectj:aspectjtools:$aspectjVersion"
// Test
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitJupiterVersion
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitJupiterVersion
testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter', version: mockitoVersion
}
//ant.lifecycleLogLevel = AntBuilder.AntMessagePriority.VERBOSE
compileJava {
doLast {
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
classpath: configurations.ajc.asPath)
ant.iajc(
maxmem: "1024m", fork: "true", Xlint: "ignore",
destDir: project.sourceSets.main.output.classesDirs[0].absolutePath,
sourceroots: project.sourceSets.main.java.srcDirs[0].absolutePath,
classpath: project.sourceSets.main.runtimeClasspath.asPath,
source: project.sourceCompatibility,
target: project.targetCompatibility,
showWeaveInfo: true
)
}
}
test {
useJUnitPlatform()
failFast = true
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
classifier "sources"
}
task testJar(type: Jar) {
from sourceSets.test.allJava
classifier "test"
}
task javadocJar(type: Jar) {
from javadoc
classifier 'javadoc'
}
artifacts {
sourceJar
testJar
javadocJar
}
}
configurations {
integrationTestImplementation.extendsFrom implementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly
// Use the release version instead of gitVersion for the produced jar
jar.archiveVersion = releaseVersion
shadowJar.archiveVersion = releaseVersion
}
task integrationTest(type: Test) {
useJUnitPlatform()
description = 'Runs integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
shouldRunAfter test
}
check.dependsOn integrationTest
task runTestGenerator(type: JavaExec) {
group = "Execution"
description = "Run the integration test baseline file generator."
classpath = sourceSets.integrationTest.runtimeClasspath
main = javaTestGenerator
}
task runDataLoader(type: JavaExec) {
group = "Execution"
description = "Run the data loader."
classpath = sourceSets.integrationTest.runtimeClasspath
main = javaDataLoader
}
task runServer(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.mongodb.jdbc.oidc.manualtests.TestRFC8252Server'
}
task runAuthFlow(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.mongodb.jdbc.oidc.manualtests.TestOidcAuthFlow'
}
task runAuthFlowAndRefresh(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.mongodb.jdbc.oidc.manualtests.TestOidcAuthFlowAndRefresh'
}
task runCallback(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.mongodb.jdbc.oidc.manualtests.TestOidcCallback'
}
task runCallbackWithShortTimeout(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.mongodb.jdbc.oidc.manualtests.TestOidcCallbackWithShortTimeout'
}
task runCallbackWithBadRefreshToken(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.mongodb.jdbc.oidc.manualtests.TestOidcCallbackWithBadRefreshToken'
}
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}
dependencies {
integrationTestImplementation "org.yaml:snakeyaml:$snakeYamlVersion"
api "org.mongodb:mongodb-driver-sync:$mongodbDriverVersion"
integrationTestImplementation "org.junit.jupiter:junit-jupiter:$junitJupiterVersion"
integrationTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitJupiterVersion
implementation group: 'org.thymeleaf', name: 'thymeleaf', version: thymeLeafVersion
implementation group: 'com.nimbusds', name: 'oauth2-oidc-sdk', version: oauth2OIDCVersion
}
def getReleaseVersion() {
def snapshot = isDirtyVersion() || !isTaggedVersion()
if (snapshot) {
return getAbbreviatedGitVersion() + "-SNAPSHOT"
} else {
return getGitVersion()
}
}
def isDirtyVersion() {
getGitVersion().endsWith("dirty")
}
def isTaggedVersion() {
def out = new ByteArrayOutputStream()
def result = exec {
commandLine 'git', 'describe', '--exact'
ignoreExitValue true
standardOutput out
errorOutput out
}
if (result.getExitValue() == 0) {
return true
} else {
return false
}
}
def getGitVersion() {
def out = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always', '--dirty'
standardOutput = out
}
out.toString().substring(1).trim()
}
def getAbbreviatedGitVersion() {
def out = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--abbrev=0'
standardOutput = out
}
out.toString().substring(1).trim()
}
tasks.register('runMongoSQLTranslateLibTest', Test) {
description = 'Runs MongoSQLTranslateLibTest'
group = 'verification'
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
useJUnitPlatform()
filter {
if (project.hasProperty('testMethod')) {
includeTestsMatching "*MongoSQLTranslateLibTest.$testMethod"
} else {
includeTestsMatching "*MongoSQLTranslateLibTest"
}
}
}
tasks.test {
filter {
excludeTestsMatching "*MongoSQLTranslateLibTest"
}
}
apply from: 'gradle/publish.gradle'
apply from: 'gradle/deploy.gradle'