chore: slimmer build.gradle

This commit is contained in:
dev@ftbsc 2023-02-01 21:53:08 +01:00
parent 7ebbb991d2
commit 7ef6f46d8a

View file

@ -8,17 +8,18 @@ buildscript {
classpath "com.palantir.gradle.gitversion:gradle-git-version:0.13.0" classpath "com.palantir.gradle.gitversion:gradle-git-version:0.13.0"
} }
} }
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: "com.palantir.git-version" apply plugin: "com.palantir.git-version"
version gitVersion() version = gitVersion()
group = 'co.fantabos.bscv' group = 'co.fantabos.bscv'
archivesBaseName = 'boscovicino' archivesBaseName = 'boscovicino'
minecraftVersion = '1.16.5'
project.ext { project.ext {
minecraftVersion = getProjectProperty("bscv.mc.version", "1.16.5")
forgeVersion = getProjectProperty("bscv.forge.version", "1.16.5-36.2.39") forgeVersion = getProjectProperty("bscv.forge.version", "1.16.5-36.2.39")
copyJarDo = getProjectProperty("copyjar.do", "false") copyJarDo = getProjectProperty("copyjar.do", "false")
copyJarUseVersionSubDir = getProjectProperty("copyjar.useVersionSubDir", "false") copyJarUseVersionSubDir = getProjectProperty("copyjar.useVersionSubDir", "false")
@ -44,7 +45,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft { minecraft {
mappings channel: 'official', version: "${project.ext.minecraftVersion}" mappings channel: 'official', version: minecraftVersion
runs { runs {
client { client {
workingDirectory project.file('run') workingDirectory project.file('run')
@ -113,38 +114,15 @@ tasks.register('copyJar', Copy) {
if(!project.ext.copyJarDo.toBoolean()) return if(!project.ext.copyJarDo.toBoolean()) return
def modDir = "${project.ext.copyJarTargetGameDir}/mods/" def modDir = "${project.ext.copyJarTargetGameDir}/mods/"
//check if the per-version subdirectory is disabled
if(project.ext.copyJarUseVersionSubDir.toBoolean())
modDir = modDir + project.ext.minecraftVersion
// find previous jar (if it exists) // find previous jar (if it exists)
final previousJars = project.fileTree(dir: modDir).matching { final previousJars = project.fileTree(dir: modDir).matching {
include project.archivesBaseName + '*' include project.archivesBaseName + '*'
}.files }.files
//change filename
if (previousJars) {
if(copyJarKeepBackups.toBoolean()) {
//create .backups folder
final backupDir = modDir + '/.backups/'
project.file(backupDir).mkdirs()
for (File previousJar : previousJars) {
final n = modDir + '/.backups/' + previousJar.getName() + '.bk'
def f = project.file(n)
def i = 1
while (f.exists()) {
f = project.file(n + '_' + i)
i++
}
previousJar.renameTo(f)
}
} else
previousJars previousJars
.stream() .stream()
.filter(f -> f.toString().toLowerCase().endsWith("jar")) //dont kill old backups but smite existing jars .filter(f -> f.toString().toLowerCase().endsWith("jar")) //dont kill old backups but smite existing jars
.forEach(f -> f.delete()) .forEach(f -> f.delete())
}
//copy jar from build/libs to the forge mod folder //copy jar from build/libs to the forge mod folder
//from shadowJar //we want the über version, not the small one //from shadowJar //we want the über version, not the small one