-
Notifications
You must be signed in to change notification settings - Fork 224
/
build.gradle
214 lines (184 loc) · 7.07 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
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'checkstyle'
group 'com.bettercloud'
archivesBaseName = 'vault-java-driver'
version '5.1.0'
ext.isReleaseVersion = !version.endsWith('SNAPSHOT')
// This project is actually limited to Java 8 compatibility. See below.
sourceCompatibility = 9
targetCompatibility = 9
repositories {
mavenCentral()
}
dependencies {
testCompile('junit:junit:4.12')
testCompile('org.mockito:mockito-core:2.28.2')
testCompile('org.testcontainers:testcontainers:1.12.3')
testCompile('org.eclipse.jetty:jetty-server:9.4.19.v20190610')
testCompile('org.slf4j:slf4j-api:1.7.26')
testCompile('org.bouncycastle:bcprov-jdk15on:1.62')
testCompile('org.bouncycastle:bcpkix-jdk15on:1.62')
testCompile('org.apache.commons:commons-io:1.3.2')
testRuntime('org.slf4j:slf4j-simple:1.7.26')
}
// Beginning of Java 9 compatibility config
//
// Allowing a library to support Java 9+ modularity, while also maintaining backwards-compatibility for Java 8 users, is WAY more
// tricky than expected! The lines below are adapted from a blog article (https://dzone.com/articles/building-java-6-8-libraries-for-jpms-in-gradle),
// and cause the built classes to support a Java 8 JRE, while also including a module definition suitable for use with Java 9. There are a
// few considerations that come with this:
//
// * You now need JDK 9 or higher to BUILD this library. You can still USE the built artifact as a dependency in a Java 8 project.
// * Although "sourceCompatibility" and "targetCompatability" above are set for Java 9, the "compileJava" settings below will not
// allow you to build with any code changes that are not Java 8 compatible.
// * Unfortunately, IntelliJ (and perhaps other IDE's?) will show syntax highlighting, code completion tips, etc for Java 9. Sorry for
// the inconvenience. In any case, you should not commit changes to source control without confirming that the project builds.
compileJava {
exclude 'module-info.java'
options.compilerArgs = ['--release', '8']
}
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
task compileModuleInfoJava(type: JavaCompile) {
classpath = files()
source = 'src/main/java/module-info.java'
destinationDir = compileJava.destinationDir
options.encoding = compileJava.options.encoding
doFirst {
options.compilerArgs = [
'--release', '9',
'--module-path', compileJava.classpath.asPath,
]
}
}
compileModuleInfoJava.dependsOn compileJava
classes.dependsOn compileModuleInfoJava
// End of Java 9 compatibility config
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
//
// Separate unit tests from integration tests. See: `src/test-integration/README.md`
//
configurations {
unitTestsCompile.extendsFrom testCompile
unitTestsRuntime.extendsFrom testRuntime
integrationTestsCompile.extendsFrom testCompile
integrationTestsRuntime.extendsFrom testRuntime
}
sourceSets {
unitTests {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
java.srcDir file('src/test/java')
}
integrationTests {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
java.srcDir file('src/test-integration/java')
resources.srcDirs += file('src/test-integration/resources')
}
}
task unitTest(type: Test) {
testClassesDirs = sourceSets.unitTests.output.classesDirs
classpath = sourceSets.unitTests.runtimeClasspath
testLogging {
events "passed", "skipped", "failed"
}
}
task integrationTest(type: Test) {
testClassesDirs= sourceSets.integrationTests.output.classesDirs
classpath = sourceSets.integrationTests.runtimeClasspath
testLogging {
events "passed", "skipped", "failed"
}
}
//
// Deploying releases to Maven Central (or snapshots to a local Nexus repository).
//
// Snapshots are not signed... but signing the release artifact requires the following project properties:
//
// signing.keyId = <ID of the private key in your secure keyring used for signing JAR's>
// signing.password = <public key password>
// signing.secretKeyRingFile = <full path to your keyring file (i.e secring.gpg)>
//
if (!hasProperty('ossrhUsername')) {
ext.ossrhUsername = ''
}
if (!hasProperty('ossrhPassword')) {
ext.ossrhPassword = ''
}
if (!hasProperty('nexusUrl')) {
ext.nexusUrl = ''
}
if (!hasProperty('nexusUsername')) {
ext.nexusUsername = ''
}
if (!hasProperty('nexusPassword')) {
ext.nexusPassword = ''
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
// snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
// authentication(userName: ossrhUsername, password: ossrhPassword)
// }
snapshotRepository(url: nexusUrl) {
authentication(userName: nexusUsername, password: nexusPassword)
}
pom.project {
name 'vault-java-driver'
packaging 'jar'
// optionally artifactId can be defined here
description 'Zero-dependency Java client for HashiCorp\'s Vault'
url 'https://github.com/BetterCloud/vault-java-driver'
scm {
connection 'https://github.com/BetterCloud/vault-java-driver.git'
developerConnection 'https://github.com/BetterCloud/vault-java-driver.git'
url 'https://github.com/BetterCloud/vault-java-driver'
}
licenses {
license {
name 'MIT'
url 'https://github.com/BetterCloud/vault-java-driver/blob/master/README.md'
}
}
developers {[
developer {
id 'steve-perkins'
name 'Steve Perkins'
email '[email protected]'
},
developer {
id 'steve-perkins-bc'
name 'Steve Perkins'
email '[email protected]'
},
developer {
id 'jarrodcodes'
name 'Jarrod Young'
email '[email protected]'
}
]}
}
}
}
}