Update build script
This commit is contained in:
parent
fa478e4b15
commit
0da8278998
@ -3,7 +3,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream
|
import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
val mod_version: String by project
|
val mod_version: String by project
|
||||||
val mc_version: String by project
|
val mc_version: String by project
|
||||||
@ -20,16 +19,14 @@ plugins {
|
|||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("net.minecraftforge.gradle")
|
id("net.minecraftforge.gradle")
|
||||||
id("org.spongepowered.mixin")
|
id("org.spongepowered.mixin")
|
||||||
id("org.parchmentmc.librarian.forgegradle")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
create("library") // non-mod libraries
|
|
||||||
create("klibrary") // kotlin libs
|
create("klibrary") // kotlin libs
|
||||||
get("implementation").extendsFrom(get("library"), get("klibrary"))
|
get("implementation").extendsFrom(get("klibrary"))
|
||||||
}
|
}
|
||||||
|
|
||||||
data class GitInfo(val version: String, val count: String, val tag: String, val buildNumber: String) {
|
data class GitInfo(val version: String, val tag: String, val buildNumber: String) {
|
||||||
// val tagIsVersion: Boolean get() = tag != "" && tag.matches(Regex("v[0-9]+\\.[0-9]\\.[0-9]"))
|
// val tagIsVersion: Boolean get() = tag != "" && tag.matches(Regex("v[0-9]+\\.[0-9]\\.[0-9]"))
|
||||||
|
|
||||||
val publishVersion: String get() {
|
val publishVersion: String get() {
|
||||||
@ -67,7 +64,7 @@ data class GitInfo(val version: String, val count: String, val tag: String, val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val gitVersion = getCommitVersion() ?: GitInfo("", "", "", "")
|
val gitVersion = getCommitVersion() ?: GitInfo("", "", "")
|
||||||
|
|
||||||
version = gitVersion.modVersion
|
version = gitVersion.modVersion
|
||||||
group = "ru.dbotthepony"
|
group = "ru.dbotthepony"
|
||||||
@ -76,7 +73,6 @@ fun getCommitVersion(): GitInfo? {
|
|||||||
try {
|
try {
|
||||||
val versionStream = FastByteArrayOutputStream()
|
val versionStream = FastByteArrayOutputStream()
|
||||||
val tagStream = FastByteArrayOutputStream()
|
val tagStream = FastByteArrayOutputStream()
|
||||||
val countStream = FastByteArrayOutputStream()
|
|
||||||
|
|
||||||
val gotVersion = exec {
|
val gotVersion = exec {
|
||||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||||
@ -84,27 +80,20 @@ fun getCommitVersion(): GitInfo? {
|
|||||||
standardOutput = versionStream
|
standardOutput = versionStream
|
||||||
}.exitValue == 0
|
}.exitValue == 0
|
||||||
|
|
||||||
val gotCount = exec {
|
|
||||||
commandLine("git", "rev-list", "--count", "HEAD")
|
|
||||||
workingDir(".")
|
|
||||||
standardOutput = countStream
|
|
||||||
}.exitValue == 0
|
|
||||||
|
|
||||||
val gotTag = exec {
|
val gotTag = exec {
|
||||||
commandLine("git", "tag", "--points-at", "HEAD")
|
commandLine("git", "tag", "--points-at", "HEAD")
|
||||||
workingDir(".")
|
workingDir(".")
|
||||||
standardOutput = tagStream
|
standardOutput = tagStream
|
||||||
}.exitValue == 0
|
}.exitValue == 0
|
||||||
|
|
||||||
if (!gotVersion || !gotCount || !gotTag) {
|
if (!gotVersion || !gotTag) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val version = versionStream.array.copyOfRange(0, versionStream.length).toString(Charsets.UTF_8).trim()
|
val version = versionStream.array.copyOfRange(0, versionStream.length).toString(Charsets.UTF_8).trim()
|
||||||
val tag = tagStream.array.copyOfRange(0, tagStream.length).toString(Charsets.UTF_8).trim()
|
val tag = tagStream.array.copyOfRange(0, tagStream.length).toString(Charsets.UTF_8).trim()
|
||||||
val count = countStream.array.copyOfRange(0, countStream.length).toString(Charsets.UTF_8).trim()
|
|
||||||
|
|
||||||
return GitInfo(version, count, tag, System.getenv("BUILD_NUMBER") ?: "")
|
return GitInfo(version, tag, System.getenv("BUILD_NUMBER") ?: "")
|
||||||
} catch(err: Throwable) {
|
} catch(err: Throwable) {
|
||||||
println("Error getting git version")
|
println("Error getting git version")
|
||||||
println(err)
|
println(err)
|
||||||
@ -147,8 +136,6 @@ dependencies {
|
|||||||
val jupiter_version: String by project
|
val jupiter_version: String by project
|
||||||
val kotlin_version: String by project
|
val kotlin_version: String by project
|
||||||
val kotlin_for_forge_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
|
|
||||||
val mixin_version: String by project
|
val mixin_version: String by project
|
||||||
|
|
||||||
minecraft("net.minecraftforge:forge:$mc_version-$forge_version")
|
minecraft("net.minecraftforge:forge:$mc_version-$forge_version")
|
||||||
@ -156,7 +143,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version")
|
implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version")
|
||||||
|
|
||||||
fun library(notation: Any) { this.add("library", notation) }
|
|
||||||
fun klibrary(notation: Any) { this.add("klibrary", notation) }
|
fun klibrary(notation: Any) { this.add("klibrary", notation) }
|
||||||
|
|
||||||
val excludeKGroup = closureOf<Any> {
|
val excludeKGroup = closureOf<Any> {
|
||||||
@ -165,9 +151,6 @@ dependencies {
|
|||||||
|
|
||||||
klibrary(create("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version", excludeKGroup))
|
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.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))
|
|
||||||
|
|
||||||
compileOnly("yalter.mousetweaks:MouseTweaks:2.23:api")
|
compileOnly("yalter.mousetweaks:MouseTweaks:2.23:api")
|
||||||
annotationProcessor("org.spongepowered:mixin:${mixin_version}:processor")
|
annotationProcessor("org.spongepowered:mixin:${mixin_version}:processor")
|
||||||
@ -217,21 +200,26 @@ dependencies {
|
|||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
getByName("dataImplementation").extendsFrom(getByName("implementation"))
|
getByName("dataImplementation").extendsFrom(getByName("implementation"))
|
||||||
getByName("library").resolutionStrategy.cacheChangingModulesFor(10, "minutes")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
val use_parchment: String by project
|
mappings("official", mc_version)
|
||||||
|
|
||||||
if (use_parchment.toBoolean()) {
|
|
||||||
mappings("parchment", parchment_version)
|
|
||||||
} else {
|
|
||||||
mappings("official", mc_version)
|
|
||||||
}
|
|
||||||
|
|
||||||
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
|
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
|
configureEach {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
create("client") {
|
create("client") {
|
||||||
mods {
|
mods {
|
||||||
create(mod_id) {
|
create(mod_id) {
|
||||||
@ -282,33 +270,11 @@ minecraft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
/*mixin {
|
||||||
add(sourceSets.main.get(), "$mod_id.refmap.json")
|
add(sourceSets.main.get(), "$mod_id.refmap.json")
|
||||||
config("$mod_id.mixins.json")
|
config("$mod_id.mixins.json")
|
||||||
config("$mod_id.ad_astra.mixins.json")
|
config("$mod_id.ad_astra.mixins.json")
|
||||||
}
|
}*/
|
||||||
|
|
||||||
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["library"]
|
|
||||||
.copyRecursive()
|
|
||||||
.resolve()
|
|
||||||
.map { it.absolutePath }
|
|
||||||
.toMutableList()
|
|
||||||
.also { it.addAll(configurations["klibrary"].copyRecursive().resolve().map { it.absolutePath }) }
|
|
||||||
.joinToString(File.pathSeparator)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
||||||
@ -383,7 +349,6 @@ fun org.gradle.jvm.tasks.Jar.attachManifest() {
|
|||||||
// Example configuration to allow publishing using the maven-publish plugin
|
// Example configuration to allow publishing using the maven-publish plugin
|
||||||
// This is the preferred method to reobfuscate your jar file
|
// This is the preferred method to reobfuscate your jar file
|
||||||
tasks.jar.configure {
|
tasks.jar.configure {
|
||||||
from(configurations["library"].map { if (it.isDirectory) it else zipTree(it) })
|
|
||||||
finalizedBy("reobfJar")
|
finalizedBy("reobfJar")
|
||||||
attachManifest()
|
attachManifest()
|
||||||
archiveVersion.set(gitVersion.jarName)
|
archiveVersion.set(gitVersion.jarName)
|
||||||
@ -397,7 +362,6 @@ tasks {
|
|||||||
|
|
||||||
create("deobfJar", org.gradle.jvm.tasks.Jar::class.java) {
|
create("deobfJar", org.gradle.jvm.tasks.Jar::class.java) {
|
||||||
archiveClassifier.set("deobf")
|
archiveClassifier.set("deobf")
|
||||||
from(configurations["library"].map { if (it.isDirectory) it else zipTree(it) })
|
|
||||||
from(sourceSets.main.get().output)
|
from(sourceSets.main.get().output)
|
||||||
attachManifest()
|
attachManifest()
|
||||||
}
|
}
|
||||||
|
@ -31,15 +31,6 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maven(url = "https://maven.parchmentmc.org") {
|
|
||||||
name = "Parchment mappings"
|
|
||||||
|
|
||||||
content {
|
|
||||||
includeGroup("org.parchmentmc")
|
|
||||||
includeGroup("org.parchmentmc.feather")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,15 +38,11 @@ buildscript {
|
|||||||
val kotlin_version: String by settings
|
val kotlin_version: String by settings
|
||||||
val forge_gradle_version: String by settings
|
val forge_gradle_version: String by settings
|
||||||
val mixingradle_version: String by settings
|
val mixingradle_version: String by settings
|
||||||
val koremods_modlauncher_version: String by settings
|
|
||||||
val koremods_script_version: String by settings
|
|
||||||
|
|
||||||
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = forge_gradle_version)
|
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = forge_gradle_version)
|
||||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
|
||||||
classpath("org.spongepowered:mixingradle:${mixingradle_version}")
|
classpath("org.spongepowered:mixingradle:${mixingradle_version}")
|
||||||
|
|
||||||
classpath(group = "org.parchmentmc", name = "librarian", version = "1.+")
|
|
||||||
|
|
||||||
classpath(group = "org.gradle.toolchains", name = "foojay-resolver", version = "0.5.0")
|
classpath(group = "org.gradle.toolchains", name = "foojay-resolver", version = "0.5.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user