diff options
-rw-r--r-- | installMinecraft.init.gradle.kts | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/installMinecraft.init.gradle.kts b/installMinecraft.init.gradle.kts index dd052e4..bf28e9e 100644 --- a/installMinecraft.init.gradle.kts +++ b/installMinecraft.init.gradle.kts @@ -9,41 +9,43 @@ * Will prefer a remapJar task, or otherwise use the shadowJar or jar tasks (for forge gradle). */ - allprojects { this.afterEvaluate { if (!listOf( - "gg.essential.loom", - "cc.polyfrost.loom", - "dev.architectury.loom", - "fabric-loom", - "net.minecraftforge.gradle.tweaker-client", - "net.minecraftforge.gradle.forge", - "xyz.wagyourtail.unimined" - ).any { plugins.hasPlugin(it) } - ) { - return@afterEvaluate - } - val toInstall = listOf("remapJar", "shadowJar", "jar").mapNotNull { - tasks.findByName(it) - }.filterIsInstance<org.gradle.jvm.tasks.Jar>().firstOrNull() - val targetDirectory = File(project.findProperty("minecraft.modfolder") as String) - if (toInstall != null) { - tasks.create("installToMinecraft") { - dependsOn(toInstall) - doLast { - val modJar = toInstall.archiveFile.get().asFile - targetDirectory.listFiles() - .filter { - it.name.startsWith(toInstall.archiveBaseName.get()) - } - .forEach { - it.delete() + "gg.essential.loom", + "cc.polyfrost.loom", + "dev.architectury.loom", + "fabric-loom", + "net.minecraftforge.gradle.tweaker-client", + "net.minecraftforge.gradle.forge", + "xyz.wagyourtail.unimined", + ).any { plugins.hasPlugin(it) } + ) { + return@afterEvaluate + } + val toInstall = + listOf("remapJar", "shadowJar", "jar") + .mapNotNull { + tasks.findByName(it) + }.filterIsInstance<org.gradle.jvm.tasks.Jar>() + .firstOrNull() + val targetDirectory = File(project.findProperty("minecraft.modfolder") as? String ?: return@afterEvaluate) + if (toInstall != null) { + tasks.create("installToMinecraft") { + dependsOn(toInstall) + doLast { + val modJar = toInstall.archiveFile.get().asFile + targetDirectory + .listFiles() + .filter { + it.name.startsWith(toInstall.archiveBaseName.get()) + }.forEach { + it.delete() + } + modJar.copyTo(targetDirectory.resolve(modJar.name)) + println("Installed $modJar to $targetDirectory") } - modJar.copyTo(targetDirectory.resolve(modJar.name)) - println("Installed $modJar to $targetDirectory") } } } } -} |