-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathbuild.gradle
73 lines (61 loc) · 2.12 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
plugins {
id 'com.github.ben-manes.versions' version '0.14.0'
}
apply plugin: 'idea'
idea {
project {
ipr {
withXml { provider ->
def node = provider.asNode()
//configure git support for the project in idea
node.component.find { it.'@name' == 'VcsDirectoryMappings' }?.mapping[0].'@vcs' = 'Git'
}
}
}
}
task publish {
File index = new File("$rootDir/build/index.adoc")
index.parentFile.mkdirs()
def header = """= Asciidoctor Gradle Examples
Rob Winch <https://github.com/rwinch[@rwinch]>; Dan Hyun <https://github.com/danhyun[@danhyun]>
:icons: font
:toc: left
:numbered:
:github_url: https://github.com/asciidoctor/asciidoctor-gradle-examples
:github_project_path: {github_url}/tree/master
:github_fork_badge: https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png
[.badge]
image::{github_fork_badge}[link="{github_url}"]
[discrete]
== About
This repository contains examples on how to use Gradle and Asciidoctor to create html5, pdf, epub, deck.js, and reveal.js outputs.
"""
index.text = header
new File("$rootDir/build/docinfo.html").text = '<style>.badge { position: fixed; top: 0; right: 0; }</style>'
}
subprojects {
task copyOutput(type: Copy, dependsOn: ["asciidoctor"]) {
from "$project.buildDir/docs"
into "$project.projectDir"
}
task publish(dependsOn: "copyOutput") {
doLast {
File index = new File("$rootDir/build/index.adoc")
def projectName = project.projectDir.name
def content = """include::{rootDir}/$projectName/README.adoc[leveloffset=+1]
=== Source
* {github_project_path}/$projectName[View source]
=== Outputs
"""
index << content
def outputs = []
new File("$project.buildDir/docs").eachDir { dir ->
dir.eachFileMatch(~/.*\.(html|pdf|epub|mobi)/) { f ->
def dirName = dir.name
outputs << "* link:./$projectName/$dirName/$f.name[$dirName]\n"
}
}
index << outputs.join('\n') << "\n"
}
}
}