This repository has been archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
337 lines (303 loc) · 9.75 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
buildscript {
repositories {
jcenter()
}
dependencies {
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'
}
}
plugins {
id "com.google.protobuf" version "0.8.2"
id "java"
id "pmd"
id "findbugs"
id "jacoco"
id 'com.github.kt3k.coveralls' version '2.6.3'
id "maven-publish"
id "com.jfrog.artifactory" version "4.4.0"
id "com.jfrog.bintray" version "1.7.3"
id "idea"
id "eclipse"
}
def versionProps = new Properties()
versionProps.load(new StringReader(new File(project.projectDir.absolutePath + '/version.properties').text))
def versionDropwizardVersion = versionProps['DROPWIZARD_VERSION']
def versionProjectVersion = versionProps['PROJECT_VERSION'].toInteger()
def versionIsSnapshot = versionProps['SNAPSHOT'].toBoolean()
def isRelease = ((project.hasProperty('forceRelease') && project.forceRelease.toBoolean()) || !versionIsSnapshot)
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
group = 'io.github.msteinhoff'
description = 'A set of classes to use a gRPC server in a Dropwizard service.'
version = "$versionDropwizardVersion-$versionProjectVersion" + (!isRelease ? "-SNAPSHOT" : "")
ext {
ghRepo = 'msteinhoff/dropwizard-grpc'
url = 'https://msteinhoff.github.io/dropwizard-grpc/'
issueUrl = 'https://github.com/msteinhoff/dropwizard-grpc/issues/'
vcsUrl = 'https://github.com/msteinhoff/dropwizard-grpc/'
ciUrl = 'https://travis-ci.org/msteinhoff/dropwizard-grpc/'
buildDateTime = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ", Locale.ENGLISH).format(new Date())
buildDate = buildDateTime.split('T')[0]
buildTime = buildDateTime.split('T')[1]
gitRevision = "git rev-parse HEAD".execute().text.trim()
gradleVersion = '3.2.1'
// compile dependencies
dropwizardVersion = versionDropwizardVersion
grpcVersion = '1.13.1'
// test dependencies
junitVersion = '4.12'
mockitoVersion = '1.10.19'
protocVersion = '3.5.1-1'
protoVersion = '3.3.1'
// make sure this is compatible with gRPC, see SECURITY.md in grpc-java repo
tcnativeBoringSslVersion = '2.0.7.Final'
bintrayUser = System.env.BINTRAY_USER
bintrayApiKey = System.env.BINTRAY_API_KEY
ossrhUser = System.env.OSSRH_USER
ossrhPassword = System.env.OSSRH_PASSWORD
}
repositories {
jcenter()
}
sourceSets {
test {
java {
srcDirs += new File(buildDir, 'generated/source/proto/test/java')
srcDirs += new File(buildDir, 'generated/source/proto/test/grpc')
}
}
}
dependencies {
compile "io.dropwizard:dropwizard-core:$dropwizardVersion"
compile "io.grpc:grpc-netty:$grpcVersion"
compile "io.grpc:grpc-stub:$grpcVersion"
testCompile "io.dropwizard:dropwizard-testing:$dropwizardVersion"
testCompile "io.grpc:grpc-protobuf:$grpcVersion"
testCompile "com.google.protobuf:protobuf-java:$protoVersion"
testCompile "io.grpc:grpc-testing:$grpcVersion"
testCompile "io.netty:netty-tcnative-boringssl-static:$tcnativeBoringSslVersion"
testCompile "junit:junit:$junitVersion"
testCompile "org.mockito:mockito-all:$mockitoVersion"
}
protobuf {
// Configure the protoc executable
protoc {
// Download from repositories
artifact = "com.google.protobuf:protoc:$protocVersion"
}
plugins {
// Define a plugin with name 'grpc'
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
}
generateProtoTasks {
ofSourceSet('test')*.plugins {
// Apply the "grpc" plugin whose spec is defined above, without
// options. Note the braces cannot be omitted, otherwise the
// plugin will not be added. This is because of the implicit way
// NamedDomainObjectContainer binds the methods.
grpc { }
}
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
tasks.withType(Jar) {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': "Mario Steinhoff",
"Implementation-Vendor-Id": project.group,
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(),
'Built-By': System.properties['user.name'],
'Build-Date': buildDate,
'Build-Time': buildTime,
"Git-Commit-Id": gitRevision
)
}
}
pmd {
toolVersion = "5.5.1"
}
findbugs {
toolVersion = "3.0.1"
excludeFilter = file("${projectDir}/config/findbugs/excludeFilter.xml")
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
test {
maxParallelForks = 4
}
jacoco {
toolVersion = "0.7.6.201602180812"
}
tasks.coveralls {
onlyIf { System.env.'CI' }
}
javadoc {
options.noTimestamp = true
}
task javadocJar(type: Jar) {
group BasePlugin.BUILD_GROUP
description 'Assemble a jar archive containing the javadoc files.'
dependsOn javadoc
classifier 'javadoc'
from javadoc.destinationDir
}
javadocJar.enabled = isRelease
task sourcesJar(type: Jar) {
group BasePlugin.BUILD_GROUP
description 'Assemble a jar archive containing the source files.'
classifier 'sources'
from sourceSets.main.allSource
}
sourcesJar.enabled = isRelease
artifacts {
archives jar
if(isRelease) {
archives sourcesJar
archives javadocJar
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
if(isRelease) {
artifact sourcesJar
artifact javadocJar
}
def projectMeta = {
resolveStrategy = groovy.lang.Closure.DELEGATE_FIRST
name project.name
description project.description
url project.url
inceptionYear '2016'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
ciManagement {
system 'Travis CI'
url project.ciUrl
}
issueManagement {
system 'GitHub Issues'
url project.issueUrl
}
scm {
connection 'scm:git:https://github.com/msteinhoff/dropwizard-grpc.git'
developerConnection 'scm:git:git@github.com:msteinhoff/dropwizard-grpc.git'
url project.vcsUrl
}
developers {
developer {
id 'm.steinhoff'
name 'Mario Steinhoff'
email 'steinhoff.mario@gmail.com'
}
}
}
pom.withXml {
asNode().children().last() + projectMeta
}
}
}
}
artifactory {
contextUrl = 'https://oss.jfrog.org/'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = bintrayUser
password = bintrayApiKey
maven = true
}
defaults {
publications ('mavenJava')
}
}
resolve {
repository {
repoKey = 'libs-release'
username = bintrayUser
password = bintrayApiKey
maven = true
}
}
}
artifactoryPublish.enabled = !isRelease
artifactoryPublish.dependsOn(assemble)
publish.dependsOn(artifactoryPublish)
bintray {
user = bintrayUser
key = bintrayApiKey
publications = ['mavenJava']
dryRun = project.hasProperty('dryRun') && project.dryRun.toBoolean()
publish = true
pkg {
repo = 'maven'
name = project.name
desc = project.description
websiteUrl = project.url
issueTrackerUrl = project.issueUrl
vcsUrl = project.vcsUrl
licenses = ['Apache-2.0']
labels = ['dropwizard', 'grpc', 'java']
publicDownloadNumbers = true
githubRepo = ghRepo
githubReleaseNotesFile = 'CHANGELOG.md'
version {
name = project.version
vcsTag = "v${project.version}"
released = buildDateTime
gpg {
sign = true
}
mavenCentralSync {
sync = true
user = ossrhUser
password = ossrhPassword
close = '1'
}
}
}
}
bintrayUpload.enabled = isRelease
bintrayUpload.dependsOn(assemble)
publish.dependsOn(bintrayUpload)
task wrapper(type: Wrapper) {
gradleVersion = gradleVersion
distributionUrl "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}
idea {
module {
// Marks the already(!) added srcDir as "generated"
generatedSourceDirs += new File(buildDir, 'generated/source/proto/test/java')
generatedSourceDirs += new File(buildDir, 'generated/source/proto/test/grpc')
}
}
eclipse {
classpath {
file.beforeMerged {
// this will make Eclipse pick them up as source directories
mkdir(new File(buildDir, 'generated/source/proto/test/java'))
mkdir(new File(buildDir, 'generated/source/proto/test/grpc'))
}
}
project {
natures.add('org.eclipse.buildship.core.gradleprojectnature')
}
}