1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-14 05:44:52 +00:00
CC-Tweaked/projects/forge/build.gradle.kts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

261 lines
7.3 KiB
Plaintext
Raw Normal View History

// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
import cc.tweaked.gradle.*
2024-01-31 20:55:14 +00:00
import net.neoforged.gradle.dsl.common.runs.run.Run
plugins {
id("cc-tweaked.forge")
id("cc-tweaked.gametest")
id("cc-tweaked.mod-publishing")
}
val modVersion: String by extra
val allProjects = listOf(":core-api", ":core", ":forge-api").map { evaluationDependsOn(it) }
cct {
inlineProject(":common")
allProjects.forEach { externalSources(it) }
}
sourceSets {
main {
resources.srcDir("src/generated/resources")
}
2024-01-31 20:55:14 +00:00
testMod { runs { modIdentifier = "cctest" } }
testFixtures { runs { modIdentifier = "cctest" } }
}
minecraft {
2024-01-31 20:55:14 +00:00
accessTransformers {
file("src/main/resources/META-INF/accesstransformer.cfg")
}
}
2024-01-31 20:55:14 +00:00
runs {
configureEach {
systemProperty("forge.logging.markers", "REGISTRIES")
systemProperty("forge.logging.console.level", "debug")
2024-01-31 20:55:14 +00:00
cct.sourceDirectories.get().forEach {
if (it.classes) modSourceAs(it.sourceSet, "computercraft")
}
2024-01-31 20:55:14 +00:00
dependencies {
runtime(configurations["minecraftLibrary"])
}
2024-01-31 20:55:14 +00:00
}
2024-01-31 20:55:14 +00:00
val client by registering {
workingDirectory(file("run"))
}
2024-01-31 20:55:14 +00:00
val server by registering {
workingDirectory(file("run/server"))
programArgument("--nogui")
}
2024-01-31 20:55:14 +00:00
val data by registering {
workingDirectory(file("run"))
programArguments.addAll(
"--mod", "computercraft", "--all",
"--output", file("src/generated/resources/").absolutePath,
"--existing", project(":common").file("src/main/resources/").absolutePath,
"--existing", file("src/main/resources/").absolutePath,
)
}
2024-01-31 20:55:14 +00:00
fun Run.configureForGameTest() {
gameTest()
2024-01-31 20:55:14 +00:00
systemProperty("cctest.sources", project(":common").file("src/testMod/resources/data/cctest").absolutePath)
2024-01-31 20:55:14 +00:00
modSource(sourceSets.testMod.get())
modSource(sourceSets.testFixtures.get())
modSourceAs(project(":core").sourceSets.testFixtures.get(), "cctest")
2024-01-31 20:55:14 +00:00
jvmArgument("-ea")
2024-01-31 20:55:14 +00:00
dependencies {
runtime(configurations["testMinecraftLibrary"])
}
2024-01-31 20:55:14 +00:00
}
2024-01-31 20:55:14 +00:00
val gameTestServer by registering {
workingDirectory(file("run/testServer"))
configureForGameTest()
}
2024-01-31 20:55:14 +00:00
val gameTestClient by registering {
configure(runTypes.client)
2024-01-31 20:55:14 +00:00
workingDirectory(file("run/testClient"))
configureForGameTest()
systemProperties("cctest.tags", "client,common")
}
}
configurations {
2024-01-31 20:55:14 +00:00
val minecraftLibrary by registering {
isCanBeResolved = true
isCanBeConsumed = false
}
runtimeOnly { extendsFrom(minecraftLibrary.get()) }
val testMinecraftLibrary by registering {
isCanBeResolved = true
isCanBeConsumed = false
// Prevent ending up with multiple versions of libraries on the classpath.
shouldResolveConsistentlyWith(minecraftLibrary.get())
}
}
dependencies {
compileOnly(libs.jetbrainsAnnotations)
annotationProcessorEverywhere(libs.autoService)
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
2024-01-31 20:55:14 +00:00
compileOnly(libs.bundles.externalMods.forge.compile)
runtimeOnly(libs.bundles.externalMods.forge.runtime) { cct.exclude(this) }
// Depend on our other projects.
api(commonClasses(project(":forge-api"))) { cct.exclude(this) }
clientApi(clientClasses(project(":forge-api"))) { cct.exclude(this) }
implementation(project(":core")) { cct.exclude(this) }
2024-01-31 20:55:14 +00:00
"minecraftLibrary"(libs.cobalt) {
val version = libs.versions.cobalt.get()
jarJar.ranged(this, "[$version,${getNextVersion(version)})")
}
2024-01-31 20:55:14 +00:00
"minecraftLibrary"(libs.jzlib) {
jarJar.ranged(this, "[${libs.versions.jzlib.get()},)")
}
2024-01-31 20:55:14 +00:00
"minecraftLibrary"(libs.netty.http) {
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
isTransitive = false
}
2024-01-31 20:55:14 +00:00
"minecraftLibrary"(libs.netty.socks) {
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
isTransitive = false
}
2024-01-31 20:55:14 +00:00
"minecraftLibrary"(libs.netty.proxy) {
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
isTransitive = false
}
testFixturesApi(libs.bundles.test)
testFixturesApi(libs.bundles.kotlin)
testImplementation(testFixtures(project(":core")))
testImplementation(libs.bundles.test)
testRuntimeOnly(libs.bundles.testRuntime)
testModImplementation(testFixtures(project(":core")))
testModImplementation(testFixtures(project(":forge")))
// Ensure our test fixture dependencies are on the classpath
"testMinecraftLibrary"(libs.bundles.kotlin)
"testMinecraftLibrary"(libs.bundles.test)
testFixturesImplementation(testFixtures(project(":core")))
}
// Compile tasks
tasks.processResources {
inputs.property("modVersion", modVersion)
2024-01-31 20:55:14 +00:00
inputs.property("neoVersion", libs.versions.neoForge.get())
filesMatching("META-INF/mods.toml") {
2024-01-31 20:55:14 +00:00
expand(mapOf("neoVersion" to libs.versions.neoForge.get(), "file" to mapOf("jarVersion" to modVersion)))
}
}
tasks.jar {
archiveClassifier.set("slim")
for (source in cct.sourceDirectories.get()) {
if (source.classes && source.external) from(source.sourceSet.output)
}
}
tasks.sourcesJar {
for (source in cct.sourceDirectories.get()) from(source.sourceSet.allSource)
}
tasks.jarJar {
archiveClassifier.set("")
2024-01-31 20:55:14 +00:00
configuration(project.configurations["minecraftLibrary"])
for (source in cct.sourceDirectories.get()) {
if (source.classes) from(source.sourceSet.output)
}
}
tasks.assemble { dependsOn("jarJar") }
// Check tasks
tasks.test {
systemProperty("cct.test-files", layout.buildDirectory.dir("tmp/testFiles").getAbsolutePath())
}
2024-01-31 20:55:14 +00:00
tasks.checkDependencyConsistency {
// Forge pulls in slf4j 2.0.9 instead of 2.0.7, so we need to override that.
override(libs.slf4j.asProvider(), "2.0.9")
}
val runGametest by tasks.registering(JavaExec::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Runs tests on a temporary Minecraft instance."
dependsOn("cleanRunGametest")
usesService(MinecraftRunnerService.get(gradle))
2024-01-31 20:55:14 +00:00
setRunConfig(runs["gameTestServer"])
2024-01-31 20:55:14 +00:00
systemProperty("forge.logging.console.level", "info")
systemProperty("cctest.gametest-report", layout.buildDirectory.dir("test-results/$name.xml").getAbsolutePath())
}
cct.jacoco(runGametest)
tasks.check { dependsOn(runGametest) }
2024-01-31 20:55:14 +00:00
/*val runGametestClient by tasks.registering(ClientJavaExec::class) {
description = "Runs client-side gametests with no mods"
2024-01-31 20:55:14 +00:00
setRunConfig(runs["testClient"])
tags("client")
}
cct.jacoco(runGametestClient)
tasks.register("checkClient") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Runs all client-only checks."
dependsOn(runGametestClient)
2024-01-31 20:55:14 +00:00
}*/
// Upload tasks
modPublishing {
output.set(tasks.jarJar)
}
// Don't publish the slim jar
for (cfg in listOf(configurations.apiElements, configurations.runtimeElements)) {
cfg.configure { artifacts.removeIf { it.classifier == "slim" } }
}
2024-01-31 20:55:14 +00:00
tasks.withType(GenerateModuleMetadata::class).configureEach { isEnabled = false }
publishing {
publications {
named("maven", MavenPublication::class) {
2024-01-31 20:55:14 +00:00
jarJar.component(this)
mavenDependencies {
cct.configureExcludes(this)
}
}
}
}