forked from rundeck/rundeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
404 lines (359 loc) · 13.9 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
/*
* Copyright 2016 SimplifyOps, Inc. (http://simplifyops.com)
*
* 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.
*/
/**
* Rundeck Master-Build Project
*
* This project does not contain any buildable code and does not generate any
* artifacts, however it allows us to set defaults for the subjects and provides
* Groovy syntax highlighting for gradle build files (like this one)
**/
import org.gradle.plugins.signing.Sign
buildscript {
repositories {
maven {
name 'mavenCentralProxy'
url mavenCentralUrl
if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) {
credentials {
username mavenUser
password mavenPassword
}
}
}
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.adaptc.gradle:nexus-workflow:0.6'
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath group: 'org.yaml', name: 'snakeyaml', version: '1.26'
classpath 'org.owasp:dependency-check-gradle:5.3.2'
}
}
plugins {
id 'com.gradle.build-scan' version '3.2.1'
id "org.dvaske.gradle.git-build-info" version "0.8"
id "com.dorongold.task-tree" version "1.5"
id "org.ajoberstar.grgit" version "2.2.1"
}
apply plugin: 'java'
apply plugin: 'nexus-workflow'
apply plugin: 'eclipse';
apply plugin: 'idea'
apply plugin: 'com.google.osdetector'
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
suppressionFile='cve-suppress.xml'
formats=['HTML','JUNIT']
outputDirectory="build/owasp-reports/junit"
failBuildOnCVSS=8
skipConfigurations=['agent']
scanSet=[]
}
/*
* Project configuration:
* Configure build context(release, publish, etc)
* Setup global project attributes
*/
description = 'The main-build project for Rundeck';
eclipse.project.name = 'rundeck'
ext.exportedProjects = [
":core",
":rundeck-authz:rundeck-authz-api",
":rundeck-authz:rundeck-authz-core",
":rundeck-authz:rundeck-authz-yaml",
":rundeck-storage:rundeck-storage-api",
":rundeck-storage:rundeck-storage-data",
":rundeck-storage:rundeck-storage-filesys",
":rundeck-storage:rundeck-storage-conf",
":rundeckapp"
]
project.ext.environment = project.hasProperty('environment') ? environment : 'development'
project.ext.artifactDir = "$projectDir/artifacts"
def versionProps = new Properties()
file("version.properties").withInputStream { versionProps.load(it) }
def vVersion = versionProps.getProperty('version.version')
def vNum = ext.vNum = versionProps.getProperty('version.number')
def vTag = ext.vTag = project.environment == 'release'? versionProps.getProperty('version.tag') : 'SNAPSHOT'
def vDate = ext.vDate = versionProps.getProperty('version.date')
def vRevision = ext.vRevision = versionProps.getProperty('version.release.number')
if (ext.environment == 'release') {
project.ext.resolvedVersion = vVersion
} else {
project.ext.resolvedVersion = "${vNum}-SNAPSHOT".toString()
}
project.ext.branch = grgit.branch.current().name
project.ext.commit = grgit.head().id
logger.lifecycle("Building version {}", project.resolvedVersion)
allprojects {
version = project.resolvedVersion
ext.isReleaseBuild = false
ext.isSnapshotBuild = false
ext.isDevBuild = false
if(project.environment == 'release'){
ext.isReleaseBuild=true
} else {
ext.isDevBuild=true
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'ch.qos.logback', module: 'logback-core'
}
}
/**
* Defaults for all projects
*/
subprojects {
// set the eclipse project naming convention to rundeck:<path>:<projectName>
// so it matches the logical hierarchy more closely
apply plugin: 'eclipse'
eclipse.project.name = "${project.getParent().eclipse.project.name}:${name}"
}
def buildConf = new org.yaml.snakeyaml.Yaml().load( file('./build.yaml').newDataInputStream() )
project(':rundeckapp') {
it.ext.bundledPlugins = buildConf.rundeck.plugins
it.ext.bundledPlugins += [
project(':plugins:script-plugin'),
project(':plugins:stub-plugin'),
project(':plugins:localexec-plugin'),
project(':plugins:copyfile-plugin'),
project(':plugins:job-state-plugin'),
project(':plugins:flow-control-plugin'),
project(':plugins:jasypt-encryption-plugin'),
project(':plugins:object-store-plugin'),
project(':plugins:orchestrator-plugin'),
project(':plugins:git-plugin'),
project(':plugins:source-refresh-plugin'),
project(':plugins:upvar-plugin')
]
}
// prompt for PGP key passphrase if not set
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign } && project.hasProperty("signing.keyId") && !project.hasProperty( "signing.password") && !project.isDevBuild) {
// Use Java 6's console to read from the console (no good for a CI environment)
def console = System.console()
console.printf "\n\nWe have to sign some things in this build.\n\nPlease enter your signing details.\n\n"
//def id = console.readLine("PGP Key Id: ")
//def file = console.readLine("PGP Secret Key Ring File (absolute path): ")
def password = console.readPassword("PGP Private Key Password: ")
//allprojects { ext."signing.keyId" = id }
//allprojects { ext."signing.secretKeyRingFile" = file }
allprojects { ext."signing.password" = password }
console.printf "\nThanks.\n\n"
}
}
//subproject libs that are uploaded to maven central
exportedProjects.each {
project(it) {
apply from: "${rootDir}/gradle/java.gradle"
configurations {
existing
}
def archiveName = project.name
if (! archiveName.startsWith('rundeck'))
archiveName = "rundeck-${project.name}"
else if (archiveName.startsWith('rundeckapp'))
archiveName = project.name.replace('rundeckapp', 'rundeck')
/* Modify auto-gen POM which gets picked up by Bintray */
install {
repositories.mavenInstaller {
pom.project {
artifactId archiveName
groupId project.group
inceptionYear '2014'
packaging 'jar'
version version
name "Rundeck library ${archiveName}"
description project.description?:'Rundeck'
url 'http://rundeck.org'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url 'https://github.com/rundeck/rundeck'
connection 'scm:git:[email protected]/rundeck/rundeck.git'
developerConnection 'scm:git:[email protected]:rundeck/rundeck.git'
}
developers {
developer {
id('gschueler')
name('Greg Schueler')
email('[email protected]')
}
}
parent {
groupId('org.sonatype.oss')
artifactId('oss-parent')
version('7')
}
}
}
}
apply plugin: 'signing'
//********* artifact signing *********
if (isReleaseBuild && project.hasProperty("signing.keyId")) {
signing {
sign configurations.archives
}
} else {
task signArchives {
// do nothing
}
}
//build a pom we reuse for both maven builds and release to sonatype
ext.publishPom = pom {
project {
artifactId archiveName
groupId project.group
inceptionYear '2014'
packaging 'jar'
version version
name "Rundeck library ${archiveName}"
description project.description?:'Rundeck'
url 'http://rundeck.org'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url 'https://github.com/rundeck/rundeck'
connection 'scm:git:[email protected]/rundeck/rundeck.git'
developerConnection 'scm:git:[email protected]:rundeck/rundeck.git'
}
developers {
developer {
id('gschueler')
name('Greg Schueler')
email('[email protected]')
}
}
parent {
groupId('org.sonatype.oss')
artifactId('oss-parent')
version('7')
}
}
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.archives
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
authentication(userName: findProperty('sonatypeUsername'), password: findProperty('sonatypePassword'))
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: findProperty('sonatypeUsername'), password: findProperty('sonatypePassword'))
}
pom = project.publishPom
}
}
task copyExisting {
inputs.dir 'build/libs'
inputs.dir 'build/poms'
outputs.dir 'build/existing'
doLast {
copy {
from "build/libs"
from "build/poms"
into "build/existing"
exclude "*.original"
rename { file ->
if (file =~ /^pom/)
return "$project.name-${version}.pom"
}
}
}
}
task discoverExisting {
dependsOn copyExisting
doLast {
file("build/existing").eachFile {f ->
artifacts {
existing file: f, name: archiveName
}
}
}
}
task configureUploadExisting {
dependsOn discoverExisting
doLast {
uploadExisting {
repositories.mavenDeployer {
dependsOn "discoverExisting"
configuration = configurations.existing
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
authentication(userName: findProperty('sonatypeUsername'), password: findProperty('sonatypePassword'))
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: findProperty('sonatypeUsername'), password: findProperty('sonatypePassword'))
}
}
}
}
}
uploadExisting.dependsOn(configureUploadExisting)
//utility to create a pom for building
if(!(project.name in ['core','launcher'])){
//:core buildfile will generate its own pom for specialized purpose
task('createPom').doLast {
publishPom.writeTo("pom.xml")
}
}
}
}
task bashVersionInfo {
doLast {
println """\
|VERSION_FULL=${project.resolvedVersion}
|VERSION_NUMBER=${project.vNum}
|VERSION_TAG=${project.vTag}
|VERSION_DATE=${project.vDate}
|VERSION_REVISION=${project.vRevision}""".stripMargin()
}
}
task alljavadoc(type: Javadoc) {
source exportedProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(exportedProjects.collect { project(it).sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
/* Workaround for Bintray plugin attaching task to subprojects */
gradle.taskGraph.whenReady { taskGraph ->
def tasks = taskGraph.getAllTasks()
tasks.each { task ->
if (task.name == 'bintrayUpload' && ! exportedProjects.contains(task.project.path)) {
task.enabled = false
}
}
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
// Limit heap size in forked test processes for CI
test {
maxHeapSize = "512m"
}