forked from sheehan/job-dsl-gradle-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
119 lines (94 loc) · 3.3 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
apply plugin: 'groovy'
sourceSets {
jobs {
groovy {
srcDirs 'jobs'
compileClasspath += main.compileClasspath
}
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
repositories {
mavenCentral()
jcenter()
maven { url 'http://repo.jenkins-ci.org/releases/' }
}
configurations {
testPlugins {}
}
// Exclude buggy Xalan dependency this way the JRE default TransformerFactory is used
// The xalan pulled in by htmlunit does not properly deal with spaces folder / job names
configurations.all*.exclude group: 'xalan'
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.8'
compile "org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}"
compile 'org.kohsuke:github-api:1.70'
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile 'cglib:cglib-nodep:2.2.2' // used by Spock
// Jenkins test harness dependencies
testCompile 'org.jenkins-ci.main:jenkins-test-harness:2.8'
testCompile "org.jenkins-ci.main:jenkins-war:${jenkinsVersion}"
testCompile "org.jenkins-ci.main:jenkins-war:${jenkinsVersion}:war-for-test@jar"
// Job DSL plugin including plugin dependencies
testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"
testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}@jar"
testCompile 'org.jenkins-ci.plugins:structs:1.6@jar'
testCompile 'org.jenkins-ci.plugins:cloudbees-folder:5.12@jar'
// plugins to install in test instance
testPlugins 'org.jenkins-ci.plugins:ghprb:1.31.4'
testPlugins 'com.coravy.hudson.plugins.github:github:1.19.0'
testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:5.12'
testPlugins 'org.jenkins-ci.plugins:credentials:2.1.10'
// for the RestApiScriptRunner
compile('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') {
exclude(module: 'groovy')
}
// for the RestApiScriptRunner
compile('org.apache.ant:ant:1.9.7')
}
task resolveTestPlugins(type: Copy) {
from configurations.testPlugins
into new File(sourceSets.test.output.resourcesDir, 'test-dependencies')
include '*.hpi'
include '*.jpi'
def mapping = [:]
doFirst {
configurations.testPlugins.resolvedConfiguration.resolvedArtifacts.each {
mapping[it.file.name] = "${it.name}.${it.extension}"
}
}
rename { mapping[it] }
doLast {
List<String> baseNames = source*.name.collect { mapping[it] }.collect { it[0..it.lastIndexOf('.') - 1] }
new File(destinationDir, 'index').setText(baseNames.join('\n'), 'UTF-8')
}
}
defaultTasks 'libs'
configurations {
libs
}
dependencies {
libs 'org.kohsuke:github-api:1.70'
}
task cleanLibs(type: Delete) {
delete 'lib'
}
task libs(type: Copy) {
into 'lib'
from configurations.libs
}
test {
dependsOn tasks.resolveTestPlugins
inputs.files sourceSets.jobs.groovy.srcDirs
// set build directory for Jenkins test harness, JENKINS-26331
systemProperty 'buildDirectory', project.buildDir.absolutePath
}
task rest(dependsOn: 'classes', type: JavaExec) {
main = 'com.dslexample.rest.RestApiScriptRunner'
classpath = sourceSets.main.runtimeClasspath
systemProperties System.getProperties()
}
task wrapper(type: Wrapper) {
gradleVersion = '3.4.1'
}