-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
102 lines (87 loc) · 2.46 KB
/
build.gradle.kts
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
import java.io.PrintStream
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
val serverPort = project.findProperty("serverPort")?.toString() ?: "3002"
defaultTasks("setup")
tasks.register("setupNodeJs") {
doLast {
copy {
into(layout.buildDirectory)
from(layout.projectDirectory.dir("src/nodejs"))
}
}
doLast {
exec {
workingDir(layout.buildDirectory.get().asFile)
commandLine(listOf("npm", "install"))
}
}
doLast {
copy {
into(layout.buildDirectory.dir("js"))
from(layout.buildDirectory.dir("saxonjs3/browser")) {
include("*.js")
}
from(layout.buildDirectory.dir("saxonjs3/saxonjs-he-package")) {
include("*.js")
}
}
}
doLast {
val stream = PrintStream(layout.buildDirectory.file(".env").get().asFile)
stream.println("PORT=${serverPort}")
stream.close()
}
}
tasks.register("setup") {
dependsOn("copyStaticFiles")
dependsOn("setupNodeJs")
dependsOn("compileXslt")
// Just some place to hang dependencies
}
tasks.register<Exec>("server") {
dependsOn("setup")
workingDir(layout.buildDirectory.get().asFile)
commandLine(listOf("node", "server.js"))
}
tasks.register<Copy>("copyStaticFiles") {
into(layout.buildDirectory)
from(layout.projectDirectory.dir("src")) {
include("**/*.html")
include("**/*.css")
include("**/*.js")
}
}
val compileXslt = tasks.register("compileXslt") {
dependsOn("setupNodeJs")
// Just somewhere to hang dependencies
}
val xslFiles = fileTree(layout.projectDirectory.dir("src")) {
include("**/*.xsl")
}
xslFiles.forEach {
val srcpos = it.toString().lastIndexOf("/src/")
val path = it.toString().substring(srcpos+5)
val compile = tasks.register<Exec>("compile_${path.replace("/","_")}") {
dependsOn("setupNodeJs")
inputs.file(layout.projectDirectory.file("src/${path}"))
outputs.file(layout.buildDirectory.file(path.replace(".xsl", ".sef.json")))
workingDir(layout.buildDirectory.get().asFile)
commandLine("node", "node_modules/xslt3-he/xslt3.js",
"-xsl:../src/${path}", "-export:${path.replace(".xsl", ".sef.json")}",
"-stublib:stublib.json",
"-nogo", "-ns:##html5")
}
compileXslt { dependsOn(compile) }
}
tasks.register("helloWorld") {
doLast {
println("Hello, world.")
}
}