overdrive_that_matters/build.gradle.kts

222 lines
6.2 KiB
Plaintext

import groovy.lang.Closure
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Date
import java.text.SimpleDateFormat
val mod_version: String by project
val mc_version: String by project
val forge_version: String by project
val mod_id: String by project
plugins {
java
kotlin
id("net.minecraftforge.gradle")
}
configurations {
create("klibrary") // Kotlin library
}
version = mod_version
group = "ru.dbotthepony.mc"
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
println("Targeting Java ${java.toolchain.languageVersion.get()}")
tasks.withType(KotlinCompile::class.java) {
kotlinOptions {
freeCompilerArgs = listOf("-Xjvm-default=all")
jvmTarget = java.toolchain.languageVersion.get().toString()
}
}
tasks.withType(JavaCompile::class.java) {
options.compilerArgs.add("-Xlint:all")
}
sourceSets {
create("data") {
compileClasspath += sourceSets["main"].output
runtimeClasspath += sourceSets["main"].output
}
this["main"].resources {
srcDir("src/data/resources")
}
}
tasks.test {
useJUnitPlatform()
}
dependencies {
val jupiter_version: String by project
val kotlin_version: String by project
val kotlin_for_forge_version: String by project
val kotlin_coroutines_version: String by project
val kotlin_serialization_version: String by project
minecraft("net.minecraftforge:forge:$mc_version-$forge_version")
testImplementation("org.junit.jupiter:junit-jupiter:${jupiter_version}")
implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version")
fun klibrary(notation: Any) { this.add("klibrary", notation) }
val excludeKGroup = closureOf<Any> {
(this as ExternalModuleDependency).exclude(group = "org.jetbrains", module = "annotations")
} as Closure<Any>
// Add everything to the classpath correctly
klibrary(create("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version", excludeKGroup))
klibrary(create("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version", excludeKGroup))
klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version", excludeKGroup))
klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlin_coroutines_version", excludeKGroup))
klibrary(create("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_version", excludeKGroup))
// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
// Examples using mod jars from ./libs
// implementation fg.deobf("blank:EnderRift-1.18.1:2.4.1")
// compile against the JEI API but do not include it at runtime
//compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api")
// at runtime, use the full JEI jar
//runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")
val jei_version: String by project
val mc_version_weak: String by project
val the_one_probe_version: String by project
implementation("mezz.jei:jei-${mc_version}:${jei_version}:deobf")
implementation(fg.deobf(create("mcjty.theoneprobe:theoneprobe:${mc_version_weak}-${the_one_probe_version}", closureOf<Any> {
(this as ExternalModuleDependency).isTransitive = false
} as Closure<Any>)))
//compileOnly(fg.deobf("blank:Mekanism-1.18.1:10.1.2.homebaked-api"))
implementation(fg.deobf("blank:Mekanism-1.18.1:10.1.2.homebaked-all"))
}
configurations {
getByName("dataImplementation").extendsFrom(getByName("implementation"))
}
minecraft {
mappings("official", mc_version)
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
create("client") {
mods {
create(mod_id) {
source(sourceSets["main"])
}
}
}
create("server") {
mods {
create(mod_id) {
source(sourceSets["main"])
}
}
}
create("data") {
args("--mod", "overdrive_that_matters", "--all", "--output", file("src/data/resources/"), "--existing", file("src/main/resources/"))
mods {
create(mod_id) {
sources(sourceSets["main"], sourceSets["data"])
}
}
}
}
}
minecraft.runs.all {
workingDirectory = project.file("run").absolutePath
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property("forge.logging.markers", "REGISTRIES")
// Log4j console level
property("forge.logging.console.level", "debug")
lazyToken("minecraft_classpath") {
configurations["klibrary"].copyRecursive().resolve().map { it.absolutePath }.joinToString(File.pathSeparator)
}
}
repositories {
maven {
name = "Progwml6 maven"
url = uri("https://dvs1.progwml6.com/files/maven/")
}
maven {
name = "ModMaven"
url = uri("https://modmaven.dev")
}
maven {
name = "tterrag maven"
url = uri("https://maven.tterrag.com/")
}
maven {
url = uri("https://maven.k-4u.nl")
}
maven {
name = "Kotlin for Forge"
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
}
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
flatDir {
dir("libs")
}
}
// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
tasks.jar.configure {
finalizedBy("reobfJar")
manifest {
attributes(mapOf(
"Specification-Title" to project.name,
"Specification-Vendor" to "DBotThePony",
"Specification-Version" to "1", // We are version 1 of ourselves
"Implementation-Title" to project.name,
"Implementation-Version" to tasks.jar.get().archiveVersion,
"Implementation-Vendor" to "DBotThePony",
"Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date())
))
}
}
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn("reobfJar")
/*
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
}
*/