-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle.kts
133 lines (108 loc) · 4.14 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
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
import java.util.*
plugins {
java
distribution
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
exclusiveContent {
forRepository {
maven("https://maven.squiddev.cc")
}
filter {
includeGroup("cc.tweaked")
includeGroup("org.teavm")
}
}
}
val filteredCCSources by tasks.registering(Sync::class) {
from("vendor/CC-Tweaked/projects/core-api/src/main/java")
from("vendor/CC-Tweaked/projects/core/src/main/java")
from("vendor/CC-Tweaked/projects/web/src/main/java") {
exclude("cc/tweaked/web/Main.java")
}
into(layout.buildDirectory.dir(name))
}
sourceSets {
main {
java.srcDir(filteredCCSources)
resources.srcDir("vendor/CC-Tweaked/projects/core/src/main/resources")
}
register("builder") {
java.srcDir("vendor/CC-Tweaked/projects/web/src/builder/java")
resources.srcDir("vendor/CC-Tweaked/projects/web/src/builder/resources")
}
}
dependencies {
compileOnly(libs.bundles.annotations)
implementation(libs.asm)
implementation(libs.cobalt)
implementation(libs.fastutil)
implementation(libs.guava)
implementation(libs.jzlib)
implementation(libs.netty.http)
implementation(libs.netty.proxy)
implementation(libs.netty.socks)
implementation(libs.slf4j)
runtimeOnly(libs.teavm.core) // Contains the TeaVM runtime
implementation(libs.bundles.teavm.api)
"builderCompileOnly"(libs.bundles.annotations)
"builderImplementation"(libs.bundles.teavm.tooling)
"builderImplementation"(libs.asm)
"builderImplementation"(libs.asm.commons)
}
tasks {
val teaVMOutput = layout.buildDirectory.dir("teaVM")
val compileTeaVM by registering(JavaExec::class) {
group = "build"
description = "Stitch all files together"
val propertiesFile = projectDir.resolve("vendor/CC-Tweaked/gradle.properties")
inputs.files(sourceSets.main.get().runtimeClasspath).withPropertyName("inputClasspath")
inputs.file(propertiesFile).withPropertyName("inputProperties")
outputs.dir(teaVMOutput).withPropertyName("output")
classpath = sourceSets["builder"].runtimeClasspath
jvmArguments.addAll(provider {
val properties = Properties().also { propertiesFile.inputStream().use(it::load) }
val main = sourceSets.main.get()
listOf(
"-Dcct.input=${main.output.classesDirs.asPath}",
"-Dcct.version=${properties["modVersion"]}",
"-Dcct.classpath=${main.runtimeClasspath.asPath}",
"-Dcct.output=${teaVMOutput.get().asFile.absolutePath}"
)
})
mainClass.set("cc.tweaked.web.builder.Builder")
javaLauncher.set(project.javaToolchains.launcherFor { languageVersion.set(java.toolchain.languageVersion) })
}
val genCssTypes by registering(Exec::class) {
group = "build"
description = "Generates type stubs for CSS files"
inputs.file("src/web/ts/styles.css").withPropertyName("styles.css")
outputs.file("src/web/ts/styles.css.d.ts").withPropertyName("styles.css.d.ts")
commandLine("node", "tools/setup.js")
}
val rollup by registering(Exec::class) {
group = "build"
description = "Combines multiple Javascript files into one"
dependsOn(genCssTypes)
inputs.files(compileTeaVM).withPropertyName("teaVM")
inputs.files(fileTree("src/web")).withPropertyName("sources")
inputs.file("package-lock.json").withPropertyName("package-lock.json")
inputs.file("rollup.config.js").withPropertyName("Rollup config")
outputs.files(fileTree(layout.buildDirectory.dir("web"))).withPropertyName("output")
outputs.files(fileTree(layout.buildDirectory.dir("webMin"))).withPropertyName("outputMin")
commandLine("npx", "rollup", "-c")
}
assemble { dependsOn(rollup) }
assembleDist { dependsOn(rollup) }
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile::class) {
options.compilerArgs.addAll(listOf("-Xlint", "-Xlint:-processing"))
}
}