forked from mongodb/mongo-jdbc-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
217 lines (184 loc) · 6.13 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
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"
}
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')
}
}
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
}
}
dependencies {
// MongoDB
ajc "org.aspectj:aspectjtools:$aspectjVersion"
implementation "org.aspectj:aspectjrt:$aspectjVersion"
implementation group: 'org.mongodb', name: 'mongodb-driver-sync', version: mongodbDriverVersion
implementation group: 'org.mongodb', name: 'mongodb-driver-core', version: mongodbDriverVersion
implementation group: 'org.mongodb', name: 'mongodb-driver', 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
}
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}
dependencies {
implementation "org.yaml:snakeyaml:$snakeYamlVersion"
api "org.mongodb:mongodb-driver-sync:$mongodbDriverVersion"
api "org.mongodb:mongodb-driver:$mongodbDriverVersion"
integrationTestImplementation "org.junit.jupiter:junit-jupiter:$junitJupiterVersion"
integrationTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitJupiterVersion
}
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()
}
apply from: 'gradle/publish.gradle'
apply from: 'gradle/deploy.gradle'