-
Notifications
You must be signed in to change notification settings - Fork 103
/
build.gradle
404 lines (349 loc) · 15.5 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
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:1.2.0'
classpath 'com.netflix.nebula:nebula-dependency-recommender:3.6.3'
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
classpath 'gradle.plugin.org.openrepose:gradle-jaxb-plugin:2.3.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
classpath 'org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11:0.8.2'
classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.1'
classpath 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
classpath 'com.netflix.nebula:gradle-git-scm-plugin:3.0.1'
classpath 'com.netflix.nebula:gradle-ospackage-plugin:3.4.0'
classpath 'org.hidetake:gradle-ssh-plugin:1.0.5'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.ajoberstar:gradle-git:1.3.2'
classpath 'com.bmuschko:gradle-vagrant-plugin:2.0'
classpath 'com.bmuschko:gradle-docker-plugin:3.0.6'
}
}
apply plugin: 'org.sonarqube'
apply plugin: 'nebula.gradle-git-scm'
apply plugin: 'org.hidetake.ssh'
ext {
reposeCodename = "Ezio"
scalaMajor = '2'
scalaMinor = '11'
scalaPatch = '7'
scalaMajDotMin = "$scalaMajor.$scalaMinor"
}
task('buildAll', description: 'Builds all the sub-projects.', group: 'release')
task('publishToPackageRepo', group: 'publishing', description: 'Publishes the debian and rpm packages to the package repo.',
dependsOn: [':repose-aggregator:artifacts:cli-utils:buildDeb',
':repose-aggregator:artifacts:cli-utils:buildRpm',
':repose-aggregator:artifacts:experimental-filter-bundle:buildDeb',
':repose-aggregator:artifacts:experimental-filter-bundle:buildRpm',
':repose-aggregator:artifacts:extensions-filter-bundle:buildDeb',
':repose-aggregator:artifacts:extensions-filter-bundle:buildRpm',
':repose-aggregator:artifacts:filter-bundle:buildDeb',
':repose-aggregator:artifacts:filter-bundle:buildRpm',
':repose-aggregator:artifacts:repose-lint:buildDeb',
':repose-aggregator:artifacts:repose-lint:buildRpm',
':repose-aggregator:artifacts:valve:buildDeb',
':repose-aggregator:artifacts:valve:buildRpm',
':repose-aggregator:artifacts:web-application:buildDeb',
':repose-aggregator:artifacts:web-application:buildRpm',
':buildAll',
]) << {
ssh.run {
session(remotes.packageRepo) {
put from: tasks.getByPath(':repose-aggregator:artifacts:cli-utils:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:cli-utils:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:experimental-filter-bundle:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:experimental-filter-bundle:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:extensions-filter-bundle:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:extensions-filter-bundle:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:filter-bundle:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:filter-bundle:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:repose-lint:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:repose-lint:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:valve:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:valve:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:web-application:buildDeb').outputs.files, into: '/home/repose-dev/RELEASES'
put from: tasks.getByPath(':repose-aggregator:artifacts:web-application:buildRpm').outputs.files, into: '/home/repose-dev/RELEASES'
}
}
}
task('tagVersion', description: 'Tag the repository with the current version.', group: 'release', dependsOn: [buildAll]) << {
scmFactory.create().tag(version)
}
task('exportVersion', description: 'Write the current build version out to a properties file.') << {
file("$rootDir/repose-aggregator/build/release-version.properties").text = 'RELEASE_VERSION=' + version + System.lineSeparator()
}
task('release', description: 'Release the project and publish to all repos.', group: 'release', dependsOn: [exportVersion, tagVersion, publishToPackageRepo])
allprojects {
group = 'org.openrepose'
def baseVersion = '8.6.2.0'
version = project.hasProperty('release') ? baseVersion : "$baseVersion-SNAPSHOT"
apply plugin: 'idea'
apply plugin: 'nebula.dependency-recommender'
repositories {
mavenCentral()
maven {
url "https://maven.research.rackspacecloud.com/content/groups/aggregate/"
}
maven {
url 'https://build.shibboleth.net/nexus/content/repositories/releases'
}
}
ext {
docsHome = "http://www.openrepose.org/versions/$version/index.html".toString()
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'scala'
apply plugin: 'org.unbroken-dome.test-sets'
apply plugin: 'nebula.provided-base'
apply plugin: 'org.openrepose.gradle.plugins.jaxb'
apply plugin: 'checkstyle'
apply plugin: 'codenarc'
apply plugin: 'scalaStyle'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'jacoco'
apply plugin: 'nebula.maven-publish'
apply plugin: 'signing'
dependencies {
jaxb "com.sun.xml.bind:jaxb-xjc"
jaxb "com.sun.xml.bind:jaxb-impl"
jaxb "javax.xml.bind:jaxb-api"
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-ant"
//todo: remove these once gradle bug with zinc compiler is fixed
zinc 'com.typesafe.zinc:zinc:0.3.9'
zinc 'org.scala-lang:scala-library:2.10.5'
}
testSets {
integrationTest
}
check.dependsOn integrationTest
integrationTest.mustRunAfter test
sourceCompatibility = 1.8
targetCompatibility = 1.8
task transformXSDs() {
description "Runs xml through an xslt transform"
ext.outputDir = "$buildDir/src/generated-xsd"
def xsltFile = "$rootDir/repose-aggregator/src/config/xsl/remove-1.1-elements.xsl"
def schemaBaseDir = "$projectDir/src/main/resources/META-INF/schema"
//If they set a property for the jaxbXSLT file override our default
if (project.hasProperty('jaxbXsltFile')) {
xsltFile = project.jaxbXsltFile
}
if (project.hasProperty('jaxbSchemaBase')) {
schemaBaseDir = project.jaxbSchemaBase
}
inputs.files(
fileTree(dir: schemaBaseDir, includes: ["**/*.xsd", "**/*.xjb"]),
file(xsltFile)
)
outputs.dir outputDir
doLast {
file(outputDir).mkdirs()
//Find all XSDs in the src/main/resources/META-INF.schema
if (file(xsltFile).exists() && file(schemaBaseDir).exists()) {
logger.lifecycle("Transforming Schemas")
ant.xslt(
extension: '.xsd',
basedir: schemaBaseDir,
includes: "**/*.xsd",
style: xsltFile,
destdir: "${outputDir}"
)
} else {
logger.lifecycle("NOT Transforming Schemas")
copy {
from schemaBaseDir
into outputDir
include "**/*.xsd"
}
}
//Copy over any bindings.xjb into their appropriate directories
logger.lifecycle("Copying xjb's")
copy {
from schemaBaseDir
into outputDir
include "**/*.xjb"
}
}
}
def generatedDir = "${buildDir}/src/generated-sources"
jaxb {
xsdDir transformXSDs.outputDir
bindingsDir = transformXSDs.outputDir
xjc {
destinationDir = generatedDir
generateEpisodeFiles = false
}
}
xjc.dependsOn transformXSDs
sourceSets {
generated {
java {
srcDirs += generatedDir
}
output.classesDir = sourceSets.main.output.classesDir
}
main {
java {
compileClasspath += generated.output
runtimeClasspath += generated.output
}
}
}
[JavaCompile, ScalaCompile, GroovyCompile].collect { type ->
tasks.withType(type) {
dependsOn('xjc')
}
}
configurations {
compile.exclude group: 'commons-logging', module: 'commons-logging'
testCompile.exclude group: 'xerces', module: 'xerces'
}
checkstyle {
configFile = file("$rootDir/repose-aggregator/src/config/styles/checkstyle.xml")
sourceSets = sourceSets.matching {it.name != 'generated'}
}
codenarc {
configFile = file("$rootDir/repose-aggregator/src/config/styles/codenarc.xml")
}
//todo: write a good one of these plugins, because this is garbage
scalaStyle {
configLocation = "$rootDir/repose-aggregator/src/config/styles/scalastyle_config.xml"
includeTestSourceDirectory = true
source = "src/main/scala"
testSource = "src/test/scala"
failOnWarning = true
}
check.dependsOn scalaStyle
license {
header file("$rootDir/repose-aggregator/src/config/license/LICENSE.txt")
mapping {
scala = 'SLASHSTAR_STYLE'
}
exclude "**/*.cfg.xml"
exclude "**/log4j2*.xml"
sourceSets = sourceSets.matching {it.name != 'generated'}
}
//todo: for some reason jacoco freaks when we do clean and build together
jacoco {
toolVersion = "0.7.6.201602180812"
}
test {
jacoco {
destinationFile = file("$rootDir/repose-aggregator/build/jacoco/jacocoTest.exec")
}
}
integrationTest {
jacoco {
destinationFile = file("$rootDir/repose-aggregator/build/jacoco/jacocoIntegrationTest.exec")
}
systemProperty 'jacocoArguments', jacoco.getAsJvmArg()
}
if(project.hasProperty('sonarBuild')) {
tasks.withType(Test) {
it.ignoreFailures = true
}
}
// Create an empty classes directory to satisfy Sonar
// This is necessary since Sonar requires class directories to exist if the Java plugin is applied, which
// is currently done on all sub-projects. Sub-projects without any classes, like some of those under
// :repose-aggregator:artifacts, will break Sonar without this line.
// TODO: Remove this line once future versions of the Sonar plugin support a missing classes/main/ directory.
file("$buildDir/classes/main").mkdirs()
jar {
manifest {
attributes(
"Specification-Title": "Repose Components - $project.name",
"Specification-Vendor": "Rackspace US, Inc.",
"Specification-Version": version,
"Implementation-Title": "Repose Components - $project.name",
"Implementation-Version": version,
"Implementation-Vendor": "Rackspace US, Inc.",
"Implementation-Vendor-Id": project.group,
"Built-By": System.getProperty('user.name'),
"Build-Jdk": org.gradle.internal.jvm.Jvm.current(),
"Created-By": "Gradle $project.gradle.gradleVersion",
)
}
}
idea {
module {
sourceDirs += file("$generatedDir")
generatedSourceDirs += file("$generatedDir")
}
}
publishing {
repositories {
maven {
name 'reposeNexus'
if (project.hasProperty('release')) {
url 'https://maven.research.rackspacecloud.com/content/repositories/releases'
} else {
url 'https://maven.research.rackspacecloud.com/content/repositories/snapshots'
}
credentials {
username project.hasProperty('maven.repo.username') ? property('maven.repo.username') : 'Need to provide an actual username'
password project.hasProperty('maven.repo.password') ? property('maven.repo.password') : 'Need to provide an actual password'
}
}
}
publications {
nebula(MavenPublication) {
if(project.hasProperty('release')) {
artifact source: signArchives.singleSignature, extension: 'asc'
}
//when we include the signature it tries to switch the packaging in the pom to pom,
// i just remove it here, because the default in maven is jar if you don't specify,
// so i can go fix it only where it needs it
pom.withXml { XmlProvider xml ->
def root = xml.asNode()
root.get("packaging").each { root.remove(it) }
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
sign configurations.archives
}
buildAll.dependsOn build
publish.dependsOn buildAll
project.tasks.getByPath(':release').dependsOn publish
}
dependencyRecommendations {
propertiesFile file: file('versions.properties')
}
//this will let us access the a couple of the versions while still keeping a single source of truth
project.ext.versionProperties = new Properties()
project.ext.versionProperties.load(new FileInputStream("$rootDir/versions.properties"))
sonarqube {
properties {
property "sonar.dynamicAnalysis", "reuseReports"
property "sonar.jacoco.reportPath", "$rootDir/repose-aggregator/build/jacoco/jacocoTest.exec"
property "sonar.jacoco.itReportPath", "$rootDir/repose-aggregator/build/jacoco/jacocoIntegrationTest.exec"
}
}
remotes {
packageRepo {
user = 'repose-dev'
host = 'repo.openrepose.org'
def repoKey = new File("${System.properties['user.home']}/.ssh/repo_key")
if (repoKey.exists()) {
identity = file(repoKey)
} else {
identity = file("${System.properties['user.home']}/.ssh/id_rsa")
}
def systemKnownHosts = new File("/etc/ssh/ssh_known_hosts")
if (systemKnownHosts.exists()) {
knownHosts = file(systemKnownHosts)
}
}
}