This repository has been archived by the owner on Sep 8, 2019. It is now read-only.
forked from jenkinsci/job-dsl-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
201 lines (168 loc) · 5.87 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
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'org.ajoberstar.git-publish' version '0.3.3'
id 'com.github.onslip.gradle-one-jar' version '1.0.5'
// need to be in the root project as workaround for https://github.com/michel-kraemer/gradle-download-task/issues/48
id 'de.undercouch.download' version '3.1.2'
}
defaultTasks 'build' // for BuildHive
configure(subprojects - project(':job-dsl-api-viewer')) {
group = 'org.jenkins-ci.plugins'
apply plugin: 'groovy'
apply plugin: 'codenarc'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile "org.codehaus.groovy:groovy-all:${groovyVersion}"
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile 'junit:junit:4.12'
testCompile 'cglib:cglib-nodep:3.2.5' // used by Spock
testCompile 'org.objenesis:objenesis:2.5.1' // used by Spock
}
codenarc {
toolVersion = '1.1'
configFile = file('../config/codenarc/rules.groovy')
}
codenarcTest {
configFile = file('../config/codenarc/rules-test.groovy')
}
}
project(':job-dsl-core') {
repositories {
jcenter()
maven {
url('https://repo.jenkins-ci.org/public/')
}
}
apply plugin: 'application'
apply plugin: 'gradle-one-jar'
apply plugin: 'maven-publish'
sourceSets {
ast {
groovy {
srcDir 'src/ast/groovy'
}
resources {
srcDir 'src/ast/resources'
}
}
examples {
groovy {
srcDirs 'src/main/docs/examples'
}
}
main.compileClasspath += sourceSets.ast.output
test.compileClasspath += sourceSets.ast.output
}
description = 'Generates Jenkins jobs via a DSL'
mainClassName = 'javaposse.jobdsl.Run'
ext {
apiDocData = "${project.buildDir}/dsl.json"
}
dependencies {
astCompile "org.codehaus.groovy:groovy-all:${groovyVersion}"
compile 'commons-codec:commons-codec:1.8' // for Perforce
compile 'xmlunit:xmlunit:1.4' // for runtime use, not just for testing
compile('org.jvnet.hudson:xstream:1.4.7-jenkins-1') {
exclude group: 'xmlpull'
exclude group: 'xpp3'
}
}
codenarcExamples {
configFile = file('../config/codenarc/rules-examples.groovy')
}
jar {
manifest {
attributes 'Main-Class': project.mainClassName
attributes 'Implementation-Version': version
attributes 'Jenkins-ClassFilter-Whitelisted': 'true'
}
}
task jarSources(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task jarJavadocs(type: Jar, dependsOn: 'javadoc') {
from project.javadoc.destinationDir
classifier = 'javadoc'
}
task jarGroovydocs(type: Jar, dependsOn: 'groovydoc') {
from project.groovydoc.destinationDir
classifier = 'groovydoc'
}
task oneJar(type: OneJar) {
mainClass = project.mainClassName
}
task generateApiDoc(type: JavaExec, dependsOn: 'classes') {
main = 'javaposse.jobdsl.dsl.doc.ApiDocGenerator'
classpath = sourceSets.main.runtimeClasspath
args = [version, apiDocData]
inputs.dir "${project.projectDir}/src/main/docs"
outputs.file apiDocData
}
jar {
from(tasks.generateApiDoc) {
into 'javaposse/jobdsl/dsl'
}
}
run {
if (project.hasProperty('args')) {
args project.args.split('\\s+')
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact jarJavadocs
artifact jarGroovydocs
artifact jarSources
artifact oneJar
artifact source: apiDocData, extension: 'json', classifier: 'apidoc' builtBy(project.tasks.generateApiDoc)
}
}
repositories {
maven {
name 'jenkins'
if (project.version.toString().endsWith('-SNAPSHOT')) {
url 'https://repo.jenkins-ci.org/snapshots'
} else {
url 'https://repo.jenkins-ci.org/releases'
}
}
}
}
// gradle-jpi plugin does this for plugins, so we're mimicking it to get our additional artifacts up to repo.jenkinsci.org
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(tasks.publish)) {
PublishingExtension publishingExtension = project.extensions.getByType(PublishingExtension)
def credentials = loadCredentialsForJenkinsCommunityRepository()
publishingExtension.repositories.getByName('jenkins').credentials {
username credentials.userName
password credentials.password
}
}
}
}
private Map loadCredentialsForJenkinsCommunityRepository() {
def dot = new File(System.getProperty('user.home'), '.jenkins-ci.org')
if (!dot.exists()) {
throw new Exception("Trying to deploy to Jenkins community repository but there's no credential file ${dot}. See https://wiki.jenkins-ci.org/display/JENKINS/Dot+Jenkins+Ci+Dot+Org")
}
Properties props = new Properties()
dot.withInputStream { i -> props.load(i) }
[userName: props.userName, password: props.password]
}
gitPublish {
commitMessage = "updated wiki for $version"
repoUri = "git@github.com:$githubUser/job-dsl-plugin.wiki.git"
branch = 'master'
repoDir = file("$buildDir/wiki")
contents {
from 'docs'
filesMatching('*.md') {
filter(ReplaceTokens, tokens: [version: version, jenkinsVersion: jenkinsVersion])
}
}
}
task publishDocs(dependsOn: ['gitPublishPush', ':job-dsl-api-viewer:gitPublishPush'])