ViaFabricPlus/build.gradle
2023-02-24 00:27:51 +01:00

107 lines
2.5 KiB
Groovy

plugins {
id "fabric-loom" version "1.1-SNAPSHOT"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
configurations {
include
implementation.extendsFrom include
api.extendsFrom include
}
allprojects {
repositories {
mavenCentral()
maven {
name = "Jitpack"
url = "https://jitpack.io"
}
maven {
name = "ViaVersion"
url "https://repo.viaversion.com"
}
}
}
loom {
accessWidenerPath = file("src/main/resources/viafabricplus.accesswidener")
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
include "com.github.FlorianMichael:ViaLoadingBase:${project.vialoadingbase_version}"
include "com.viaversion:viaversion:${project.viaversion_version}"
include "com.viaversion:viabackwards-common:${project.viabackwards_version}"
include "org.yaml:snakeyaml:1.29"
include "com.github.RaphiMC:ViaLegacy:${project.vialegacy_version}"
include "com.github.RaphiMC:ViaAprilFools:${project.viaaprilfools_version}"
include "net.lenni0451.mcstructs:text:${project.mcstructs_text_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}
java {
withSourcesJar()
}
jar {
dependsOn configurations.include
from {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations.include.collect {
zipTree(it)
}
} {
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
}
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
tasks.register("installAddons") {
group archivesBaseName
dependsOn "build"
doLast {
File base = file(".")
base.listFiles().each {
if (it.name.startsWith("ViaFabricPlus-") && it.isDirectory()) {
String addonName = it.name.toLowerCase() + "-" + project(it.name).version + ".jar"
File build = new File(it, "build" + File.separator + "libs" + File.separator + addonName)
File modDest = new File(base, "run" + File.separator + "mods" + File.separator + addonName)
if(build.exists()) {
if (modDest.delete())
println "Deleted old $addonName"
else
println "Failed to delete old $addonName version"
if (build.renameTo(modDest))
println "Copied $addonName"
}
}
}
}
}