forked from linkedin/rest.li
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
454 lines (396 loc) · 13.7 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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/*
Copyright (c) 2012 LinkedIn Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
project.ext.buildScriptDirPath = "${projectDir.path}/build_script"
project.ext.isDefaultEnvironment = !project.hasProperty('overrideBuildEnvironment')
File getEnvironmentScript()
{
final File env = file(isDefaultEnvironment ? 'defaultEnvironment.gradle' : project.overrideBuildEnvironment)
assert env.isFile() : "The environment script [$env] does not exists or is not a file."
return env
}
apply from: environmentScript
apply from: "${buildScriptDirPath}/configBuildScript.gradle"
project.ext.externalDependency = [
'avro': 'org.apache.avro:avro:1.4.0',
'avro_1_6': 'org.apache.avro:avro:1.6.3',
'cglib': 'cglib:cglib-nodep:2.2',
'codemodel': 'com.sun.codemodel:codemodel:2.2',
'commonsCli': 'commons-cli:commons-cli:1.0',
'commonsCodec': 'commons-codec:commons-codec:1.3',
'commonsCompress': 'org.apache.commons:commons-compress:1.2',
'commonsHttpClient': 'commons-httpclient:commons-httpclient:3.1',
'commonsIo': 'commons-io:commons-io:1.4',
'commonsLang': 'commons-lang:commons-lang:2.4',
'easymock': 'org.easymock:easymock:3.1',
'mockito': 'org.mockito:mockito-all:1.9.5',
'guava': 'com.google.guava:guava:10.0',
'httpclient': 'org.apache.httpcomponents:httpclient:4.3.1',
'httpcore': 'org.apache.httpcomponents:httpcore:4.3.1',
'jacksonCore': 'com.fasterxml.jackson.core:jackson-core:2.4.3',
'jacksonDataBind': 'com.fasterxml.jackson.core:jackson-databind:2.4.3',
'jacksonCoreAsl_1_4': 'org.codehaus.jackson:jackson-core-asl:1.4.2',
'jacksonCoreAsl_1_8': 'org.codehaus.jackson:jackson-core-asl:1.8.8',
'javaxInject': 'javax.inject:javax.inject:1',
'jdkTools': files("${System.getProperty('java.home')}/../lib/tools.jar"),
'jetty': 'org.eclipse.jetty.aggregate:jetty-all:8.1.8.v20121106',
'json': 'org.json:json:20070829',
'log4j': 'log4j:log4j:1.2.15',
'mail': 'javax.mail:mail:1.4.1',
'mina': 'org.apache.mina:mina-core:1.1.7',
'netty': 'org.jboss.netty:netty:3.2.3.Final',
'objenesis': 'org.objenesis:objenesis:1.2',
'parseq': 'com.linkedin.parseq:parseq:1.3.6',
'parseq_tracevis': 'com.linkedin.parseq:parseq-tracevis:1.3.6',
'servletApi': 'javax.servlet:javax.servlet-api:3.0.1',
'slf4jApi': 'org.slf4j:slf4j-api:1.6.2',
'slf4jLog4j12': 'org.slf4j:slf4j-log4j12:1.6.2',
'snappy': 'org.iq80.snappy:snappy:0.3',
'testng': 'org.testng:testng:6.4',
'velocity': 'org.apache.velocity:velocity:1.5',
'zookeeper': 'org.apache.zookeeper:zookeeper:3.3.4',
// for restli-spring-bridge ONLY, we must keep these dependencies isolated
'springCore': 'org.springframework:spring-core:3.2.3.RELEASE',
'springContext': 'org.springframework:spring-context:3.2.3.RELEASE',
'springWeb': 'org.springframework:spring-web:3.2.3.RELEASE',
'springBeans': 'org.springframework:spring-beans:3.2.3.RELEASE',
// for restli-guice-bridge ONLY, we should keep these dependencies isolated
'guice': 'com.google.inject:guice:3.0',
'guiceServlet': 'com.google.inject.extensions:guice-servlet:3.0',
// for restli-scala-tools only, we must not add dependencies on scala from any other pegasus modules
'scalaLibrary_2_10': 'org.scala-lang:scala-library:2.10.3',
'scalaCompiler_2_10': 'org.scala-lang:scala-compiler:2.10.3',
'scalaReflect_2_10': 'org.scala-lang:scala-reflect:2.10.3'
];
if (!project.ext.isDefaultEnvironment)
{
spec.external.each { overrideDepKey, overrideDepValue ->
if (project.ext.externalDependency[overrideDepKey] != null)
{
project.ext.externalDependency[overrideDepKey] = overrideDepValue
}
}
}
allprojects {
apply plugin: 'idea'
tasks.withType(JavaCompile).all { JavaCompile compile ->
if(!project.sourceCompatibility.isJava6Compatible()) // lower bound of java versions we support.
{
throw new GradleScriptException("Pegasus required Java 6 or later to build, current version: ${JavaVersion.current()}", null)
}
// for all supported versions that we test build, fail the build if any compilation warnings are reported
compile.options.compilerArgs = ['-Xlint', '-Xlint:-path', '-Xlint:-static', '-Werror']
}
tasks.withType(Javadoc)
{
if (JavaVersion.current().isJava8Compatible())
{
//Disable the crazy super-strict doclint tool in Java 8
//noinspection SpellCheckingInspection
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
afterEvaluate {
if (project.plugins.hasPlugin('pegasus'))
{
configurations {
pluginsRuntime {
visible = false
}
dataTemplateCompile {
visible = false
}
restClientCompile {
visible = false
}
}
dependencies {
pluginsRuntime project(':gradle-plugins')
dataTemplateCompile project(':data')
restClientCompile project(':restli-client')
}
}
else
{
apply from: "${buildScriptDirPath}/cleanGenerated.gradle", to: it
}
}
configurations {
compile {
transitive = false
}
testArtifacts {
visible = false
}
// Exclude a bunch of undesirable, unused dependencies
// that Log4j 1.2.15 drags in; these break the open source
// build since they are not available in maven central.
all*.exclude group: 'javax.jms', module: 'jms'
all*.exclude group: 'com.sun.jdmk', module: 'jmxtools'
all*.exclude group: 'com.sun.jmx', module: 'jmxri'
}
// Default dependencies for all subprojects
dependencies {
compile externalDependency.slf4jApi
// Note this adds a default log4j.xml configuration to all projects testRuntime configuration.
// However, projects can still override simply by creating their own
// src/test/resources/log4j.xml, since that will always appear in the testRuntime classpath
// before this one.
testRuntime project(':log-test-config')
}
if (isDefaultEnvironment)
{
apply plugin: 'maven'
apply from: "${buildScriptDirPath}/maven.gradle"
apply plugin: 'signing'
project.group = 'com.linkedin.pegasus'
repositories {
mavenLocal()
mavenCentral()
}
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier = 'javadoc'
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
signing {
required = { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name project.name
packaging 'jar'
description 'Pegasus is a framework for building robust, scalable service architectures using dynamic discovery and simple asychronous type-checked REST + JSON APIs.'
url 'http://github.com/linkedin/pegasus'
scm {
url '[email protected]:linkedin/pegasus.git'
connection 'scm:git:[email protected]:linkedin/pegasus.git'
developerConnection 'scm:git:[email protected]:linkedin/pegasus.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'sweeboonlim'
name 'Swee Lim'
}
developer {
id 'sihde'
name 'Steve Ihde'
}
developer {
id 'mtagle'
name 'Moira Tagle'
}
developer {
id 'adublinkedin'
name 'Alex Dubman'
}
developer {
id 'CrendKing'
name 'Keren Jin'
}
developer {
id 'DuglsYoung'
name 'Doug Young'
}
developer {
id 'osumampouw'
name 'Oby Sumampouw'
}
developer {
id 'davidhoa'
name 'David Hoa'
}
developer {
id 'cpettitt'
name 'Chris Pettitt'
}
developer {
id 'chikit'
name 'Chi Kit Chan'
}
developer {
id 'apy101'
name 'Angelika Clayton'
}
developer {
id 'jpbetz'
name 'Joe Betz'
}
developer {
id 'karanparikh'
name 'Karan Parikh'
}
developer {
id 'nishanthshankaran'
name 'Nishanth Shankaran'
}
}
}
}
}
}
}
task testJar(type: Jar){
from sourceSets.test.output
classifier = 'tests'
}
artifacts {
testArtifacts testJar
}
// Configure the IDEA plugin to (1) add the codegen as source dirs and (2) work around
// an apparent bug in the plugin which doesn't set the outputDir/testOutputDir as documented
idea.module {
// Gradle docs claim the two settings below are the default, but
// the actual defaults appear to be "out/production/$MODULE_NAME"
// and "out/test/$MODULE_NAME". Changing it so IDEA and gradle share
// the class output directory.
outputDir = sourceSets.main.output.classesDir
testOutputDir = sourceSets.test.output.classesDir
}
test {
maxHeapSize = '1g'
useTestNG() {
excludeGroups 'not_implemented'
excludeGroups 'integration'
excludeGroups 'd2integration'
excludeGroups 'integration_external_product_dependent'
excludeGroups 'known_issue'
excludeGroups 'withoutAssertion'
}
}
task asyncTests(type: Test) {
useTestNG() {
includeGroups 'async'
}
}
task integrationTests(type: Test) {
useTestNG() {
includeGroups 'integration'
excludeGroups 'd2integration'
excludeGroups 'integration_external_product_dependent'
}
}
task d2integrationTests(type: Test) {
useTestNG() {
includeGroups 'd2integration'
excludeGroups 'integration'
excludeGroups 'integration_external_product_dependent'
}
}
//all functional tests which are expected to pass assuming proper environment setup
task allTests(type: Test) {
maxHeapSize = '1g'
useTestNG() {
excludeGroups 'known_issue'
excludeGroups 'not_implemented'
}
}
task integrationExternalProductDependentTests(type: Test) {
useTestNG() {
includeGroups 'integration_external_product_dependent'
}
}
task notImplementedFeaturesTests(type: Test) {
useTestNG() {
includeGroups 'not_implemented'
}
}
task knownIssuesTests(type: Test) {
useTestNG() {
includeGroups 'known_issue'
}
}
task allFailingTests(type: Test) {
useTestNG() {
includeGroups 'known_issue'
includeGroups 'not_implemented'
}
}
task testsWithoutAssertion(type: Test) {
enableAssertions = false
useTestNG() {
includeGroups 'withoutAssertion'
}
}
project.tasks.test.dependsOn(asyncTests)
project.tasks.test.dependsOn(testsWithoutAssertion)
task cleanBuildDir(type: Exec){
delete(rootDir.toString()+'build')
commandLine = ['rm', '-rf', rootDir.toString() + '/build']
workingDir = file(rootDir.toString())
}
task makedir(type:Exec) {
// gradle mkdir does not create dir with "-p" flag on so this is a generic task that takes -Ddirpath=..... parameter
// Usage examples:
// gradle makedir -Ddirpath=abc/xyz
def dir = System.getProperties()['dirpath'] ?: null
if (dir != null){
commandLine = ['mkdir','-p', dir]
workingDir = file(rootDir.toString())
}
}
}
final skippedTests = [:].withDefault {[]}
project.gradle.addListener(new TestListener() {
@Override
void beforeSuite(TestDescriptor suite) {}
@Override
void afterSuite(TestDescriptor suite, TestResult result) {}
@Override
void beforeTest(TestDescriptor testDescriptor) {}
@Override
void afterTest(TestDescriptor testDescriptor, TestResult result) {
if (result.skippedTestCount > 0)
{
skippedTests[testDescriptor.className] << testDescriptor.name
}
}
})
project.gradle.buildFinished { BuildResult result ->
if (skippedTests.size() > 0)
{
final StringBuilder msgBuilder = new StringBuilder("\nThe following tests should be executed but actually skipped. Please fix and try again.");
skippedTests.each { className, methods ->
msgBuilder.append("\nClass: ${className} , Methods: ${methods}")
}
throw new GradleException(msgBuilder.toString())
}
}