forked from jenkins-infra/jenkins.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
282 lines (238 loc) · 8.63 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
/*
* This build.gradle file is to be used for generating the jenkins.io site
*/
buildscript {
repositories {
jcenter()
maven {
url 'https://plugins.gradle.org/m2'
}
}
dependencies {
classpath "org.ajoberstar:gradle-git:1.2.0"
classpath "com.github.jruby-gradle:jruby-gradle-plugin:[1.3.2,2.0)"
/*
* not available on jcenter, only the Gradle plugins portal, this
* plugin also wasn't published with the proper maven metadata so we
* must fetch the version specifically for it
*/
classpath 'gradle.plugin.com.craigburke.gradle:bower-installer-gradle:2.5.1'
}
}
apply plugin: 'com.github.jruby-gradle.base'
apply plugin: 'com.craigburke.bower-installer'
import org.ajoberstar.grgit.Grgit
import com.github.jrubygradle.JRubyExec
ext.gitRef = Grgit.open('.')?.head()?.abbreviatedId
ext.siteOutputDir = "${buildDir}/_site"
ext.userHandbook = "${buildDir}/user-handbook"
description = 'Build for generating jenkins.io'
version = "2.0.${System.env.BUILD_NUMBER ?: '0'}+${ext.gitRef}"
defaultTasks 'assemble', 'archive'
configurations {
asciidoctor
externalFetcher
}
repositories {
/* needed for alpha gems like asciidoctor-pdf */
maven { url 'http://rubygems.lasagna.io/proxy/maven/prereleases/' }
}
dependencies {
/* For rendering colored output for warnings/etc */
asciidoctor 'rubygems:colorize:[0.8.1,1.0)'
/* used for primary site generation */
asciidoctor 'rubygems:awestruct:[0.5.7,0.6)'
/* ensure we pull in a more recent version of asciidoctor */
asciidoctor 'rubygems:asciidoctor:[1.5.5,2.0)'
/* used for legacy markdown template processing via tilt */
asciidoctor 'rubygems:kramdown:[1.9.0,2.0)'
/* contains a number of useful awestruct extensions */
asciidoctor 'rubygems:awestruct-ibeams:[0.4.1,)'
/* 1.2.0 causes 'C extensions are not supported' error. It's known that
JRuby's C extensions are deprecated */
asciidoctor 'rubygems:eventmachine:[1.0, 1.2)'
/* newer or beta versions of unf don't package their extensions properly */
asciidoctor 'rubygems:unf:0.1.4'
/* needed for generating handbook PDFs and others */
asciidoctor 'rubygems:asciidoctor-pdf:[1.5.0,)'
/* listen 3.1.2 breaks support for JRuby see :
* <https://github.com/guard/listen/pull/377#issuecomment-216241081>
*/
asciidoctor 'rubygems:listen:3.1.1'
/* ffi-1.9.13 doesn't seem to like embedded JRuby sub-process invocations
* <https://gist.github.com/rtyler/87644f89da7c828c3be2e3b2400c9edb>
*/
asciidoctor 'rubygems:ffi:1.9.10'
/* used for processing haml templates (haml.info) */
asciidoctor 'rubygems:haml:4.0.7'
/* used for processing inline liquid templating */
asciidoctor 'rubygems:liquid:[3.0.6,4.0)'
/* used for syntax highlighting */
asciidoctor 'rubygems:coderay:[1.1.0,2.0)'
/* needed for clean HTTP accesses */
externalFetcher 'rubygems:faraday:[0.9.2,1.0)'
externalFetcher 'rubygems:faraday_middleware:[0.9.2,1.0)'
/* needed for unzipping external resources */
externalFetcher 'rubygems:rubyzip:1.2.0'
/* used for running release.rss.groovy */
externalFetcher localGroovy()
}
/* for fetching javascript assets that we need for building the legacy and new
* versions of the site
*/
bower {
/* weird syntax is weird */
/* jQuery and jQuery UI are both used by the "legacy" download picker and
* can likely go away once the legacy site is sunsetted
*/
'jquery' ('1.11.3') {
source 'dist/**'
}
'jquery-ui' ('1.11.4') {
source '**/*.js'
source 'themes/base/**' >> 'themes/base/'
}
/* needed for jenkins.io */
'bootstrap' ('4.0.0-alpha.2') {
source 'dist/**'
}
'ekko-lightbox' ('3.3.3') {
source 'dist/**'
}
'tether' ('1.1.1') {
source 'dist/**'
}
}
task fetchExamples(type: Exec) {
group 'Site'
description 'Fetch pipeline-examples for inclusion in the site'
commandLine './scripts/fetch-examples'
inputs.source file('scripts/fetch-examples')
}
task fetchReleaseHistory(type: JavaExec) {
group 'Site'
classpath = configurations.externalFetcher
main = 'groovy.ui.GroovyMain'
def groovyScript = "${projectDir}/scripts/release.rss.groovy"
args groovyScript, "https://updates.jenkins.io/release-history.json"
file(project.ext.siteOutputDir).mkdirs()
standardOutput file("${project.ext.siteOutputDir}/releases.rss").newOutputStream()
inputs.source file(groovyScript)
}
task fetchExternalResources(type: JRubyExec) {
group 'Site'
description 'Fetch external resources which need to be compiled into the site'
script "${projectDir}/scripts/fetch-external-resources"
configuration 'externalFetcher'
inputs.source file("${projectDir}/scripts/fetch-external-resources")
}
task compileContent(type: JRubyExec) {
group 'Site'
description 'Compile the site using the awestruct CLI'
dependsOn 'fetchExternalResources', 'fetchExamples', 'prepareJavaScripts'
script 'awestruct'
scriptArgs '--generate', '--verbose',
/* forcefully set the site.base_url since the config is not
* being respected
*/
'--url', 'https://jenkins.io',
'--source-dir', "${projectDir}/${contentDir}",
'--output-dir', project.ext.siteOutputDir
if (hasProperty('profile')) {
scriptArgs '--profile', profile
}
/* without the --force option, awestruct is not smart enough to regenerate
* files based on includes */
configuration 'asciidoctor'
inputs.source fileTree(projectDir)
.include("${contentDir}/**/*.adoc")
.include("${contentDir}/**/*.haml")
.include("${contentDir}/**/*.md")
}
task prepareJavaScripts {
group 'Site'
description 'Fetch JavaScript/CSS dependencies for generating the site'
dependsOn bowerInstall
doLast {
def assetsDir = file("${contentDir}/assets")
assetsDir.mkdirs()
copy {
from "${projectDir}/src/assets"
into assetsDir
}
}
}
task prepareUserHandbook(type: JRubyExec) {
group 'Handbook'
description 'Generate the raw .adoc file for PDF generation'
script "${projectDir}/scripts/generate-handbook-pdf"
scriptArgs "${project.ext.userHandbook}.adoc"
configuration 'asciidoctor'
inputs.source file("${projectDir}/scripts/generate-handbook-pdf")
}
task printHandbook(type: JRubyExec) {
group 'Handbook'
description 'Take the computed .adof file and generate a PDF'
dependsOn prepareUserHandbook
script 'asciidoctor-pdf'
scriptArgs '--base-dir', 'content', '--out-file',
"${project.ext.userHandbook}.pdf",
"${project.ext.userHandbook}.adoc"
configuration 'asciidoctor'
doLast {
file(project.ext.siteOutputDir).mkdirs()
copy {
from "${project.ext.userHandbook}.pdf"
into project.ext.siteOutputDir
}
}
}
task printBooks {
group 'Handbook'
description 'Generate all non-HTML-based handbook files'
dependsOn printHandbook
}
task assemble {
group 'Site'
description 'Assemble the full site'
dependsOn fetchExternalResources,
fetchExamples,
fetchReleaseHistory,
prepareJavaScripts,
compileContent,
printBooks
}
task archiveBeta(type: Zip) {
def computedDirName = "jenkins.io-${project.version}.beta"
group 'Site'
description 'Create a zip archive of the site for deployment'
dependsOn assemble
archiveName "${computedDirName}.zip"
into(computedDirName) { from project.ext.siteOutputDir }
File targetDir = file("${buildDir}/archives")
targetDir.mkdirs()
destinationDir = targetDir
}
task archive {
group 'Site'
description 'Create a zip archive of the site for deployment'
dependsOn archiveBeta
}
task run(type:Exec) {
description 'inspect the generated build/_site locally through http://localhost:4242/'
workingDir 'build/_site'
commandLine 'python','-m','SimpleHTTPServer', '4242'
}
def defineDevTask(name, body) {
task(name, type: JRubyExec) {
description "Run in the development mode with live reloading. Point your browser to http://localhost:4242/"
script 'awestruct'
scriptArgs '--dev',
'--source-dir', "${projectDir}/${contentDir}",
'--output-dir', project.ext.siteOutputDir
configuration 'asciidoctor'
body.delegate = delegate
body()
}
}
defineDevTask('dev') {}