/
griffon-site.gradle
141 lines (121 loc) · 4.99 KB
/
griffon-site.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
/*
* Copyright 2008-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.json.JsonParserType
import groovy.json.JsonSlurper
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
buildscript {
repositories {
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'org.jbake:jbake-gradle-plugin:1.0.0'
classpath "org.eclipse.jetty:jetty-webapp:$jettyVersion"
classpath "org.eclipse.jetty:jetty-annotations:$jettyVersion"
}
}
apply plugin: 'base'
apply plugin: 'org.jbake.site'
configurations {
docs
}
dependencies {
docs project(':griffon-guide')
}
task pluginList() {}
pluginList.doLast {
URL url = 'https://api.github.com/users/griffon-plugins/repos?sort=full_name'.toURL()
def json = new JsonSlurper().setType(JsonParserType.LAX).parse(url)
String content = '''
:linkattrs:
:icons: 'font'
[cols="2,5*^"]
|====
'''.stripIndent(8)
json.each { repo ->
content += """| link:${repo.html_url}[${repo.name}, window="_blank"]"""
content += """pass:[<ul class="list-inline">
<li><iframe src="http://ghbtns.com/github-btn.html?user=griffon-plugins&repo=${repo.name}&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe></li>
<li><iframe src="http://ghbtns.com/github-btn.html?user=griffon-plugins&repo=${repo.name}&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe></li></ul>]""".stripIndent(8)
content += """| image:https://api.bintray.com/packages/griffon/griffon-plugins/${repo.name}/images/download.svg[link="https://bintray.com/griffon/griffon-plugins/${repo.name}/_latestVersion"]"""
content += """| image:http://img.shields.io/badge/docs-api-blue.svg[API, link="http://griffon-plugins.github.io/${repo.name}/"] """
content += """| image:http://img.shields.io/travis/griffon-plugins/${repo.name}/master.svg[Build Status, link="https://travis-ci.org/griffon-plugins/${repo.name}/"] """
content += """| image:http://img.shields.io/coveralls/griffon-plugins/${repo.name}/master.svg[Coverage Status, link="https://coveralls.io/r/griffon-plugins/${repo.name}/"] """
content += """| image:http://img.shields.io/github/issues/${repo.full_name}.svg[Open Issues, link="https://github.com/griffon-plugins/${repo.name}/issues"]"""
content += '\n'
}
content += '|====\n'
File pluginFile = new File("${buildDir}/tmp/plugins.adoc")
pluginFile.parentFile.mkdirs()
pluginFile.text = content
}
jbake {
// dependsOn pluginList
configuration['asciidoctor.attributes.export'] = true
configuration['asciidoctor.attributes.export.prefix'] = 'jbake-'
configuration['griffon.version.current'] = project.version
configuration['griffon.version.previous'] = rootProject.previousVersion
configuration['project-build-dir'] = project.buildDir.absolutePath
configuration['project-rootdir'] = rootProject.projectDir.absolutePath
version = '2.6.0'
asciidoctorjVersion = '1.5.6'
freemarkerVersion = '2.3.27-incubating'
groovyTemplatesVersion = groovyVersion
thymeleafVersion = '3.0.9.RELEASE'
jade4jVersion = '1.2.7'
}
task(guide, dependsOn: [':griffon-guide:guide']) {
// generates guide on the spot
}
task(copyGuide, type: Copy) {
destinationDir = file("$buildDir/guide")
from(tasks.getByPath(':griffon-guide:guide').destinationDir) {
into project.version
}
}
task(site, type: Copy, dependsOn: [bake, copyGuide]) {
destinationDir = file("$buildDir/site")
from file(bake.output)
from(copyGuide.destinationDir) {
into 'guide'
}
doLast {
copy {
into file("${destinationDir}/reports/${project.version}")
from(rootProject.tasks.binaryReport.reportsDir)
}
}
}
task(siteRun) {
dependsOn site
doLast {
Server server = new Server(8080)
String wardir = site.destinationDir.absolutePath
WebAppContext context = new WebAppContext()
context.setResourceBase(wardir)
context.setDescriptor(wardir + 'WEB-INF/web.xml')
context.setContextPath('/')
context.setParentLoaderPriority(true)
server.setHandler(context)
server.start()
server.join()
}
}
task(siteZip, type: Zip, dependsOn: site) {
baseName = 'griffon-site'
from site.destinationDir
}