Skip to content

Instantly share code, notes, and snippets.

@fallenthereaper
Last active November 17, 2023 14:16
Show Gist options
  • Save fallenthereaper/5c06f5a374ae360a0cdf094277690b6d to your computer and use it in GitHub Desktop.
Save fallenthereaper/5c06f5a374ae360a0cdf094277690b6d to your computer and use it in GitHub Desktop.
build.gradle
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${forgegradle_version}", changing: true
classpath 'org.parchmentmc:librarian:1.+'
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
plugins {
id 'net.minecraftforge.gradle' version '5.1.+'
id 'com.github.johnrengelman.shadow' version "${shadow_version}"
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'org.spongepowered.mixin'
group = 'com.fallenreaper'
version = '1.0-SNAPSHOT'
boolean inWorkspace = findProject(':insight') != null
java {
archivesBaseName = 'fable'
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
minecraft {
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// official MCVersion Official field/method names from Mojang mapping files
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
//
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
// mappings channel: 'official', version: '1.19.3'
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
// enable using JBR to hotswap MOAR
// also ignore the option if someone isnt using JBR
jvmArgs '-XX:+AllowEnhancedClassRedefinition', '-XX:+IgnoreUnrecognizedVMOptions'
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'fable'
mods {
fable {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'fable'
mods {
fable {
source sourceSets.main
}
}
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'fable'
mods {
fable {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
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', 'fable', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
fable {
source sourceSets.main
}
}
}
}
}
mixin {
add sourceSets.main, "fable.refmap.json"
config "fable.mixins.json"
}
afterEvaluate {
tasks.configureReobfTaskForReobfJar.mustRunAfter(tasks.compileJava)
tasks.configureReobfTaskForReobfJarJar.mustRunAfter(tasks.compileJava)
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
mavenLocal()
maven { // Registrate
url "https://maven.tterrag.com/"
}
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
name = 'GeckoLib'
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
}
maven {
// Location of the maven that hosts JEI files (and TiC)
name 'Progwml6 maven'
url 'https://dvs1.progwml6.com/files/maven'
}
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
maven {
url = "https://maven.theillusivec4.top/"
}
// maven {
// name 'JEI maven'
// url = "https://dvs1.progwml6.com/files/maven"
// }
maven {
// location of the maven that hosts JEI files since January 2023
// location of the maven for Vazkii's mods
name = "Jared's maven"
url = "https://maven.blamejared.com/"
}
// If you havej mod jar dependencies in ./libs, you can declare them as a repository like so:
flatDir {
dir 'libs'
}
}
jarJar.enable()
jarJar.fromRuntimeConfiguration()
jarJar {
// Include or exclude dependencies here from runtime configuration
dependencies {
// Exclude any dependency which begins with 'com.google.gson.'
exclude(dependency('com.tterrag.registrate:Registrate'))
}
}
configurations {
library
implementation.extendsFrom library
}
dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.9.2'
jarJar(group: 'com.tterrag.registrate', name: 'Registrate', version: '[MC1.19-1.1.5,)') {
jarJar.pin(it, project.registrate_version)
}
// implementation fg.deobf('com.fallenreaper:insight:1.0-ALPHA')
// implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.20.1:4.2.2')
def registrate = "com.tterrag.registrate:Registrate:${registrate_version}"
// implementation "org.joml:joml:${jomlVersion}"
implementation fg.deobf(registrate)
// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}"))
compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}"))
// at runtime, use the full JEI jar for Forge
runtimeOnly(fg.deobf("curse.maven:not-enough-crashes-forge-442354:4181251"))
/// runtimeOnly(fg.deobf("curse.maven:supplementaries-412082:4488276"))
runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}"))
// Examples using mod jars from ./libs
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
def insightLib = "com.fallenreaper.insight:insight:${insightlib_version}"
// jarJar(group: 'com.fallenreaper.insight', name: 'insight', version: "[${insightlib_version},)") {
// // transitive = true
// // exclude group: 'group', module: 'registrate'
// jarJar.pin(it, '[1.19-1.0,)')
// }
jarJar(group: 'com.fallenreaper.insight', name: 'insight', version: "[${insightlib_version},)") {
// transitive = true
// exclude group: 'group', module: 'registrate'
jarJar.pin(it, '[1.19-1.0,)')
}
// jarJar 'ignored:insight-1.0:1.19.2'
implementation fg.deobf(insightLib)
//library (group: 'com.fallenreaper.insight', name: 'insight', version: "[${insightlib_version},)") {
// // transitive = true
// // exclude group: 'group', module: 'registrate'
// jarJar.pin(it, '[1.19-1.0,)')
//}
// implementation fg.deobf('blank:insight-1.19.2:1.0-ALPHA')
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
"Specification-Title" : "fable",
"Specification-Vendor" : "FallenReaper",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "FallenReaper",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
shadowJar {
classifier = ''
// configurations = [project.configurations.shade]
relocate 'com.tterrag.registrate', 'com.fallenreaper.fable.repack.registrate'
}
reobf {
shadowJar {}
}
artifacts {
archives jar, shadowJar
}
publishing {
tasks.publish.dependsOn 'build'
publications {
mavenJava(MavenPublication) {
artifact shadowJar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
jar.finalizedBy('reobfJar')
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment