Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update buildscript to RFG #14

Merged
merged 5 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 121 additions & 64 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
buildscript {
repositories {
maven {
name = "forge"
url = "https://maven.minecraftforge.net/"
}
maven {
url = 'https://maven.cleanroommc.com'
}
maven {
url = 'https://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
if (project.use_mixins.toBoolean()) {
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}
}

apply plugin: 'net.minecraftforge.gradle.forge'

if (project.use_mixins.toBoolean()) {
apply plugin: 'org.spongepowered.mixin'
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import org.jetbrains.gradle.ext.Gradle

plugins {
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.9"
id("com.matthewprenger.cursegradle") version "1.4.0"
}

version = project.mod_version
group = project.maven_group
archivesBaseName = project.archives_base_name

sourceCompatibility = targetCompatibility = '1.8'
// 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()
withJavadocJar()
}

compileJava {
sourceCompatibility = targetCompatibility = '1.8'
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

configurations {
Expand All @@ -41,10 +37,8 @@ configurations {
}

minecraft {
version = '1.12.2-14.23.5.2847'
runDir = 'run'
mappings = 'stable_39'
def args = []
mcVersion = '1.12.2'
def args = ["-ea:${project.group}"]
if (project.use_coremod.toBoolean()) {
args << '-Dfml.coreMods.load=' + coremod_plugin_class_name
}
Expand All @@ -53,76 +47,139 @@ minecraft {
args << '-Dmixin.checks.interfaces=true'
args << '-Dmixin.debug.export=true'
}
clientJvmArgs.addAll(args)
serverJvmArgs.addAll(args)
extraRunJvmArguments.addAll(args)

useDependencyAccessTransformers = true

replaceIn("src/main/java/${project.mod_ref_path.replace('.', '/')}.java")
replace("@VERSION@", project.mod_version)
replace("@MODID@", project.archivesBaseName)
injectedTags.put("VERSION", project.version)
injectedTags.put("ID", project.archives_base_name)
}

// Generate a my.project.Tags class with the version number as a field
tasks.injectTags.configure {
outputClassName.set("${project.group}.Tags")
}

repositories {
maven {
url = 'https://maven.cleanroommc.com'
}
maven { url = "https://repo.spongepowered.org/maven" }
//maven { url "https://maven.mcmoddev.com/" }
maven {
url = 'https://repo.spongepowered.org/maven'
}
maven {
url 'https://cursemaven.com'
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
url 'https://dvs1.progwml6.com/files/maven/'
}
mavenLocal() // Must be last for caching to work
}

dependencies {
compileOnly 'org.jetbrains:annotations:23.0.0'
implementation 'zone.rong:mixinbooter:7.0'

if (project.use_mixins.toBoolean()) {
deobfCompile 'zone.rong:mixinbooter:5.0'
}
api("org.spongepowered:mixin:0.8.3") { 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("org.spongepowered:mixin:0.8.3") { transitive = false }
// Example deobf dependency
// compileOnly rfg.deobf("curse.maven:endercore-231868:2972849:")

deobfCompile 'mezz.jei:jei_1.12.2:4.15.0.293'
implementation 'mezz.jei:jei_1.12.2:4.15.0.293'
}

sourceSets {
def mixinConfigRefMap = 'mixins.' + project.archives_base_name + '.refmap.json'
def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins'
def refMap = "${mixinTmpDir}" + File.separator + mixinConfigRefMap
def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg"

main {
ext.refMap = 'mixins.' + archives_base_name + '.refmap.json'
}
tasks.named("reobfJar", ReobfuscatedJar).configure {
extraSrgFiles.from(mixinSrg)
}

tasks.named("compileJava", JavaCompile).configure {
doFirst {
new File(mixinTmpDir).mkdirs()
}
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
]
}

processResources {
// this will ensure that this task is redone when the versions change.
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
fcd.expand(
'version': project.version,
'mcversion': project.minecraft.version
)
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'

if (project.use_access_transformer.toBoolean()) {
rename '(.+_at.cfg)', 'META-INF/$1' // Access Transformers
}
rename '(.+_at.cfg)', 'META-INF/$1' // Access Transformers

// Embed mixin refmap
from refMap
dependsOn("compileJava")
}

jar {
manifest {
def attribute_map = [:]
if (project.use_coremod.toBoolean()) {
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
attribute_map['FMLCorePluginContainsFMLMod'] = true
}
if (project.use_mixins.toBoolean()) {
attribute_map['TweakClass'] = 'org.spongepowered.asm.launch.MixinTweaker'
}
// false for dev and true for non dev
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
attribute_map['FMLCorePluginContainsFMLMod'] = true
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
if (project.use_access_transformer.toBoolean()) {
attribute_map['FMLAT'] = project.archives_base_name + '_at.cfg'
}
attributes(attribute_map)
}
// Add all embedded dependencies into the jar
from(provider { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } })
}

idea {
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"]
}
}
compiler.javac {
afterEvaluate {
javacAdditionalOptions = "-encoding utf8"
moduleJavacAdditionalOptions = [
(project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ')
]
}
}
}
}
}

tasks.named("processIdeaSettings").configure {
dependsOn("injectTags")
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ mod_ref_path = com.cleanroommc.modularui.ModularUI
# Boilerplate Options
use_mixins = true
use_coremod = true
use_assetmover = false
use_access_transformer = false

# Coremod Arguments
include_mod = true
coremod_plugin_class_name = com.cleanroommc.modularui.core.ModularUICore
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
24 changes: 24 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name = "GTNH Maven"
url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/")
allowInsecureProtocol = true
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroup("com.gtnewhorizons.retrofuturagradle")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}

plugins {
// Automatic toolchain provisioning
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
}

rootProject.name = "ModularUI"
5 changes: 3 additions & 2 deletions src/main/java/com/cleanroommc/modularui/ModularUI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cleanroommc.modularui;

import com.cleanroommc.Tags;
import com.cleanroommc.modularui.drawable.DrawableSerialization;
import com.cleanroommc.modularui.keybind.KeyBindHandler;
import com.cleanroommc.modularui.manager.GuiInfos;
Expand Down Expand Up @@ -29,9 +30,9 @@
@Mod(modid = ModularUI.ID, name = ModularUI.NAME, version = ModularUI.VERSION, dependencies = "required-after:mixinbooter@[5.0,);")
public class ModularUI {

public static final String ID = "@MODID@";
public static final String ID = Tags.ID;
public static final String NAME = "Modular UI";
public static final String VERSION = "@VERSION@";
public static final String VERSION = Tags.VERSION;
public static final Logger LOGGER = LogManager.getLogger(ID);

public static final String BOGO_SORT = "bogosorter";
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Rongmario",
"CleanroomMC"
],
"credits": "GTCE Autor for the idea and concept, Kila Bash for improvements in GTCEu",
"credits": "GTCE Author for the idea and concept, Kila Bash for improvements in GTCEu",
"logoFile": "assets/modularui/textures/modular_ui_logo.png",
"screenshots": [],
"dependencies": []
Expand Down