forked from apache/netbeans-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
275 lines (238 loc) · 9.09 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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
buildscript {
//have to apply here for this to be applied at the right time
apply from: file("gradle/deps.gradle")
initScript(buildscript)
}
apply from: file("gradle/utils.gradle")
apply plugin: 'org.jbake.site'
apply plugin: 'io.freefair.jsass-base'
loadGlobals(globalsFile)
//to build up content, assets, etc which JBake can process for us, we need to process:
//SASS files
//JS files
//Image files
//Any other content we want to preprocess
//Content files such as .html and .md and .asciidoc which just need metadata/front matter
//GSP content templates which allow programming and replacement with Groovy templates
//and we need to place all of these files in the appropriate location for JBake to do its job
//...this means in either the content or the assets folders, and this will be the
//generatedAssetsDir and generatedContentDir
jsass {
indent = ' '
linefeed = System.lineSeparator()
omitSourceMapUrl = false
outputStyle = io.bit3.jsass.OutputStyle.COMPRESSED
precision = 3
sourceComments = false
sourceMapContents = false
sourceMapEmbed = false
sourceMapEnabled = true
}
task compileContentSass(type: io.freefair.gradle.plugins.jsass.SassCompile,
description: "Compiles the projects SaSS files to the build directory.",
group: "Build") {
source = file("$contentDir/scss")
destinationDir = file("$generatedAssetDir/css")
exclude '_vendor/*.scss'
}
task preprocessContentAssets(type: Copy,
description: "Pre-processes all .css, .js (not in the minimize list), images, etc from the content directory into the generated assets directory",
group: "Build") {
into generatedAssetDir
filteringCharset 'UTF-8'
includeEmptyDirs false
from(contentDir) {
exclude(["/templates/**"])
include "**/*.cgi",
"**/*.css",
"**/css/*.css",
"dtds/**",
"ns/**",
"fonts/**",
"**/*.gif",
"**/.htaccess",
"**/sitemap.xml.gz",
"**/robots.txt",
"**/*.jpeg",
"**/*.jpg",
"**/*.js",
"**/*.png",
"**/*.svg",
"**/*.ttf",
"**/*.woff",
"**/doap_NetBeans.rdf"
}
from(contentDir_old) {
include "**/*.jpeg",
"**/*.jpg",
"**/*.js",
"**/*.png",
"**/*.svg"
}
from("$contentDir/scss") {
into('css')
include "**/*.scss"
}
}
task preprocessContentStaticsLanguage(type: Copy) {
from contentDir_ca
from contentDir_fr
from contentDir_ja
from contentDir_pt_BR
from contentDir_ru
from contentDir_zh_CN
from contentDir_old
into generatedContentDir
filteringCharset 'UTF-8'
includeEmptyDirs false
include "**/*.adoc"
exclude "kb/docs/**/section**"
}
task preprocessContentStatics(type: Copy,
description: "Pre-processes all .html, .md, and possibly other files which have metadata/front matter in a side car file of the same name and extension with an extra .yml extension after that",
group: "Build") {
from contentDir
into generatedContentDir
filteringCharset 'UTF-8'
includeEmptyDirs false
include "**/*.html.yml", "**/*.md.yml", "**/*.html", "**/*.md", "**/*.asciidoc","**/*.adoc", "fonts/**", "**/.htaccess", "**/*.xml.gz", "**/*.txt", "**/.jbakeignore"
exclude "/templates/**", "/css/**", "fonts/**", "kb/docs/**/section**"
def mergeList = []
eachFile { details ->
if(details.sourcePath.endsWith(".yml")) {
//we don't want to do anything else with this
//it will just be copied into the generated folder
//but will not be merged by
return
}
def contentFile = file("${contentDir}/${details.sourcePath}")
def ymlFile = file("${contentFile}.yml")
if(ymlFile.exists()) {
logger.info("Setting up merge for ${details.path}")
def mergeData = createMergeData(file("${generatedContentDir}/${details.path}.yml").absolutePath,
file("${generatedContentDir}/${details.path}").absolutePath)
mergeList << mergeData
} else {
logger.info("The content file ${contentFile} can not be merged because the corresponding YAML file ${ymlFile} was not found.")
}
}
doLast {
//let's merge up the metadata with the content yml+content from the merge map
mergeList.each { data ->
logger.info("Merging ${data.file} and ${data.yml}")
mergeContentAndMetadata(data)
}
}
}
task preprocessTemplates(type: Copy,
description: "Pre-processes the templates for JBake to use for baking",
group: "Build") {
from templateDir
into generatedTemplateDir
filteringCharset 'UTF-8'
includeEmptyDirs false
include "**/*"
}
task preprocessContentTemplates(type: Copy,
description: "Pre-processes the *.gsp and *.gsp.yml files under content for baking as Groovy templates; edit global.yml to add data used in content other than YAML front matter",
group: "Build") {
def mergeList = []
filteringCharset 'UTF-8'
includeEmptyDirs false
from contentDir
into generatedContentDir
//we need to do both of these to make sure we are or are not up to date
include "**/*.gsp", "**/*.gsp.yml"
exclude "/templates/**"
rename '(.*)\\.gsp', '$1'
//expand the files using Groovy's SimpleTemplateEngine
//for processing content like templates are also processed
def props = [:]
props.putAll(globals)
expand props
eachFile { details ->
if(details.sourcePath.endsWith(".yml")) {
//we don't want to do anything else with this
//it will just be copied into the generated folder
//but will not be merged by jbake as there will not
//be meta info
return
}
def contentFile = file("${contentDir}/${details.sourcePath}")
def ymlFile = file("${contentFile}.yml")
if(ymlFile.exists()) {
def mergeData = createMergeData(file("${generatedContentDir}/${details.path}.yml").absolutePath,
file("${generatedContentDir}/${details.path}").absolutePath)
mergeList << mergeData
} else {
throw new Exception("The content file ${contentFile} can not be processed because the corresponding YAML file ${ymlFile} was not found.")
}
}
doLast {
//let's merge up the metadata with the content yml+content from the merge map
mergeList.each { data ->
mergeContentAndMetadata(data)
}
}
}
task preprocessContent(dependsOn: ["compileContentSass",
"preprocessContentAssets",
"preprocessContentStatics",
"preprocessContentStaticsLanguage",
"preprocessTemplates",
"preprocessContentTemplates"],
description: "Runs all preprocess tasks to prepare for a bake",
group: "Build") {
}
jbake {
groovyTemplatesVersion = "${libs.groovy}"
version = "${libs.jbake}"
//the following vars are set the way they are because the way the jbake plugin works
srcDirName = generatedDirRelativePath
destDirName = bakedDirRelativePath
//this will cause builds to be faster as only changes will be baked,
//and since it is in the build directory, can be cleaned
configuration["db.store"]="local"
configuration["db.path"]=cacheDir.absolutePath
configuration.putAll(globals)
}
bake.mustRunAfter preprocessContent
task buildSite(dependsOn: ["preprocessContent", "bake"],
description: "Runs the site build: preprocessContent and bake",
group: "Build") {
}
build.dependsOn buildSite
task run(type: JavaExec, group: "Run") {
def wDir = new File(buildDir, "tomcat")
doFirst {
wDir.mkdirs()
bakedDir.mkdirs()
}
mainClass="TomcatMain"
classpath buildscript.configurations.classpath + files("${rootProject.projectDir}/buildSrc/build/classes/groovy/main")
args = [bakedDir, 8080, "SHUTDOWN", 8088]
workingDir = wDir
}
task stop(type: JavaExec, group: "Run") {
mainClass="TomcatStopMain"
classpath buildscript.configurations.classpath + files("${rootProject.projectDir}/buildSrc/build/classes/groovy/main")
args = ["SHUTDOWN", 8082]
}