Skip to content

Commit

Permalink
Add support for generating a user handbook by the Gradle build process
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Tyler Croy committed Dec 19, 2016
1 parent f58c221 commit 9edda43
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
41 changes: 39 additions & 2 deletions build.gradle
Expand Up @@ -27,6 +27,7 @@ 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}"
Expand Down Expand Up @@ -137,7 +138,7 @@ task fetchReleaseHistory(type: JavaExec) {
classpath = configurations.externalFetcher
main = 'groovy.ui.GroovyMain'
def groovyScript = "${projectDir}/scripts/release.rss.groovy"
args groovyScript, "http://updates.jenkins.io/release-history.json"
args groovyScript, "https://updates.jenkins.io/release-history.json"

file(project.ext.siteOutputDir).mkdirs()

Expand Down Expand Up @@ -189,6 +190,40 @@ task prepareJavaScripts {
}
}
}
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'
Expand All @@ -197,7 +232,8 @@ task assemble {
fetchExamples,
fetchReleaseHistory,
prepareJavaScripts,
compileContent
compileContent,
printBooks
}

task archiveBeta(type: Zip) {
Expand All @@ -220,6 +256,7 @@ task archive {
dependsOn archiveBeta
}


task run(type:Exec) {
description 'inspect the generated build/_site locally through http://localhost:4242/'
workingDir 'build/_site'
Expand Down
4 changes: 1 addition & 3 deletions scripts/generate-handbook-pdf
Expand Up @@ -3,7 +3,7 @@
require 'yaml'

HANDBOOK_DIR = 'content/doc/book'
OUTPUT_ADOC = 'book.adoc'
OUTPUT_ADOC = ARGV.first

documents = []
chapters = YAML.load_file(File.open("#{HANDBOOK_DIR}/book.yml", 'r'))
Expand Down Expand Up @@ -59,5 +59,3 @@ EOF
f.write read_adoc(document)
end
end

`asciidoctor-pdf -B content #{OUTPUT_ADOC}`

0 comments on commit 9edda43

Please sign in to comment.