-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
282 lines (233 loc) · 8.35 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
ext {
ver = [
failSafe : '[1.0.4, 1.1.0)',
grpcSpringBootStarter : '[2.1.4, 2.2.0)',
rxJava : "[2.1.4, 2.2.0)",
latrine : '[0.1.4, 0.2.0)',
grpc : '[1.8.0, 1.9.0)',
rxgrpc : '[0.7.2, 0.8.0)',
protobuf : '[3.5.0, 3.6.0)',
grpcStarter : '[2.1.0, 2.2.0)',
googleCommonProtos: '[0.1.20, 0.2.0)',
tcpNative : '[2.0.7.Final, 2.1.0)',
reflections : '[0.9.11, 1.0.0)',
groovy : '2.4.13',
spock : '[1.1-groovy-2.4,1.2)',
cglib : '[3.2.5, 3.3.0)',
objenesis : '2.6',
]
}
buildscript {
ext {
ver = [
springBoot : '[2.0.0.M7, 2.1)',
axionRelease : '[1.8.1, 1.9.0)',
protobufPlugin : '[0.8.1, 0.9.0)',
osdetectorPlugin : '[1.4.0, 15.0)',
]
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath(
"org.springframework.boot:spring-boot-gradle-plugin:${ver.springBoot}",
"pl.allegro.tech.build:axion-release-plugin:${ver.axionRelease}",
"com.google.protobuf:protobuf-gradle-plugin:${ver.protobufPlugin}",
"com.google.gradle:osdetector-gradle-plugin:${ver.osdetectorPlugin}",
)
}
}
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'pl.allegro.tech.build.axion-release'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.google.protobuf'
apply plugin: "com.google.osdetector"
group = 'com.github.venth.training'
scmVersion {
ignoreUncommittedChanges = false
tag {
prefix = 'v'
versionSeparator = ''
}
}
sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9
compileJava {
options.fork = true
options.incremental = true
options.compilerArgs << '-parameters'
dependsOn processResources
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
configurations {
container
}
def containerClassifier = 'linux-x86_64'
def tcpNativeClassifier = osdetector.classifier
// Fedora variants use a different soname for OpenSSL than other linux distributions
// (see http://netty.io/wiki/forked-tomcat-native.html).
if (osdetector.os == "linux" && osdetector.release.isLike("fedora")) {
tcpNativeClassifier += "-fedora"
}
dependencies {
compile(
'org.springframework.boot:spring-boot-starter-webflux',
'org.springframework.boot:spring-boot-starter-actuator',
// grpc base configuration
"org.lognet:grpc-spring-boot-starter:${ver.grpcStarter}",
// grpc
"com.google.api.grpc:proto-google-common-protos:${ver.googleCommonProtos}",
"io.grpc:grpc-netty:${ver.grpc}",
"io.grpc:grpc-protobuf:${ver.grpc}",
"io.grpc:grpc-stub:${ver.grpc}",
"com.salesforce.servicelibs:rxgrpc-stub:${ver.rxgrpc}",
"io.netty:netty-tcnative-boringssl-static:${ver.tcpNative}:${tcpNativeClassifier}",
"org.reflections:reflections:${ver.reflections}",
// circuit breaker and repeater on failures
"net.jodah:failsafe:${ver.failSafe}",
// logging
"org.slf4j:slf4j-api",
"org.slf4j:log4j-over-slf4j",
"org.slf4j:jul-to-slf4j",
"org.slf4j:jcl-over-slf4j",
// reactive
"io.reactivex.rxjava2:rxjava:${ver.rxJava}",
)
compileOnly(
// to deal with spring configuration properties
// https://docs.spring.io/spring-boot/docs/2.0.0.M7/reference/html/configuration-metadata.html#configuration-metadata-annotation-processor
'org.springframework.boot:spring-boot-configuration-processor',
// to avoid writing boring stuff...
'org.projectlombok:lombok:1.16.20',
)
// ensure that boringssl valid for docker container os
container "io.netty:netty-tcnative-boringssl-static:${ver.tcpNative}:${containerClassifier}"
testCompile(
'org.springframework.boot:spring-boot-starter-test',
'io.projectreactor:reactor-test',
// mandatory dependencies for using Spock
"org.codehaus.groovy:groovy-all:${ver.groovy}",
"org.spockframework:spock-core:${ver.spock}",
"org.spockframework:spock-spring:${ver.spock}",
// optional dependencies for using Spock
// allows mocking of classes (in addition to interfaces)
"cglib:cglib-nodep:${ver.cglib}",
// allows mocking of classes without default constructor (together with CGLIB)
"org.objenesis:objenesis:${ver.objenesis}",
"io.grpc:grpc-testing:${ver.grpc}"
)
}
def BASE_IMAGE_NAME = 'service'
task copyContainerSpecificLibs(type: Copy) {
into "${buildDir}/container-libs"
from configurations.container
}
def dockerBin = properties.get('dockerBin', '/usr/local/bin/docker')
task buildDockerImage {
dependsOn copyContainerSpecificLibs
doLast {
String DOCKER_VERSIONED_IMAGE_NAME = "${BASE_IMAGE_NAME}:${scmVersion.uncachedVersion.decoratedVersion}"
exec {
workingDir './'
commandLine 'mkdir', '-p', "${buildDir}/container-libs"
}
exec {
workingDir './'
commandLine "${dockerBin}", 'build', '--tag', "${DOCKER_VERSIONED_IMAGE_NAME}", './'
}
exec {
workingDir './'
commandLine "${dockerBin}", 'tag', "${DOCKER_VERSIONED_IMAGE_NAME}", "${BASE_IMAGE_NAME}:latest"
}
}
}
project.version = scmVersion.uncachedVersion.decoratedVersion
task fixReleaseVersion(type: Task) {
doLast {
version = scmVersion.uncachedVersion.decoratedVersion
}
}
createRelease.finalizedBy fixReleaseVersion
build.dependsOn fixReleaseVersion
build.finalizedBy buildDockerImage
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
}
uploadArchives {
//XXX configure maven repo
}
wrapper {
gradleVersion = '4.4'
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${ver.protobuf}"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${ver.grpc}"
}
rxgrpc {
artifact = "com.salesforce.servicelibs:rxgrpc:${ver.rxgrpc}:jdk8@jar"
}
}
generateProtoTasks {
all()*.plugins {
grpc {
// To generate deprecated interfaces and static bindService method,
// turn the enable_deprecated option to true below:
option 'enable_deprecated=false'
}
rxgrpc {}
}
}
}
sourceSets {
main {
output.resourcesDir = java.outputDir
}
test {
output.resourcesDir = groovy.outputDir
}
}
idea {
module {
// love reading sources :)
downloadSources = true
// protobuf files generated from proto files
sourceDirs += file("${buildDir}/generated/source/proto/main/java")
generatedSourceDirs += files("${buildDir}/generated/source/proto/main/java")
sourceDirs += file("${buildDir}/generated/source/proto/main/grpc")
generatedSourceDirs += files("${buildDir}/generated/source/proto/main/grpc")
// rxgrpc adaptation
sourceDirs += file("${buildDir}/generated/source/proto/main/rxgrpc")
generatedSourceDirs += files("${buildDir}/generated/source/proto/main/rxgrpc")
// convince intellij to used build as output directory for a module
outputDir compileJava.destinationDir
testOutputDir compileTestGroovy.destinationDir
inheritOutputDirs = false
}
}