2022-10-22 20:09:08 +00:00
|
|
|
import cc.tweaked.gradle.*
|
|
|
|
import net.darkhax.curseforgegradle.TaskPublishCurseForge
|
2022-10-29 17:17:02 +00:00
|
|
|
import net.minecraftforge.gradle.common.util.RunConfig
|
2022-11-06 10:28:49 +00:00
|
|
|
import org.jetbrains.gradle.ext.compiler
|
|
|
|
import org.jetbrains.gradle.ext.settings
|
2022-10-22 20:09:08 +00:00
|
|
|
|
|
|
|
plugins {
|
|
|
|
// Build
|
2022-11-06 15:07:13 +00:00
|
|
|
id("net.minecraftforge.gradle")
|
2022-10-22 20:09:08 +00:00
|
|
|
alias(libs.plugins.mixinGradle)
|
2022-11-06 15:07:13 +00:00
|
|
|
id("org.parchmentmc.librarian.forgegradle")
|
2022-10-22 20:09:08 +00:00
|
|
|
alias(libs.plugins.shadow)
|
|
|
|
// Publishing
|
|
|
|
alias(libs.plugins.curseForgeGradle)
|
|
|
|
alias(libs.plugins.githubRelease)
|
|
|
|
alias(libs.plugins.minotaur)
|
|
|
|
// Utility
|
|
|
|
alias(libs.plugins.taskTree)
|
2022-11-06 15:07:13 +00:00
|
|
|
id("org.jetbrains.gradle.plugin.idea-ext")
|
2022-10-22 20:09:08 +00:00
|
|
|
|
|
|
|
id("cc-tweaked.illuaminate")
|
2022-10-29 17:17:02 +00:00
|
|
|
id("cc-tweaked.gametest")
|
2022-11-04 21:41:59 +00:00
|
|
|
id("cc-tweaked.publishing")
|
2022-10-22 20:09:08 +00:00
|
|
|
id("cc-tweaked")
|
|
|
|
}
|
|
|
|
|
|
|
|
val isStable = true
|
|
|
|
val modVersion: String by extra
|
|
|
|
val mcVersion: String by extra
|
|
|
|
|
2022-11-06 15:07:13 +00:00
|
|
|
val allProjects = listOf(":core-api", ":core", ":forge-api").map { evaluationDependsOn(it) }
|
2022-11-04 21:41:59 +00:00
|
|
|
cct {
|
|
|
|
allProjects.forEach { externalSources(it) }
|
|
|
|
}
|
2022-10-22 20:09:08 +00:00
|
|
|
|
2022-11-04 22:31:56 +00:00
|
|
|
java {
|
|
|
|
registerFeature("extraMods") { usingSourceSet(sourceSets.main.get()) }
|
|
|
|
}
|
2022-10-22 20:09:08 +00:00
|
|
|
|
|
|
|
sourceSets {
|
2022-11-06 15:07:13 +00:00
|
|
|
// ForgeGradle adds a dep on the clientClasses task, despite forge-api coming from a separate project. Register an
|
|
|
|
// empty one.
|
|
|
|
register("client")
|
|
|
|
|
2022-10-22 20:09:08 +00:00
|
|
|
main {
|
|
|
|
resources.srcDir("src/generated/resources")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
minecraft {
|
|
|
|
runs {
|
|
|
|
// configureEach would be better, but we need to eagerly configure configs or otherwise the run task doesn't
|
|
|
|
// get set up properly.
|
|
|
|
all {
|
2022-10-25 21:36:21 +00:00
|
|
|
lazyToken("minecraft_classpath") {
|
|
|
|
configurations["shade"].copyRecursive().resolve().joinToString(File.pathSeparator) { it.absolutePath }
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:09:08 +00:00
|
|
|
property("forge.logging.markers", "REGISTRIES")
|
|
|
|
property("forge.logging.console.level", "debug")
|
|
|
|
|
|
|
|
forceExit = false
|
|
|
|
|
2022-11-04 21:41:59 +00:00
|
|
|
mods.register("computercraft") {
|
|
|
|
cct.sourceDirectories.get().forEach {
|
|
|
|
if (it.classes) sources(it.sourceSet)
|
|
|
|
}
|
|
|
|
}
|
2022-10-22 20:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val client by registering {
|
|
|
|
workingDirectory(file("run"))
|
|
|
|
}
|
|
|
|
|
|
|
|
val server by registering {
|
|
|
|
workingDirectory(file("run/server"))
|
|
|
|
arg("--nogui")
|
|
|
|
}
|
|
|
|
|
|
|
|
val data by registering {
|
|
|
|
workingDirectory(file("run"))
|
|
|
|
args(
|
|
|
|
"--mod",
|
|
|
|
"computercraft",
|
|
|
|
"--all",
|
|
|
|
"--output",
|
|
|
|
file("src/generated/resources/"),
|
|
|
|
"--existing",
|
|
|
|
file("src/main/resources/"),
|
|
|
|
)
|
|
|
|
property("cct.pretty-json", "true")
|
|
|
|
}
|
|
|
|
|
2022-10-29 17:17:02 +00:00
|
|
|
fun RunConfig.configureForGameTest() {
|
2022-10-30 08:49:52 +00:00
|
|
|
val old = lazyTokens.get("minecraft_classpath")
|
|
|
|
lazyToken("minecraft_classpath") {
|
|
|
|
// We do some terrible hacks here to basically find all things not already on the runtime classpath
|
|
|
|
// and add them. /Except/ for our source sets, as those need to load inside the Minecraft classpath.
|
|
|
|
val testMod = configurations["testModRuntimeClasspath"].resolve()
|
|
|
|
val implementation = configurations.runtimeClasspath.get().resolve()
|
|
|
|
val new = (testMod - implementation)
|
2022-10-30 10:50:16 +00:00
|
|
|
.asSequence()
|
|
|
|
.filter { it.isFile && !it.name.endsWith("-test-fixtures.jar") }
|
|
|
|
.map { it.absolutePath }
|
2022-10-30 08:49:52 +00:00
|
|
|
.joinToString(File.pathSeparator)
|
|
|
|
if (old == null) new else old.get() + File.pathSeparator + new
|
|
|
|
}
|
|
|
|
|
2022-10-30 10:50:16 +00:00
|
|
|
property("cctest.sources", file("src/testMod/resources/data/cctest").absolutePath)
|
|
|
|
|
|
|
|
arg("--mixin.config=computercraft-gametest.mixins.json")
|
|
|
|
|
2022-10-29 17:17:02 +00:00
|
|
|
mods.register("cctest") {
|
|
|
|
source(sourceSets["testMod"])
|
|
|
|
source(sourceSets["testFixtures"])
|
2022-11-06 22:26:07 +00:00
|
|
|
// FIXME: We need this for running in-dev but not from Gradle: source(project(":core").sourceSets.testFixtures.get())
|
2022-10-29 17:17:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:09:08 +00:00
|
|
|
val testClient by registering {
|
2022-10-24 18:21:08 +00:00
|
|
|
workingDirectory(file("run/testClient"))
|
2022-10-22 20:09:08 +00:00
|
|
|
parent(client.get())
|
2022-10-29 17:17:02 +00:00
|
|
|
configureForGameTest()
|
2022-10-22 20:09:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-25 21:36:21 +00:00
|
|
|
val gameTestServer by registering {
|
2022-10-24 18:21:08 +00:00
|
|
|
workingDirectory(file("run/testServer"))
|
2022-10-29 17:17:02 +00:00
|
|
|
configureForGameTest()
|
2022-10-22 20:09:08 +00:00
|
|
|
|
|
|
|
property("forge.logging.console.level", "info")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mappings("parchment", "${libs.versions.parchmentMc.get()}-${libs.versions.parchment.get()}-$mcVersion")
|
|
|
|
|
|
|
|
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
|
|
|
|
}
|
|
|
|
|
|
|
|
mixin {
|
|
|
|
add(sourceSets.main.get(), "computercraft.mixins.refmap.json")
|
|
|
|
config("computercraft.mixins.json")
|
|
|
|
}
|
|
|
|
|
|
|
|
reobf {
|
|
|
|
register("shadowJar")
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
val shade by registering { isTransitive = false }
|
|
|
|
implementation { extendsFrom(shade.get()) }
|
|
|
|
register("cctJavadoc")
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
minecraft("net.minecraftforge:forge:$mcVersion-${libs.versions.forge.get()}")
|
2022-10-25 21:36:21 +00:00
|
|
|
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
|
2022-10-22 20:09:08 +00:00
|
|
|
|
|
|
|
compileOnly(libs.jetbrainsAnnotations)
|
|
|
|
annotationProcessorEverywhere(libs.autoService)
|
|
|
|
|
2022-10-26 08:49:51 +00:00
|
|
|
"extraModsCompileOnly"(fg.deobf("mezz.jei:jei-1.19.2-forge-api:11.3.0.262"))
|
|
|
|
"extraModsCompileOnly"(fg.deobf("mezz.jei:jei-1.19.2-common-api:11.3.0.262"))
|
|
|
|
"extraModsRuntimeOnly"(fg.deobf("mezz.jei:jei-1.19.2-forge:11.3.0.262"))
|
|
|
|
"extraModsCompileOnly"(fg.deobf("maven.modrinth:oculus:1.2.5"))
|
2022-10-22 20:09:08 +00:00
|
|
|
|
2022-11-04 22:31:56 +00:00
|
|
|
implementation(project(":core"))
|
2022-11-06 15:07:13 +00:00
|
|
|
implementation(commonClasses(project(":forge-api")))
|
|
|
|
implementation(clientClasses(project(":forge-api")))
|
2022-10-22 20:09:08 +00:00
|
|
|
"shade"(libs.cobalt)
|
2022-11-04 22:31:56 +00:00
|
|
|
"shade"(libs.netty.http)
|
2022-10-22 20:09:08 +00:00
|
|
|
|
2022-10-29 17:17:02 +00:00
|
|
|
testFixturesApi(libs.bundles.test)
|
|
|
|
testFixturesApi(libs.bundles.kotlin)
|
|
|
|
|
2022-11-04 22:31:56 +00:00
|
|
|
testImplementation(testFixtures(project(":core")))
|
2022-10-22 20:09:08 +00:00
|
|
|
testImplementation(libs.bundles.test)
|
|
|
|
testImplementation(libs.bundles.kotlin)
|
|
|
|
testRuntimeOnly(libs.bundles.testRuntime)
|
|
|
|
|
2022-11-04 22:31:56 +00:00
|
|
|
testModImplementation(testFixtures(project(":core")))
|
|
|
|
|
2022-10-22 20:09:08 +00:00
|
|
|
"cctJavadoc"(libs.cctJavadoc)
|
|
|
|
}
|
|
|
|
|
|
|
|
illuaminate {
|
|
|
|
version.set(libs.versions.illuaminate)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compile tasks
|
|
|
|
|
|
|
|
val luaJavadoc by tasks.registering(Javadoc::class) {
|
|
|
|
description = "Generates documentation for Java-side Lua functions."
|
|
|
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
|
|
|
|
|
|
|
source(sourceSets.main.get().java)
|
2022-11-04 22:31:56 +00:00
|
|
|
source(project(":core").sourceSets.main.get().java)
|
|
|
|
|
2022-10-24 18:21:08 +00:00
|
|
|
setDestinationDir(buildDir.resolve("docs/luaJavadoc"))
|
2022-10-22 20:09:08 +00:00
|
|
|
classpath = sourceSets.main.get().compileClasspath
|
|
|
|
|
|
|
|
options.docletpath = configurations["cctJavadoc"].files.toList()
|
|
|
|
options.doclet = "cc.tweaked.javadoc.LuaDoclet"
|
|
|
|
(options as StandardJavadocDocletOptions).noTimestamp(false)
|
|
|
|
|
|
|
|
javadocTool.set(
|
|
|
|
javaToolchains.javadocToolFor {
|
2022-10-30 08:49:52 +00:00
|
|
|
languageVersion.set(cc.tweaked.gradle.CCTweakedPlugin.JAVA_VERSION)
|
2022-10-22 20:09:08 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.processResources {
|
|
|
|
inputs.property("modVersion", modVersion)
|
|
|
|
inputs.property("forgeVersion", libs.versions.forge.get())
|
|
|
|
|
|
|
|
filesMatching("META-INF/mods.toml") {
|
|
|
|
expand(mapOf("forgeVersion" to libs.versions.forge.get(), "file" to mapOf("jarVersion" to modVersion)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.jar {
|
|
|
|
finalizedBy("reobfJar")
|
|
|
|
archiveClassifier.set("slim")
|
|
|
|
|
2022-11-04 21:41:59 +00:00
|
|
|
from(allProjects.map { zipTree(it.tasks.jar.get().archiveFile) })
|
2022-10-22 20:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.shadowJar {
|
|
|
|
finalizedBy("reobfShadowJar")
|
|
|
|
archiveClassifier.set("")
|
2022-11-04 22:31:56 +00:00
|
|
|
|
|
|
|
from(allProjects.map { zipTree(it.tasks.jar.get().archiveFile) })
|
|
|
|
|
2022-10-22 20:09:08 +00:00
|
|
|
configurations = listOf(project.configurations["shade"])
|
|
|
|
relocate("org.squiddev.cobalt", "cc.tweaked.internal.cobalt")
|
2022-11-04 22:31:56 +00:00
|
|
|
relocate("io.netty.handler.codec.http", "cc.tweaked.internal.netty")
|
|
|
|
// TODO: minimize(): Would be good to support once our build scripts are stabilised.
|
2022-10-22 20:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.assemble { dependsOn("shadowJar") }
|
|
|
|
|
|
|
|
// Check tasks
|
|
|
|
|
2022-10-24 18:21:08 +00:00
|
|
|
tasks.test {
|
2022-10-29 21:47:31 +00:00
|
|
|
systemProperty("cct.test-files", buildDir.resolve("tmp/testFiles").absolutePath)
|
2022-10-24 18:21:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 20:09:08 +00:00
|
|
|
val lintLua by tasks.registering(IlluaminateExec::class) {
|
|
|
|
group = JavaBasePlugin.VERIFICATION_GROUP
|
|
|
|
description = "Lint Lua (and Lua docs) with illuaminate"
|
|
|
|
|
|
|
|
// Config files
|
|
|
|
inputs.file("illuaminate.sexp").withPropertyName("illuaminate.sexp")
|
|
|
|
// Sources
|
|
|
|
inputs.files(fileTree("doc")).withPropertyName("docs")
|
|
|
|
inputs.files(fileTree("src/main/resources/data/computercraft/lua")).withPropertyName("lua rom")
|
|
|
|
inputs.files(luaJavadoc)
|
|
|
|
|
|
|
|
args = listOf("lint")
|
|
|
|
|
|
|
|
doFirst { if (System.getenv("GITHUB_ACTIONS") != null) println("::add-matcher::.github/matchers/illuaminate.json") }
|
|
|
|
doLast { if (System.getenv("GITHUB_ACTIONS") != null) println("::remove-matcher owner=illuaminate::") }
|
|
|
|
}
|
|
|
|
|
|
|
|
val runGametest by tasks.registering(JavaExec::class) {
|
|
|
|
group = LifecycleBasePlugin.VERIFICATION_GROUP
|
|
|
|
description = "Runs tests on a temporary Minecraft instance."
|
2022-10-25 21:36:21 +00:00
|
|
|
dependsOn("cleanRunGametest")
|
2022-10-22 20:09:08 +00:00
|
|
|
|
2022-10-25 21:36:21 +00:00
|
|
|
// Copy from runGameTestServer. We do it in this slightly odd way as runGameTestServer
|
2022-10-22 20:09:08 +00:00
|
|
|
// isn't created until the task is configured (which is no good for us).
|
2022-10-25 21:36:21 +00:00
|
|
|
val exec = tasks.getByName<JavaExec>("runGameTestServer")
|
2022-10-22 20:09:08 +00:00
|
|
|
dependsOn(exec.dependsOn)
|
|
|
|
exec.copyToFull(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
cct.jacoco(runGametest)
|
|
|
|
|
|
|
|
tasks.check { dependsOn(runGametest) }
|
|
|
|
|
|
|
|
// Upload tasks
|
|
|
|
|
|
|
|
val publishCurseForge by tasks.registering(TaskPublishCurseForge::class) {
|
|
|
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
|
|
|
description = "Upload artifacts to CurseForge"
|
|
|
|
|
2022-10-24 18:21:08 +00:00
|
|
|
apiToken = findProperty("curseForgeApiKey") ?: ""
|
2022-10-22 20:09:08 +00:00
|
|
|
enabled = apiToken != ""
|
|
|
|
|
2022-11-01 21:52:49 +00:00
|
|
|
val mainFile = upload("282001", tasks.shadowJar.get().archiveFile)
|
2022-10-22 20:09:08 +00:00
|
|
|
dependsOn(tasks.shadowJar) // Ughr.
|
2022-11-04 21:41:59 +00:00
|
|
|
mainFile.changelog =
|
|
|
|
"Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion)."
|
2022-10-22 20:09:08 +00:00
|
|
|
mainFile.changelogType = "markdown"
|
|
|
|
mainFile.releaseType = if (isStable) "release" else "alpha"
|
|
|
|
mainFile.gameVersions.add(mcVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.publish { dependsOn(publishCurseForge) }
|
|
|
|
|
|
|
|
modrinth {
|
2022-10-24 18:21:08 +00:00
|
|
|
token.set(findProperty("modrinthApiKey") as String? ?: "")
|
2022-10-22 20:09:08 +00:00
|
|
|
projectId.set("gu7yAYhd")
|
|
|
|
versionNumber.set("$mcVersion-$modVersion")
|
|
|
|
versionName.set(modVersion)
|
|
|
|
versionType.set(if (isStable) "release" else "alpha")
|
|
|
|
uploadFile.set(tasks.shadowJar as Any)
|
|
|
|
gameVersions.add(mcVersion)
|
|
|
|
changelog.set("Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion).")
|
|
|
|
|
2022-10-24 18:21:08 +00:00
|
|
|
syncBodyFrom.set(provider { file("doc/mod-page.md").readText() })
|
2022-10-22 20:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.publish { dependsOn(tasks.modrinth) }
|
|
|
|
|
|
|
|
githubRelease {
|
2022-10-24 18:21:08 +00:00
|
|
|
token(findProperty("githubApiKey") as String? ?: "")
|
2022-10-22 20:09:08 +00:00
|
|
|
owner.set("cc-tweaked")
|
|
|
|
repo.set("CC-Tweaked")
|
|
|
|
targetCommitish.set(cct.gitBranch)
|
|
|
|
|
|
|
|
tagName.set("v$mcVersion-$modVersion")
|
|
|
|
releaseName.set("[$mcVersion] $modVersion")
|
|
|
|
body.set(
|
2022-10-24 18:21:08 +00:00
|
|
|
provider {
|
|
|
|
"## " + file("src/main/resources/data/computercraft/lua/rom/help/whatsnew.md")
|
|
|
|
.readLines()
|
|
|
|
.takeWhile { it != "Type \"help changelog\" to see the full version history." }
|
|
|
|
.joinToString("\n").trim()
|
|
|
|
},
|
2022-10-22 20:09:08 +00:00
|
|
|
)
|
|
|
|
prerelease.set(!isStable)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.publish { dependsOn(tasks.githubRelease) }
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
2022-11-04 21:41:59 +00:00
|
|
|
named("maven", MavenPublication::class) {
|
2022-10-22 20:09:08 +00:00
|
|
|
fg.component(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-06 10:28:49 +00:00
|
|
|
|
|
|
|
idea.project.settings.compiler.javac {
|
|
|
|
// We want ErrorProne to be present when compiling via IntelliJ, as it offers some helpful warnings
|
|
|
|
// and errors. Loop through our source sets and find the appropriate flags.
|
|
|
|
moduleJavacAdditionalOptions = subprojects
|
|
|
|
.asSequence()
|
|
|
|
.map { evaluationDependsOn(it.path) }
|
|
|
|
.flatMap { project ->
|
|
|
|
val sourceSets = project.extensions.findByType(SourceSetContainer::class) ?: return@flatMap sequenceOf()
|
|
|
|
sourceSets.asSequence().map { sourceSet ->
|
|
|
|
val name = "${idea.project.name}.${project.name}.${sourceSet.name}"
|
|
|
|
val compile = project.tasks.named(sourceSet.compileJavaTaskName, JavaCompile::class).get()
|
|
|
|
name to compile.options.allCompilerArgs.joinToString(" ") { if (it.contains(" ")) "\"$it\"" else it }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.toMap()
|
|
|
|
}
|