2023-03-15 21:52:13 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
import cc.tweaked.gradle.getAbsolutePath
|
|
|
|
|
2022-11-06 13:37:07 +00:00
|
|
|
plugins {
|
2023-10-03 08:19:19 +00:00
|
|
|
id("cc-tweaked.java-convention")
|
2022-11-06 13:37:07 +00:00
|
|
|
id("cc-tweaked.node")
|
|
|
|
id("cc-tweaked.illuaminate")
|
|
|
|
}
|
|
|
|
|
2023-10-03 08:19:19 +00:00
|
|
|
val modVersion: String by extra
|
|
|
|
|
2022-11-06 13:37:07 +00:00
|
|
|
node {
|
|
|
|
projectRoot.set(rootProject.projectDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
illuaminate {
|
|
|
|
version.set(libs.versions.illuaminate)
|
|
|
|
}
|
|
|
|
|
2023-10-03 08:19:19 +00:00
|
|
|
sourceSets.register("builder")
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation(project(":core"))
|
|
|
|
implementation(libs.bundles.teavm.api)
|
|
|
|
implementation(libs.asm)
|
|
|
|
implementation(libs.guava)
|
|
|
|
implementation(libs.netty.http)
|
|
|
|
implementation(libs.slf4j)
|
|
|
|
|
|
|
|
"builderCompileOnly"(libs.bundles.annotations)
|
|
|
|
"builderImplementation"(libs.bundles.teavm.tooling)
|
|
|
|
"builderImplementation"(libs.asm)
|
|
|
|
"builderImplementation"(libs.asm.commons)
|
|
|
|
}
|
|
|
|
|
|
|
|
val compileTeaVM by tasks.registering(JavaExec::class) {
|
|
|
|
group = LifecycleBasePlugin.BUILD_GROUP
|
|
|
|
description = "Generate our classes and resources files"
|
|
|
|
|
|
|
|
val output = layout.buildDirectory.dir("teaVM")
|
|
|
|
val minify = !project.hasProperty("noMinify")
|
|
|
|
|
|
|
|
inputs.property("version", modVersion)
|
|
|
|
inputs.property("minify", minify)
|
|
|
|
inputs.files(sourceSets.main.get().runtimeClasspath).withPropertyName("inputClasspath")
|
|
|
|
outputs.dir(output).withPropertyName("output")
|
|
|
|
|
|
|
|
classpath = sourceSets["builder"].runtimeClasspath
|
|
|
|
jvmArguments.addAll(
|
|
|
|
provider {
|
|
|
|
val main = sourceSets.main.get()
|
|
|
|
listOf(
|
|
|
|
"-Dcct.input=${main.output.classesDirs.asPath}",
|
|
|
|
"-Dcct.version=$modVersion",
|
|
|
|
"-Dcct.classpath=${main.runtimeClasspath.asPath}",
|
|
|
|
"-Dcct.output=${output.getAbsolutePath()}",
|
|
|
|
"-Dcct.minify=$minify",
|
|
|
|
)
|
|
|
|
},
|
|
|
|
)
|
|
|
|
mainClass.set("cc.tweaked.web.builder.Builder")
|
|
|
|
javaLauncher.set(project.javaToolchains.launcherFor { languageVersion.set(java.toolchain.languageVersion) })
|
|
|
|
}
|
|
|
|
|
2022-11-06 13:37:07 +00:00
|
|
|
val rollup by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) {
|
|
|
|
group = LifecycleBasePlugin.BUILD_GROUP
|
|
|
|
description = "Bundles JS into rollup"
|
|
|
|
|
2023-10-03 08:19:19 +00:00
|
|
|
val minify = !project.hasProperty("noMinify")
|
|
|
|
inputs.property("minify", minify)
|
|
|
|
|
2022-11-06 13:37:07 +00:00
|
|
|
// Sources
|
2023-09-28 20:00:00 +00:00
|
|
|
inputs.files(fileTree("src/frontend")).withPropertyName("sources")
|
2023-10-03 08:19:19 +00:00
|
|
|
inputs.files(compileTeaVM)
|
2022-11-06 13:37:07 +00:00
|
|
|
// Config files
|
|
|
|
inputs.file("tsconfig.json").withPropertyName("Typescript config")
|
|
|
|
inputs.file("rollup.config.js").withPropertyName("Rollup config")
|
|
|
|
|
|
|
|
// Output directory. Also defined in illuaminate.sexp and rollup.config.js
|
2023-09-28 20:00:00 +00:00
|
|
|
output.set(layout.buildDirectory.dir("rollup"))
|
2022-11-06 13:37:07 +00:00
|
|
|
|
2023-10-03 08:19:19 +00:00
|
|
|
args = listOf("rollup", "--config", "rollup.config.js") + if (minify) emptyList() else listOf("--configDebug")
|
2022-11-06 13:37:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val illuaminateDocs by tasks.registering(cc.tweaked.gradle.IlluaminateExecToDir::class) {
|
|
|
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
|
|
|
description = "Generates docs using Illuaminate"
|
|
|
|
|
|
|
|
// Config files
|
|
|
|
inputs.file(rootProject.file("illuaminate.sexp")).withPropertyName("illuaminate config")
|
|
|
|
// Sources
|
2022-11-09 23:58:56 +00:00
|
|
|
inputs.files(rootProject.fileTree("doc")).withPropertyName("docs")
|
|
|
|
inputs.files(project(":core").fileTree("src/main/resources/data/computercraft/lua")).withPropertyName("lua rom")
|
|
|
|
inputs.files(project(":forge").tasks.named("luaJavadoc"))
|
2023-10-03 08:19:19 +00:00
|
|
|
// Assets
|
2022-11-06 13:37:07 +00:00
|
|
|
inputs.files(rollup)
|
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
// Output directory. Also defined in illuaminate.sexp.
|
|
|
|
output.set(layout.buildDirectory.dir("illuaminate"))
|
2022-11-06 13:37:07 +00:00
|
|
|
|
|
|
|
args = listOf("doc-gen")
|
|
|
|
workingDir = rootProject.projectDir
|
|
|
|
}
|
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
val htmlTransform by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) {
|
2022-11-06 13:37:07 +00:00
|
|
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
|
|
|
description = "Post-processes documentation to statically render some dynamic content."
|
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
val sources = fileTree("src/htmlTransform")
|
|
|
|
|
2022-11-06 13:37:07 +00:00
|
|
|
// Config files
|
|
|
|
inputs.file("tsconfig.json").withPropertyName("Typescript config")
|
|
|
|
// Sources
|
2023-09-28 20:00:00 +00:00
|
|
|
inputs.files(sources).withPropertyName("sources")
|
2022-11-06 13:37:07 +00:00
|
|
|
inputs.files(illuaminateDocs)
|
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
// Output directory.
|
|
|
|
output.set(layout.buildDirectory.dir(name))
|
2022-11-06 13:37:07 +00:00
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
argumentProviders.add {
|
|
|
|
listOf(
|
2023-10-03 08:19:19 +00:00
|
|
|
"tsx",
|
|
|
|
sources.dir.resolve("index.tsx").absolutePath,
|
2023-09-28 20:00:00 +00:00
|
|
|
illuaminateDocs.get().output.getAbsolutePath(),
|
|
|
|
sources.dir.resolve("export/index.json").absolutePath,
|
|
|
|
output.getAbsolutePath(),
|
|
|
|
)
|
|
|
|
}
|
2022-11-06 13:37:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val docWebsite by tasks.registering(Copy::class) {
|
|
|
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
|
|
|
description = "Assemble docs and assets together into the documentation website."
|
|
|
|
duplicatesStrategy = DuplicatesStrategy.FAIL
|
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
from(htmlTransform)
|
2022-11-06 13:37:07 +00:00
|
|
|
|
|
|
|
// Pick up assets from the /docs folder
|
|
|
|
from(rootProject.file("doc")) {
|
|
|
|
include("logo.png")
|
|
|
|
include("images/**")
|
|
|
|
}
|
|
|
|
// index.js is provided by illuaminate, but rollup outputs some other chunks
|
|
|
|
from(rollup) { exclude("index.js") }
|
|
|
|
// Grab illuaminate's assets. HTML files are provided by jsxDocs
|
|
|
|
from(illuaminateDocs) { exclude("**/*.html") }
|
|
|
|
// And item/block images from the data export
|
2023-09-28 20:00:00 +00:00
|
|
|
from(file("src/htmlTransform/export/items")) { into("images/items") }
|
2022-11-06 13:37:07 +00:00
|
|
|
|
2023-09-28 20:00:00 +00:00
|
|
|
into(layout.buildDirectory.dir("site"))
|
2022-11-06 13:37:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.assemble { dependsOn(docWebsite) }
|