build: improve build.gradle.kts
This commit is contained in:
parent
2474a57fba
commit
f91a2c5949
@ -1,44 +1,56 @@
|
||||
var loaderName: String = "neoforge"
|
||||
|
||||
var javaVersion: String = property("java_version").toString()
|
||||
var minecraftVersion: String = property("minecraft_version").toString()
|
||||
var loaderVersion: String = property("${loaderName}_version").toString()
|
||||
|
||||
var modId: String = property("mod_id").toString()
|
||||
var modName: String = property("mod_name").toString()
|
||||
var modVersion: String = property("mod_version").toString()
|
||||
|
||||
fun getVersionType(version: String): String {
|
||||
return when {
|
||||
version.contains("alpha") -> "alpha"
|
||||
version.contains("beta") -> "beta"
|
||||
else -> "release"
|
||||
}
|
||||
}
|
||||
|
||||
// Need to be set for neoforge
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(javaVersion)
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("net.neoforged.gradle.userdev") version "7.0.134"
|
||||
id("net.neoforged.gradle.userdev") version "7.0.138"
|
||||
id("com.modrinth.minotaur") version "2.+"
|
||||
id("idea")
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "${properties["mod_id"]}-neoforge"
|
||||
version = "${properties["mod_version"]}+mc${properties["minecraft_version"]}"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(properties["java_version"] as String)
|
||||
}
|
||||
|
||||
withSourcesJar()
|
||||
sourceCompatibility = JavaVersion.valueOf("VERSION_${properties["java_version"]}")
|
||||
targetCompatibility = JavaVersion.valueOf("VERSION_${properties["java_version"]}")
|
||||
archivesName = "${modId}-${loaderName}"
|
||||
version = "${modVersion}+mc${minecraftVersion}"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("net.neoforged:neoforge:${properties["neoforge_version"]}")
|
||||
implementation("net.neoforged:neoforge:${loaderVersion}")
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
filesMatching("META-INF/neoforge.mods.toml") {
|
||||
expand(project.properties)
|
||||
}
|
||||
}
|
||||
java {
|
||||
withSourcesJar()
|
||||
sourceCompatibility = JavaVersion.valueOf("VERSION_${javaVersion}")
|
||||
targetCompatibility = JavaVersion.valueOf("VERSION_${javaVersion}")
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.properties["mod_id"]}" }
|
||||
}
|
||||
}
|
||||
modrinth {
|
||||
token = System.getenv("MODRINTH_TOKEN") ?: properties["modrinth_token"]?.toString()
|
||||
projectId = modId
|
||||
versionName = "[${loaderName.uppercase()}][${minecraftVersion}] $modName $modVersion"
|
||||
versionType = getVersionType(modVersion)
|
||||
versionNumber = modVersion
|
||||
uploadFile = tasks.jar as Any
|
||||
// Minotaur cannot detect Minecraft version in Neoforge environment
|
||||
// https://github.com/modrinth/minotaur/issues/59
|
||||
gameVersions = listOf(minecraftVersion)
|
||||
}
|
||||
|
||||
idea {
|
||||
@ -47,3 +59,25 @@ idea {
|
||||
isDownloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching("*.json") {
|
||||
expand(project.properties)
|
||||
}
|
||||
|
||||
filesMatching("META-INF/neoforge.mods.toml") {
|
||||
expand(project.properties)
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${modId}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
"HttpTextureMixin",
|
||||
"SkinManagerMixin"
|
||||
],
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"compatibilityLevel": "JAVA_${java_version}",
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user