Skip to content

Commit

Permalink
Set up RFG Gradle project
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed May 16, 2024
1 parent be2479d commit 6ea0442
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
27 changes: 27 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build the mod
run: ./gradlew --no-daemon build
- uses: actions/upload-artifact@v3
with:
name: Download
path: build/libs
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ant stuff
build.xml
/bin/
/download/
#Remove OS generated garbage
*/.DS_Store
.DS_Store
.DS_Store?
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
#gradle stuff
/.gradle
/build/
/run/
#IDEA files from Gradle
.idea/
/*.iml
/*.ipr
/*.iws
out/
#Vim backups
*~
#eclipse stuffs
/.classpath
/.project
/.settings/
/eclipse/
/*.launch
209 changes: 209 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
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.33'
id 'com.matthewprenger.cursegradle' version '1.4.0'
}

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

// 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()
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

configurations {
embed
implementation.extendsFrom(embed)
}

minecraft {
mcVersion = '1.12.2'

// 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
def args = ["-ea:${project.group}"]
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'
}
extraRunJvmArguments.addAll(args)

// Include and use dependencies' Access Transformer files
useDependencyAccessTransformers = true

// 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)
}

// Generate a group.archives_base_name.Tags class
tasks.injectTags.configure {
// Change Tags class' name here:
outputClassName.set("${project.group}.${project.mod_id}.Tags")
}

repositories {
maven {
name 'CleanroomMC Maven'
url 'https://maven.cleanroommc.com'
}
maven {
name 'SpongePowered Maven'
url 'https://repo.spongepowered.org/maven'
}
maven {
name 'CurseMaven'
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
name 'BlameJared Maven'
url 'https://maven.blamejared.com'
}
mavenLocal() // Must be last for caching to work
}

dependencies {
if (project.use_assetmover.toBoolean()) {
implementation 'com.cleanroommc:assetmover:2.5'
}
if (project.use_mixins.toBoolean()) {
implementation 'zone.rong:mixinbooter:9.1'
}

// Example of deobfuscating a dependency
// implementation rfg.deobf('curse.maven:had-enough-items-557549:4543375')
implementation rfg.deobf('curse.maven:thaumcraft-223628:2629023')
implementation 'curse.maven:thaumic-augmentation-319441:5129458'

if (project.use_mixins.toBoolean()) {
// Change your mixin refmap name here:
String mixin = modUtils.enableMixins('org.spongepowered:mixin:0.8.3', "mixins.${project.mod_id}.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
}
}

}

// Adds Access Transformer files to tasks
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)
}
}
}

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 various properties in mcmod.info and pack.mcmeta if applicable
filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
// Replace version and mcversion
fcd.expand('version': project.version,
'mcversion': project.minecraft.version)
}

if (project.use_access_transformer.toBoolean()) {
rename '(.+_at.cfg)', 'META-INF/$1' // Make sure Access Transformer files are in META-INF folder
}
}

jar {
manifest {
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"
}
}
if (project.use_access_transformer.toBoolean()) {
attribute_map['FMLAT'] = project.mod_id + '_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")
}
23 changes: 23 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs = -Xmx3G

# Mod Information
mod_id = crimsonrevelations
mod_version = 1.0
maven_group = com.mobiusflip
archives_base_name = crimsonrevelations

# If any properties changes below this line, run `gradlew setupDecompWorkspace` and refresh gradle again to ensure everything is working correctly.

# Boilerplate Options
use_mixins = false
use_coremod = false
use_assetmover = false

# Access Transformer files should be in the root of `resources` folder and with the filename formatted as: `{archives_base_name}_at.cfg`
use_access_transformer = false

# Coremod Arguments
include_mod = true
coremod_plugin_class_name =
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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
Loading

0 comments on commit 6ea0442

Please sign in to comment.