-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbuild.gradle
163 lines (138 loc) · 6.2 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
plugins {
id 'java'
id 'groovy'
id 'jacoco'
}
group = 'edgexfoundry'
version = "0.0.1"
description = "Testing EdgeX Global Pipelines Shared Library"
// Spock works with Java 1.7 and above
sourceCompatibility = 1.8
project.buildDir = 'target'
repositories {
// Spock releases are available from Maven Central
mavenCentral()
// Spock snapshots are available from the Sonatype OSS snapshot repository
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://repo.jenkins-ci.org/releases" }
maven { url "https://repo.jenkins-ci.org/public" }
}
// this is for jacoco to know where the source groovy is. Jacoco does not work at the moment
// this only works if you are running clean tests each time
// sourceSets {
// main {
// java { srcDirs = [] }
// groovy { srcDirs += ["$buildDir/classes/vars"] }
// }
// }
sourceSets {
main {
groovy {
srcDirs = ['src/main/groovy']
}
}
}
dependencies {
def withoutIcu = { exclude group: 'com.ibm.icu', module: 'icu4j' }
implementation "org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:2.15@jar"
// mandatory dependencies for using Spock
implementation "org.codehaus.groovy:groovy-all:2.5.8"
implementation "com.cloudbees:groovy-cps:1.31@jar", withoutIcu
implementation "org.slf4j:jcl-over-slf4j:1.7.25"
testImplementation "org.slf4j:log4j-over-slf4j:1.7.25"
testImplementation "org.slf4j:slf4j-api:1.7.25"
testImplementation "ch.qos.logback:logback-core:1.2.3"
testImplementation "ch.qos.logback:logback-classic:1.2.3"
testImplementation "org.apache.commons:commons-csv:1.1"
testImplementation "com.google.guava:guava:20.0"
testImplementation group: 'org.apache.maven', name: 'maven-model', version: '3.0.2'
testImplementation "org.spockframework:spock-core:1.3-groovy-2.5@jar"
// one of these dependencies has a transitive dependency to icu4j which is breaking the test runtime
// `withoutIcu` excludes that dependency...I have not been able to pinpoint which one
// so I added `withoutIcu` to all of them
// Jenkins related
testImplementation "com.homeaway.devtools.jenkins:jenkins-spock:2.1.4", withoutIcu
testImplementation "javax.servlet:javax.servlet-api:3.1.0", withoutIcu
testImplementation "org.jenkins-ci.main:jenkins-core:2.225", withoutIcu
testImplementation "org.jenkins-ci.plugins.workflow:workflow-api:2.40@jar", withoutIcu
testImplementation "org.jenkins-ci.plugins.workflow:workflow-step-api:2.22@jar", withoutIcu
testImplementation "org.jenkins-ci.plugins.workflow:workflow-cps:2.78@jar", withoutIcu
testImplementation "org.jenkins-ci.plugins.workflow:workflow-durable-task-step:2.35@jar", withoutIcu // provides the sh() pipeline step
testImplementation "org.jenkins-ci.plugins.workflow:workflow-basic-steps:2.20@jar", withoutIcu // provides the echo(), withEnv(), dir() pipeline step
testImplementation "org.jenkins-ci.plugins:durable-task:1.33@jar", withoutIcu // transitive dependency for workflow-durable-task-step
testImplementation "org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:2.15@jar", withoutIcu // provides libraryResource() step
testImplementation "org.jenkins-ci:symbol-annotation:1.10", withoutIcu
testImplementation "org.jenkins-ci.plugins:slack:2.35@jar", withoutIcu // provides the slackSend() pipeline step
testImplementation "org.jenkins-ci.plugins:pipeline-stage-step:2.3@jar", withoutIcu // provides stage() step
testImplementation "org.jenkins-ci.plugins:ssh-agent:1.17@jar", withoutIcu // provides sshagent() step
testImplementation "org.jenkins-ci.plugins:credentials:2.3.12@jar", withoutIcu // provides credentials for ssh-agent
testImplementation "org.jenkins-ci.plugins:pipeline-utility-steps:2.6.1@jar", withoutIcu // provides readJson()
testImplementation "org.jenkins-ci.plugins:ws-cleanup:0.38@jar", withoutIcu // provides cleanWs()
testImplementation "org.jenkins-ci.plugins.workflow:workflow-scm-step:2.11@jar", withoutIcu // provides checkout()
testImplementation "org.jenkins-ci.plugins:config-file-provider:3.6.2@jar", withoutIcu // provides the configFileProvider() pipeline step
testImplementation "org.jenkins-ci.plugins:credentials-binding:1.20@jar", withoutIcu // provides withCredentials() step
testImplementation "org.jenkins-ci.plugins:script-security:1.68@jar", withoutIcu
testImplementation "org.jenkins-ci.plugins:docker-commons:1.15@jar"
testImplementation "org.jenkins-ci.plugins:docker-workflow:1.21@jar"
}
test {
systemProperty 'root.loglevel', 'INFO'
systemProperty 'root.appender', 'Stdout'
systemProperty 'test.loglevel', 'INFO'
systemProperty 'logdir', './target/logs'
reports {
junitXml.required = true
}
// prints a summary after test execution
testLogging {
afterSuite { desc, result ->
if (!desc.parent) {
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
}
jacocoTestReport {
reports {
xml.required = true
csv.required = false
html.required = true
}
}
// this is needed for spock to find all the source code in the var directory
task copyGlobalLibVars (type: Copy) {
from "$rootDir/vars"
include '**/*.groovy'
into "$buildDir/classes/vars"
}
compileTestGroovy {
options.incremental = true
options.fork = true
options.failOnError = false
}
compileTestGroovy.dependsOn copyGlobalLibVars
tasks.withType(Test) {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
forkEvery = 100
}
// print the test classpath. Good for debugging ClassNotFound issues
task printClasspath {
doLast {
configurations.testRuntimeClasspath.each { println it }
}
}
// Runs the groovy custom script to generate documentation in MD files
task generateDocumentation (type: JavaExec){
mainClass = 'edgeXDocGenerator'
classpath = sourceSets.main.runtimeClasspath
def config = [
sourcePath : "vars" , // value is mandatory
excludes : [".*DocGenerator.*"] //if no exclusion, then give as []
]
args config.sourcePath, config.excludes
}
// publish the HTML files to GitHub pages
task publish(type: GradleBuild) {
buildFile = 'publish.gradle'
tasks = ['gitPublishPush']
}