bscv/build.gradle

167 lines
5.7 KiB
Groovy
Raw Normal View History

2023-01-24 01:07:30 +01:00
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
2023-02-01 20:30:37 +01:00
classpath "com.palantir.gradle.gitversion:gradle-git-version:0.13.0"
2023-01-24 01:07:30 +01:00
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
2023-01-31 23:02:27 +01:00
apply plugin: "com.palantir.git-version"
2023-01-24 01:07:30 +01:00
2023-01-31 23:02:27 +01:00
version gitVersion()
group = 'co.fantabos.bscv'
2023-01-24 01:07:30 +01:00
archivesBaseName = 'boscovicino'
project.ext {
minecraftVersion = getProjectProperty("bscv.mc.version", "1.16.5")
forgeVersion = getProjectProperty("bscv.forge.version", "1.16.5-36.2.39")
copyJarDo = getProjectProperty("copyjar.do", "false")
copyJarUseVersionSubDir = getProjectProperty("copyjar.useVersionSubDir", "false")
copyJarKeepBackups = getProjectProperty("copyjar.keepBackups", "true")
copyJarTargetGameDir = getProjectProperty("copyjar.targetGameDir", getOsGameDir())
}
def getProjectProperty(String property, String fallback) { //allows for custom gradle.properties while retaining default fallback values
return (project.hasProperty(property)) ? project.property(property) : fallback
}
def getOsGameDir() {
if (org.gradle.internal.os.OperatingSystem.current().isWindows())
return System.getenv("APPDATA") + "/.minecraft"
else if (org.gradle.internal.os.OperatingSystem.current().isMacOsX())
return System.properties["user.home"] + "/Library/Application Support/minecraft"
else
return System.properties["user.home"] + "/.minecraft"
}
2023-01-24 01:07:30 +01:00
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
2023-01-24 01:07:30 +01:00
minecraft {
mappings channel: 'official', version: "${project.ext.minecraftVersion}"
2023-01-24 01:07:30 +01:00
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// The markers can be changed as needed.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
bscv {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'bsvc', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
bscv {
source sourceSets.main
}
}
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies {
minecraft "net.minecraftforge:forge:${project.ext.forgeVersion}"
2023-01-24 01:07:30 +01:00
}
jar {
2023-01-31 23:02:27 +01:00
archiveName = "${jar.baseName}.${jar.extension}"
2023-01-24 01:07:30 +01:00
manifest {
attributes([
"Specification-Title": "bscv",
"Specification-Vendor": "ftbsc",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ftbsc",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')
tasks.register('copyJar', Copy) {
if(!project.ext.copyJarDo.toBoolean()) return
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)
final previousJars = project.fileTree(dir: modDir).matching {
include project.archivesBaseName + '*'
}.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
.stream()
.filter(f -> f.toString().toLowerCase().endsWith("jar")) //dont kill old backups but smite existing jars
.forEach(f -> f.delete())
}
//copy jar from build/libs to the forge mod folder
//from shadowJar //we want the über version, not the small one
from reobfJar
into modDir
}
2023-01-24 01:07:30 +01:00
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}