forked from FusionAuth/fusionauth-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.savant
102 lines (84 loc) · 3.24 KB
/
build.savant
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
fusionauthWebsiteStyleVersion = "0.3.68"
project(group: "io.fusionauth", name: "fusionauth-site", version: "3.0.0", licenses: ["ApacheV2_0"]) {
workflow {
fetch {
cache()
url(url: "https://repository.savantbuild.org")
}
publish {
cache()
}
}
publishWorkflow {
subversion(repository: "https://svn.savantbuild.org")
}
dependencies {
group(name: "css", export: false) {
dependency(id: "io.fusionauth:fusionauth-style:fusionauth-website-style:${fusionauthWebsiteStyleVersion}:css")
dependency(id: "io.fusionauth:fusionauth-style:fusionauth-website-style:${fusionauthWebsiteStyleVersion}:css.map")
}
}
}
dependency = loadPlugin(id: "org.savantbuild.plugin:dependency:1.0.2")
file = loadPlugin(id: "org.savantbuild.plugin:file:1.0.2")
target(name: "css", description: "Copies the CSS into place") {
file.delete {
fileSet(dir: "site/assets/css", includePatterns: [~/fusionauth-website.+/,~/fusionauth-login-style.+/])
}
dependency.copy(to: "site/assets/css") {
dependencies(group: "css", transitive: false, fetchSource: true)
}
file.copyFile(file: "site/assets/css/fusionauth-website-style-${fusionauthWebsiteStyleVersion}.css", to: "site/assets/css/fusionauth-login-style.css")
file.rename {
fileSet(dir: "site/assets/css", includePatterns: [~/fusionauth-website.+/])
filter(token: "-{integration}", value: "")
}
}
target(name: "clean", description: "cleans the project", dependsOn: ["css"]) {
cleanExecute(["bundle", "exec", "jekyll", "clean"], false)
}
target(name: "compile", description: "builds the project", dependsOn: ["css"]) {
if (switches.has("drafts")) {
cleanExecute(["bundle", "exec", "jekyll", "build", "--drafts"], false)
} else {
cleanExecute(["bundle", "exec", "jekyll", "build"], false)
}
}
target(name: "serve", description: "Build and watch the project", dependsOn: ["css"]) {
cleanExecute(["bundle", "exec", "jekyll", "serve", "--drafts", "--future", "--incremental", "-o"], false)
}
target(name: "astro", description: "Build and watch the astro project") {
astroExecute(["npm", "install"])
astroExecute(["npm", "run", "dev"])
}
target(name: "watch", description: "Build and watch the project", dependsOn: ["css"]) {
cleanExecute(["bundle", "exec", "jekyll", "build", "--drafts", "--future", "--incremental", "--watch"], false)
}
boolean astroExecute(List<String> args) {
ProcessBuilder pb = new ProcessBuilder(args).inheritIO().directory(new File('./astro'))
def process = pb.start()
process.consumeProcessOutput(System.out, System.err)
process.waitFor()
return process.exitValue() == 0
}
boolean cleanExecute(List<String> args, boolean prod) {
ProcessBuilder pb = new ProcessBuilder(args).inheritIO().directory(new File('.'))
clearEnvironment(pb)
if (prod) {
pb.environment().put("JEKYLL_ENV", "production")
}
def process = pb.start()
process.consumeProcessOutput(System.out, System.err)
process.waitFor()
return process.exitValue() == 0
}
/**
* Clears out the RBENV variables in the environment.
*
* @param pb The ProcessBuilder to clear out.
*/
static def clearEnvironment(ProcessBuilder pb) {
pb.environment().remove("RBENV_VERSION")
pb.environment().remove("RBENV_DIR")
pb.environment().remove("RBENV_ROOT")
}