BaseBandRewrite/Client/build.gradle

132 lines
3.5 KiB
Groovy
Raw Normal View History

import java.security.MessageDigest
2023-08-26 16:19:12 +02:00
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.1', changing: true
classpath "org.spongepowered:mixingradle:0.7.+"
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
group = project.modGroup
version = project.modVersion
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
tasks.withType(JavaCompile) {
configure(options) {
options.compilerArgs.add("-XDignore.symbol.file=true")
options.encoding = 'utf-8'
}
}
minecraft {
mappings channel: 'stable', version: '39-1.12'
accessTransformer = file('src/main/resources/client_at.cfg')
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
}
}
}
repositories {
maven {
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/maven'
}
maven {
name = "jitpack.io"
url = "https://jitpack.io"
}
mavenCentral()
}
dependencies {
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'
implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
annotationProcessor('org.spongepowered:mixin:0.8.5:processor') {
exclude module: 'gson'
}
}
compileJava {
def srcDir = file('src') // Replace 'src' with the actual source directory path
if (!srcDir.isDirectory()) {
throw new GradleException("The 'src' directory does not exist.")
}
// Calculate the hash of the source directory
MessageDigest md = MessageDigest.getInstance("SHA-256")
srcDir.traverse { file ->
if (file.isFile()) {
md.update(file.bytes)
}
}
def hashBytes = md.digest()
// Convert the hash to a 16-character hexadecimal string
def hash = hashBytes.encodeHex().toString().substring(0,16);
2023-09-07 19:00:56 +02:00
def targetFile = file("src/main/java/com/baseband/client/BaseBand.java")
2023-08-26 16:19:12 +02:00
def content = targetFile.text
def updatedContent = content.replaceFirst("buildNumber = (\\d+)", { _, value -> "buildNumber = ${value.toInteger() + 1}" })
updatedContent = updatedContent.replaceFirst("public static String hash = \".*\";", "public static String hash = \"" + hash + "\";")
2023-08-26 16:19:12 +02:00
targetFile.text = updatedContent
}
processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
inputs.property 'version', project.version
inputs.property 'mcversion', '1.12.2'
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.version, 'mcversion': '1.12.2'
}
from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' }
rename '(.+_at.cfg)', 'META-INF/$1'
}
mixin {
defaultObfuscationEnv 'searge'
add sourceSets.main, 'mixins.baseband.refmap.json'
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}