forked from p6spy/p6spy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
420 lines (370 loc) · 13.6 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
plugins {
id 'java'
id 'jacoco'
id 'maven'
id 'maven-publish'
id 'distribution'
id 'com.fizzpod.sweeney' version '4.2.0'
id 'com.github.hierynomus.license' version '0.15.0'
id 'com.github.johnrengelman.shadow' version '6.0.0'
// to publish !SNAPSHOTs to bintray
// ./gradlew bintrayUpload
id 'com.jfrog.bintray' version '1.8.5'
// to publish SNAPSHOTs to oss.jfrog.org
// ./gradlew artifactoryPublish
id 'com.jfrog.artifactory' version '4.16.1'
id "com.github.ben-manes.versions" version "0.29.0"
id "org.sonarqube" version "3.0"
}
def envDB
// sys property (-Denv) or env var (ORG_GRADLE_PROJECT_env) as a fallback
def isTravis = System.getProperty('env', env) != null && System.getProperty('env', env)?.equals('travis')
if (isTravis) {
// envDB = 'PostgreSQL,MySQL,H2,HSQLDB,SQLite,Firebird,Derby,Oracle,MSSQLServer,MariaDB,Percona'
envDB = 'PostgreSQL,MySQL,H2,HSQLDB,SQLite,Firebird,Derby,Oracle'
} else {
// sys property (-DDB) or env var (ORG_GRADLE_PROJECT_DB) as a fallback
envDB = System.getProperty('DB', DB)
}
repositories {
mavenCentral()
flatDir dirs: 'src/test/repo' // holds p6spy-signedjar-test
if (envDB.contains('Oracle')) {
assert new File("${buildDir}/repo/ojdbc6.jar").exists()
flatDir dirs: "${buildDir}/repo" // holds copied oracle jdbc driver
}
}
// using target 1.8 for JDK 14+, doesn't change requirements as release is performed on "oraclejdk8"
if (System.getenv("TRAVIS_JDK_VERSION") == "openjdk14") {
sourceCompatibility = 11
targetCompatibility = 11
} else {
sourceCompatibility = 11
targetCompatibility = 11
}
compileTestJava {
sourceCompatibility = 11
targetCompatibility = 11
}
compileJava.options.encoding = 'UTF8'
javadoc.options.encoding = 'UTF8'
dependencies {
testCompile 'p6spy:p6spy-signedjar-test:1.0.0'
// for providing misc *-nodep artifacts, please note that order matters here
// even if slf4j complains about multiple implementations on classpath, it takes the 1.st one
// and as we use log4j in tests => bridge needs to be the 1.st one specified
compileOnly 'org.slf4j:slf4j-api:1.7.25'
compileOnly 'org.slf4j:slf4j-log4j12:1.7.25'
compileOnly 'log4j:log4j:1.2.17'
testCompile 'org.slf4j:slf4j-api:1.7.25'
testCompile 'org.slf4j:slf4j-log4j12:1.7.25'
testCompile 'log4j:log4j:1.2.17'
compileOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1'
compileOnly 'org.apache.logging.log4j:log4j-api:2.17.1'
compileOnly 'org.apache.logging.log4j:log4j-core:2.17.1'
compileOnly 'ch.qos.logback:logback-classic:1.2.3'
compileOnly 'ch.qos.logback:logback-core:1.2.3'
testCompile 'junit:junit:4.12'
testCompile 'org.eclipse.jetty:jetty-plus:9.4.12.v20180830' // datasource testing through JNDI
testCompile 'commons-dbcp:commons-dbcp:1.4' // datasource testing
testCompile 'org.codehaus.btm:btm:2.1.4' // xa datasource testing
testCompile 'org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1'
testCompile 'org.liquibase:liquibase-core:3.0.8'
testCompile 'com.mattbertolini:liquibase-slf4j:1.2.1'
testCompile 'org.springframework:spring-jdbc:5.1.0.RELEASE'
testCompile 'org.springframework:spring-context:5.1.0.RELEASE'
testCompile 'com.j256.simplejmx:simplejmx:1.15'
testCompile 'commons-io:commons-io:2.6'
testCompile 'org.apache.commons:commons-exec:1.3'
testCompile 'org.apache.commons:commons-lang3:3.8.1'
testCompile 'commons-beanutils:commons-beanutils:1.9.3'
testCompile 'org.mockito:mockito-core:2.22.0'
testCompile 'org.apache.tomcat:tomcat-jdbc:9.0.12' // tomcat pooled datasource testing
// all the JDBC drivers tested
testRuntime 'mysql:mysql-connector-java:5.1.47'
testRuntime 'org.postgresql:postgresql:42.2.5.jre7'
testCompile 'org.hsqldb:hsqldb:2.4.1'
testCompile 'com.h2database:h2:1.4.197'
testRuntime 'org.xerial:sqlite-jdbc:3.25.2' // type 3 driver
testRuntime 'org.apache.derby:derby:10.14.2.0'
testRuntime 'org.firebirdsql.jdbc:jaybird-jdk17:3.0.5' // type 4.1 driver
testRuntime 'com.microsoft.sqlserver:mssql-jdbc:7.1.1.jre8-preview'
if (envDB.contains('Oracle')) {
testRuntime name: 'ojdbc6' // oracle copied from docker oracle container
}
}
sweeney {
// require Java 1.7 or later for the build
enforce type: 'range', expect: '[1.7,)', value: {System.getProperty('java.version')}
}
jacocoTestReport {
reports {
html.enabled = true
xml.enabled = true
}
}
license {
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'P6Spy'
header file('./script/qa/license_header.txt')
}
test {
systemProperty 'user.language', 'en'
systemProperty 'user.country', 'US'
systemProperty 'derby.stream.error.file', 'target/derby.log'
systemProperty 'DB', envDB
// to enable remote JMX testing,
// see: http://stackoverflow.com/questions/5552960/how-to-connect-to-a-java-program-on-localhost-jvm-using-jmx
// to workaround oracle timezone issue: http://stackoverflow.com/questions/9156379/ora-01882-timezone-region-not-found
// to get rid of DB2 traces => -Ddb2.jcc.override.traceLevel=0
// see: http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.jccids.doc/com.ibm.db2.luw.apdv.java.doc/doc/r0052075.htm -->
jvmArgs '-Dcom.sun.management.jmxremote', '-Dcom.sun.management.jmxremote.authenticate=false', '-Dcom.sun.management.jmxremote.port=1234', '-Dcom.sun.management.jmxremote.ssl=false', '-Doracle.jdbc.timezoneAsRegion=false', '-Ddb2.jcc.override.traceLevel=0'
}
jar {
inputs.property('moduleName', project.name)
manifest {
attributes('Automatic-Module-Name': project.name)
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
task shadowLog4jJar(type: ShadowJar) {
classifier = 'log4j-nodep'
from sourceSets.main.output //tells the task to include the project code
configurations = [ project.configurations.compileOnly ]
dependencies {
include(dependency( group: 'log4j', name: 'log4j'))
include(dependency( group: 'org.slf4j', name: 'slf4j-api'))
include(dependency( group: 'org.slf4j', name: 'slf4j-log4j'))
}
}
task shadowLog4j2Jar(type: ShadowJar) {
classifier = 'log4j2-nodep'
from sourceSets.main.output //tells the task to include the project code
configurations = [ project.configurations.compileOnly ]
dependencies {
include(dependency( group: 'org.slf4j', name: 'slf4j-api'))
include(dependency( group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl'))
include(dependency( group: 'org.apache.logging.log4j', name: 'log4j-api'))
include(dependency( group: 'org.apache.logging.log4j', name: 'log4j-core'))
}
}
task shadowLogbackJar(type: ShadowJar) {
classifier = 'logback-nodep'
from sourceSets.main.output //tells the task to include the project code
configurations = [ project.configurations.compileOnly ]
dependencies {
include(dependency( group: 'org.slf4j', name: 'slf4j-api'))
include(dependency( group: 'ch.qos.logback', name: 'logback-classic'))
include(dependency( group: 'ch.qos.logback', name: 'logback-core'))
}
}
distributions {
main {
contents {
from { 'src/main/assembly/individualFiles' }
from { 'license.txt' }
from jar
from javadocJar
from sourcesJar
from shadowLog4jJar
from shadowLog4j2Jar
from shadowLogbackJar
}
}
}
artifacts {
archives javadocJar, sourcesJar, shadowLog4jJar, shadowLog4j2Jar, shadowLogbackJar, distZip, distTar
}
publishing {
publications {
maven(MavenPublication) {
from components.java
groupId project.group
artifactId project.archivesBaseName
version project.version
artifact sourcesJar {
classifier 'sources'
}
artifact javadocJar {
classifier 'javadoc'
}
artifact shadowLog4jJar {
classifier 'log4j-nodep'
}
artifact shadowLog4j2Jar {
classifier 'log4j2-nodep'
}
artifact shadowLogbackJar {
classifier 'logback-nodep'
}
artifact distZip {
extension 'zip'
}
artifact distTar {
extension 'tar'
}
pom {
packaging 'jar'
withXml {
asNode().children().last() + {
def builder = delegate
// maven central publishing mandatories
builder.name project.name
builder.description description
builder.url 'https://github.com/p6spy/p6spy'
builder.licenses {
builder.license {
builder.name 'The Apache Software License, Version 2.0'
builder.url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
builder.distribution 'repo'
}
}
builder.scm {
builder.url 'https://github.com/p6spy/p6spy'
builder.connection 'scm:git:git://github.com/p6spy/p6spy.git'
builder.developerConnection 'scm:git:ssh://github.com:p6spy/p6spy.git'
}
builder.developers {
builder.developer {
builder.name 'Quinton McCombs'
builder.email '[email protected]'
}
builder.developer {
builder.name 'Peter Butkovic'
builder.email '[email protected]'
}
builder.developer {
builder.name 'Felix Barnsteiner'
builder.email '[email protected]'
}
builder.developer {
builder.name 'Arthur Gavlyukovskiy'
builder.email '[email protected]'
}
}
// maven central publishing optionals
builder.issueManagement {
builder.system 'github'
builder.url 'https://github.com/p6spy/p6spy/issues'
}
builder.ciManagement {
builder.system 'Travis CI'
builder.url 'https://travis-ci.org/p6spy/p6spy'
}
}
}
}
}
}
repositories{
maven {
credentials {
username System.getenv('JFROG_USER')
password System.getenv('JFROG_PASSWORD')
}
url "https://kademi.jfrog.io/artifactory/kademi-libs-release-local/"
}
}
}
// to publish SNAPSHOTs to oss.jfrog.org
artifactory {
contextUrl = 'https://oss.jfrog.org'
resolve {
repository {
repoKey = 'libs-release'
}
}
publish {
repository {
// The Artifactory repository key to publish to
// when using oss.jfrog.org the credentials are from Bintray.
if (project.version.endsWith("-SNAPSHOT")) {
repoKey = 'oss-snapshot-local'
} else {
repoKey = 'oss-release-local'
}
username = System.getenv('BINTRAY_USER')
password = System.getenv('BINTRAY_API_KEY')
}
defaults {
publications 'maven'
properties = [ 'bintray.repo': 'p6spy/maven', 'bintray.package': 'p6spy:p6spy', 'bintray.version': project.version.toString() ]
}
}
}
// to publish !SNAPSHOTs to bintray
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_API_KEY')
publications = ['maven']
// dryRun = true
// publish = true
pkg {
repo = 'maven'
name = 'p6spy:p6spy'
userOrg = group
desc = description
websiteUrl = 'https://github.com/p6spy/p6spy'
issueTrackerUrl = 'https://github.com/p6spy/p6spy/issues'
vcsUrl = 'https://github.com/p6spy/p6spy.git'
licenses = ['Apache-2.0']
publicDownloadNumbers = true
githubRepo = 'p6spy/p6spy'
githubReleaseNotesFile = 'docs/releasenotes.md'
version {
released = new Date()
name = project.version
vcsTag = "p6spy-${project.version}"
// Optional configuration for Maven Central sync of the version
mavenCentralSync {
sync = true //[Default: true] Determines whether to sync the version to Maven Central.
close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
user = System.getenv('SONATYPE_USERNAME') //OSS user token: mandatory
password = System.getenv('SONATYPE_PASSWORD') //OSS user password: mandatory
}
}
}
}
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
tasks {
check {
dependsOn(jacocoTestReport)
}
}
// fix for: https://github.com/bintray/gradle-bintray-plugin/issues/229
// reported internally in: https://github.com/p6spy/p6spy/issues/512
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
import org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact
tasks.withType(BintrayUploadTask) {
doFirst {
publishing.publications.withType(MavenPublication).forEach({ publication ->
File moduleFile = new File(project.buildDir, "publications/${publication.name}/module.json")
if (moduleFile.exists()) {
publication.artifact(new FileBasedMavenArtifact(moduleFile) {
protected String getDefaultExtension() {
return 'module';
}
})
}
})
}
}