forked from kellyrob99/Jenkins-api-tour
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
133 lines (117 loc) · 3.23 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
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'project-report'
apply plugin: 'maven'
apply plugin: 'code-quality'
apply plugin: 'jetty'
flavor = hasProperty('switch') ? 'hudson' : 'jenkins'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.linkedin:org.linkedin.gradle-plugins:1.5.0'
}
}
apply plugin: 'org.linkedin.userConfig'
apply plugin: 'org.linkedin.spec'
repositories {
mavenRepo urls: ['http://repo.jenkins-ci.org/repo/']
mavenLocal()
mavenCentral()
}
configurations {
jenkins
hudson
}
dependencies {
compile gradleApi()
compile spec.libraries.ivy
compile spec.libraries.httpBuilder
compile spec.libraries["${flavor}Cli".toString()]
runtime 'commons-cli:commons-cli:1.2'
testCompile spec.libraries.spock
testCompile spec.libraries.junit
groovy spec.libraries.groovy
jenkins spec.libraries.jenkins
hudson spec.libraries.hudson
}
group = spec.group
version = spec.version
System.properties['HUDSON_HOME'] = "$buildDir/$flavor".toString() //force Jenkins/Hudson to run within the build workspace
test {
dependsOn jettyRunWar
//takes a while to startup and otherwise tests run while still initializing
doFirst {
boolean keepGoing = true
int tries = 0
final int maxTries = 30
final long sleep = 5000
while (keepGoing && tries < maxTries)
{
try
{
keepGoing = 'http://localhost:8080/'.toURL().text.contains('Please wait')
}
catch (e)
{
//logger.warn("Exception thrown: $e")
}
logger.warn("Waiting for $flavor ${++tries} ($sleep ms)")
Thread.sleep(sleep)
}
}
/**
* Definitely some differences here in terms of both functionality(missing who-am-i method for instance)
* and in content of returned values.
*/
if(flavor == 'hudson')
{
exclude '**/HudsonCliApiTest.class'
}
}
jar.enabled = true
[jettyRun, jettyRunWar]*.daemon = true
/**
* Use the jetty plugin to run the build server.
*/
jettyRunWar {
httpPort = 9001
dependsOn configurations."$flavor"
webApp = configurations."$flavor".resolve().find {it.name.endsWith('war')}
contextPath = ''
}
task wrapper(type: Wrapper) {
gradleVersion = '1.2'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: groovydoc) {
classifier = 'javadoc'
from groovydoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
idea{
project {
jdkName = '1.6'
languageLevel = '1.6'
ipr {
withXml { provider ->
def root = provider.asNode()
root.component.find { it.@name == 'VcsDirectoryMappings' }.mapping[0].@vcs = 'Git'
// Set gradle home
def gradleSettings = root.appendNode('component', [name: 'GradleSettings'])
gradleSettings.appendNode('option', [name: 'SDK_HOME', value: gradle.gradleHomeDir.absolutePath])
}
}
}
module {
downloadJavadoc = true
downloadSources = true
}
}