2023-04-24 13:23:28 +03:00
|
|
|
import org.jetbrains.gradle.ext.Gradle
|
2022-01-06 14:59:55 +03:00
|
|
|
|
2023-04-24 13:23:28 +03:00
|
|
|
plugins {
|
2023-05-28 05:55:27 +03:00
|
|
|
id 'java'
|
|
|
|
id 'java-library'
|
|
|
|
id 'maven-publish'
|
|
|
|
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
|
|
|
|
id 'eclipse'
|
|
|
|
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.16'
|
|
|
|
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
2022-01-20 19:56:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
version = project.mod_version
|
|
|
|
group = project.maven_group
|
|
|
|
archivesBaseName = project.archives_base_name
|
2022-01-06 14:59:55 +03:00
|
|
|
|
2023-04-24 13:23:28 +03:00
|
|
|
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
|
|
|
|
java {
|
|
|
|
toolchain {
|
|
|
|
languageVersion.set(JavaLanguageVersion.of(8))
|
|
|
|
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
|
|
|
|
vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.AZUL)
|
|
|
|
}
|
|
|
|
// Generate sources and javadocs jars when building and publishing
|
|
|
|
withSourcesJar()
|
2023-05-28 05:55:27 +03:00
|
|
|
// withJavadocJar()
|
2022-01-06 14:59:55 +03:00
|
|
|
}
|
|
|
|
|
2023-04-24 17:42:45 +03:00
|
|
|
tasks.withType(JavaCompile).configureEach {
|
2023-05-28 05:55:27 +03:00
|
|
|
options.encoding = 'UTF-8'
|
2023-04-24 17:42:45 +03:00
|
|
|
}
|
|
|
|
|
2022-01-20 19:56:26 +03:00
|
|
|
configurations {
|
|
|
|
embed
|
|
|
|
implementation.extendsFrom(embed)
|
|
|
|
}
|
|
|
|
|
2022-01-06 14:59:55 +03:00
|
|
|
minecraft {
|
2023-04-24 13:23:28 +03:00
|
|
|
mcVersion = '1.12.2'
|
2023-05-28 05:55:27 +03:00
|
|
|
|
|
|
|
// MCP Mappings
|
|
|
|
mcpMappingChannel = 'stable'
|
|
|
|
mcpMappingVersion = '39'
|
|
|
|
|
|
|
|
// Set username here, the UUID will be looked up automatically
|
|
|
|
username = 'Developer'
|
|
|
|
|
|
|
|
// Add any additional tweaker classes here
|
|
|
|
// extraTweakClasses.add('org.spongepowered.asm.launch.MixinTweaker')
|
|
|
|
|
|
|
|
// Add various JVM arguments here for runtime
|
2023-04-24 13:23:28 +03:00
|
|
|
def args = ["-ea:${project.group}"]
|
2022-09-05 17:04:02 +03:00
|
|
|
if (project.use_coremod.toBoolean()) {
|
|
|
|
args << '-Dfml.coreMods.load=' + coremod_plugin_class_name
|
|
|
|
}
|
|
|
|
if (project.use_mixins.toBoolean()) {
|
|
|
|
args << '-Dmixin.hotSwap=true'
|
|
|
|
args << '-Dmixin.checks.interfaces=true'
|
|
|
|
args << '-Dmixin.debug.export=true'
|
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
extraRunJvmArguments.addAll(args)
|
|
|
|
|
2023-05-28 05:55:27 +03:00
|
|
|
// Include and use dependencies' Access Transformer files
|
2023-04-27 15:04:20 +03:00
|
|
|
useDependencyAccessTransformers = true
|
2023-05-28 05:55:27 +03:00
|
|
|
|
|
|
|
// Add any properties you want to swap out for a dynamic value at build time here
|
|
|
|
// Any properties here will be added to a class at build time, the name can be configured below
|
|
|
|
// Example:
|
|
|
|
// injectedTags.put('VERSION', project.version)
|
|
|
|
// injectedTags.put('MOD_ID', project.archives_base_name)
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
|
|
|
|
2023-05-28 05:55:27 +03:00
|
|
|
// Generate a group.archives_base_name.Tags class
|
2023-04-24 13:23:28 +03:00
|
|
|
tasks.injectTags.configure {
|
2023-05-28 05:55:27 +03:00
|
|
|
// Change Tags class' name here:
|
|
|
|
outputClassName.set("${project.group}.${project.archives_base_name}.Tags")
|
2022-01-20 19:56:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
2023-04-24 13:23:28 +03:00
|
|
|
maven {
|
2023-05-28 05:55:27 +03:00
|
|
|
name 'CleanroomMC Maven'
|
|
|
|
url 'https://maven.cleanroommc.com'
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name 'SpongePowered Maven'
|
|
|
|
url 'https://repo.spongepowered.org/maven'
|
2022-09-05 17:04:02 +03:00
|
|
|
}
|
2022-01-20 19:56:26 +03:00
|
|
|
maven {
|
2023-05-28 05:55:27 +03:00
|
|
|
name 'CurseMaven'
|
|
|
|
url 'https://cursemaven.com'
|
2023-04-24 13:23:28 +03:00
|
|
|
content {
|
2023-05-28 05:55:27 +03:00
|
|
|
includeGroup 'curse.maven'
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
2022-01-20 19:56:26 +03:00
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
mavenLocal() // Must be last for caching to work
|
2022-01-06 14:59:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2022-09-05 17:04:02 +03:00
|
|
|
if (project.use_assetmover.toBoolean()) {
|
2023-05-28 05:55:27 +03:00
|
|
|
implementation 'com.cleanroommc:assetmover:2.5'
|
2022-09-05 17:04:02 +03:00
|
|
|
}
|
|
|
|
if (project.use_mixins.toBoolean()) {
|
2023-05-28 05:55:27 +03:00
|
|
|
implementation 'zone.rong:mixinbooter:7.1'
|
2022-01-20 19:56:26 +03:00
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
|
2023-05-28 05:55:27 +03:00
|
|
|
// Example of deobfuscating a dependency
|
|
|
|
// implementation rfg.deobf('curse.maven:had-enough-items-557549:4543375')
|
2023-04-24 13:23:28 +03:00
|
|
|
|
|
|
|
if (project.use_mixins.toBoolean()) {
|
2023-05-28 05:55:27 +03:00
|
|
|
// Change your mixin refmap name here:
|
|
|
|
String mixin = modUtils.enableMixins('org.spongepowered:mixin:0.8.3', "mixins.${project.archives_base_name}.refmap.json")
|
|
|
|
api (mixin) {
|
|
|
|
transitive = false
|
|
|
|
}
|
|
|
|
annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
|
|
|
|
annotationProcessor 'com.google.guava:guava:24.1.1-jre'
|
|
|
|
annotationProcessor 'com.google.code.gson:gson:2.8.6'
|
|
|
|
annotationProcessor (mixin) {
|
|
|
|
transitive = false
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
|
|
|
}
|
2023-05-28 05:55:27 +03:00
|
|
|
|
2022-01-06 14:59:55 +03:00
|
|
|
}
|
|
|
|
|
2023-05-28 05:55:27 +03:00
|
|
|
// Adds Access Transformer files to tasks
|
2023-04-24 13:28:24 +03:00
|
|
|
if (project.use_access_transformer.toBoolean()) {
|
|
|
|
for (File at : sourceSets.getByName("main").resources.files) {
|
|
|
|
if (at.name.toLowerCase().endsWith("_at.cfg")) {
|
|
|
|
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
|
|
|
|
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-06 14:59:55 +03:00
|
|
|
processResources {
|
2023-05-28 05:55:27 +03:00
|
|
|
// This will ensure that this task is redone when the versions change
|
2022-01-20 19:56:26 +03:00
|
|
|
inputs.property 'version', project.version
|
|
|
|
inputs.property 'mcversion', project.minecraft.version
|
2023-05-28 05:55:27 +03:00
|
|
|
|
|
|
|
// Replace various properties in mcmod.info and pack.mcmeta if applicable
|
2023-04-24 13:23:28 +03:00
|
|
|
filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
|
2023-05-28 05:55:27 +03:00
|
|
|
// Replace version and mcversion
|
2023-04-24 13:23:28 +03:00
|
|
|
fcd.expand (
|
|
|
|
'version': project.version,
|
|
|
|
'mcversion': project.minecraft.version
|
|
|
|
)
|
2022-01-06 14:59:55 +03:00
|
|
|
}
|
2022-09-05 17:04:02 +03:00
|
|
|
|
|
|
|
if (project.use_access_transformer.toBoolean()) {
|
2023-05-28 05:55:27 +03:00
|
|
|
rename '(.+_at.cfg)', 'META-INF/$1' // Make sure Access Transformer files are in META-INF folder
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
2022-01-20 19:56:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
jar {
|
|
|
|
manifest {
|
2022-09-05 17:04:02 +03:00
|
|
|
def attribute_map = [:]
|
|
|
|
if (project.use_coremod.toBoolean()) {
|
|
|
|
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
|
|
|
|
if (project.include_mod.toBoolean()) {
|
|
|
|
attribute_map['FMLCorePluginContainsFMLMod'] = true
|
|
|
|
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
|
|
|
|
}
|
|
|
|
}
|
2023-05-28 05:55:27 +03:00
|
|
|
if (project.use_access_transformer.toBoolean()) {
|
2022-09-05 17:04:02 +03:00
|
|
|
attribute_map['FMLAT'] = project.archives_base_name + '_at.cfg'
|
|
|
|
}
|
2022-01-20 19:56:26 +03:00
|
|
|
attributes(attribute_map)
|
|
|
|
}
|
2023-04-24 17:39:55 +03:00
|
|
|
// Add all embedded dependencies into the jar
|
|
|
|
from(provider{ configurations.embed.collect {it.isDirectory() ? it : zipTree(it)} })
|
2022-01-06 14:59:55 +03:00
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
|
|
|
|
idea {
|
2023-05-28 05:55:27 +03:00
|
|
|
module {
|
|
|
|
inheritOutputDirs = true
|
|
|
|
}
|
|
|
|
project {
|
|
|
|
settings {
|
|
|
|
runConfigurations {
|
|
|
|
"1. Run Client"(Gradle) {
|
|
|
|
taskNames = ["runClient"]
|
|
|
|
}
|
|
|
|
"2. Run Server"(Gradle) {
|
|
|
|
taskNames = ["runServer"]
|
|
|
|
}
|
|
|
|
"3. Run Obfuscated Client"(Gradle) {
|
|
|
|
taskNames = ["runObfClient"]
|
|
|
|
}
|
|
|
|
"4. Run Obfuscated Server"(Gradle) {
|
|
|
|
taskNames = ["runObfServer"]
|
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
2023-05-28 05:55:27 +03:00
|
|
|
compiler.javac {
|
|
|
|
afterEvaluate {
|
|
|
|
javacAdditionalOptions = "-encoding utf8"
|
|
|
|
moduleJavacAdditionalOptions = [
|
|
|
|
(project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ')
|
|
|
|
]
|
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
|
|
|
}
|
2023-05-28 05:55:27 +03:00
|
|
|
}
|
2023-04-24 13:23:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("processIdeaSettings").configure {
|
|
|
|
dependsOn("injectTags")
|
|
|
|
}
|