Skip to content

Instantly share code, notes, and snippets.

@Lanse505
Created June 19, 2022 14:25
Show Gist options
  • Save Lanse505/baa5f2c95345b650b2319dda2792dc71 to your computer and use it in GitHub Desktop.
Save Lanse505/baa5f2c95345b650b2319dda2792dc71 to your computer and use it in GitHub Desktop.
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://plugins.gradle.org/m2/' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.parchmentmc:librarian:1.+'
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.1'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"
apply plugin: 'org.spongepowered.mixin'
version = "${minecraft_version}-" + getVersion()
group = "${group}"
java {
archivesBaseName = "${archive}"
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
repositories {
mavenLocal()
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "Titanium"
url = 'https://cdn.hrzn.studio/maven/'
}
maven {
name = "JEI"
url = 'https://dvs1.progwml6.com/files/maven'
}
maven {
name = "Curios"
url = 'https://maven.theillusivec4.top/'
}
maven {
name = "Patchouli"
url = 'https://maven.blamejared.com'
}
maven {
name = "Registrate"
url = "https://maven.tterrag.com/"
}
}
sourceSets {
api {}
main {
compileClasspath += api.compileClasspath
runtimeClasspath += api.runtimeClasspath
resources {
include '**/**'
srcDirs += "$rootDir/src/generated/resources"
exclude '.cache'
}
}
datagen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += main.output
runtimeClasspath += main.output
}
}
def version_properties = [
"version" : mod_version,
"mc_version" : minecraft_version,
"forge_version" : forge_version,
"loader_version": loader_version
]
processResources {
outputs.upToDateWhen { false }
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from(sourceSets.main.resources) {
include "META-INF/mods.toml"
expand version_properties
}
into "$buildDir/resources/main/"
}
minecraft {
mappings channel: "parchment", version: "${mappings_version}-1.19"
runs {
client {
workingDirectory project.file('run')
arg '-mixin.config=' + project.archive + '.mixins.json'
properties 'mixin.env.disableRefMap': 'true'
mods {
essence {
source(sourceSets.main)
}
}
}
server {
workingDirectory project.file('run')
arg '-mixin.config=' + project.archive + '.mixins.json'
properties 'mixin.env.disableRefMap': 'true'
mods {
essence {
source(sourceSets.main)
}
}
}
data {
workingDirectory project.file('run')
properties 'fml.earlyprogresswindow': 'false'
properties 'mixin.env.disableRefMap': 'true'
args '--all', '--output', file('src/generated/resources/'),
'--reports',
'--mod', 'essence', '--existing', file('src/main/resources')
mods {
essence {
source(sourceSets.main)
}
}
}
}
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
}
configurations {
shade
}
shadowJar {
configurations = [project.configurations.shade]
relocate 'com.tterrag.registrate', "com.teamacronymcoders.essence.repack.registrate"
classifier ''
}
dependencies {
// Forge
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// Titanium
//implementation fg.deobf("com.hrznstudio:titanium:${titanium_version}") {
// transitive = false
//}
// Registrate
//def registrate = "com.tterrag.registrate:Registrate:MC1.18-${registrate_version}"
//implementation fg.deobf(registrate)
//shade registrate
//Patchouli
implementation fg.deobf("vazkii.patchouli:Patchouli:${minecraft_version}-${patchouli_version}")
// JEI
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")
// Curios
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${minecraft_version}-${curios_version}:api")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${minecraft_version}-${curios_version}")
// Apply Mixin AP
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
mixin {
add sourceSets.main, "${project.archive}.refmap.json"
config 'essence.mixins.json'
}
task apiJar(type: Jar) {
from sourceSets.api.allSource
classifier = "api"
}
task srcJar(type: Jar) {
from sourceSets.main.allSource
classifier = "sources"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}
task registrateJar(type: Jar, dependsOn: javadoc) {
classifier = "registrate"
from sourceSets.main.allSource
exclude '**/**'
include 'com/teamacronymcoders/essence/registrate/**'
}
jar {
classifier = "nodep"
manifest {
attributes([
"Specification-Title" : "${title}",
"Specification-Vendor" : "${team}",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "${team}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"ModSide": "BOTH",
'MixinConfigs': "${project.archive}.mixins.json"
],)
}
}
reobf {
shadowJar{}
registrateJar{}
}
build.dependsOn shadowJar
build.dependsOn reobfShadowJar
build.dependsOn registrateJar
build.dependsOn reobfRegistrateJar
artifacts {
archives javadocJar
archives apiJar
archives srcJar
archives shadowJar
archives registrateJar
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}
String getVersion() {
String version = "${mod_version}"
String branch = project.hasProperty("branch") ? project.branch : ""
if (branch != "") {
version += "-" + branch
String buildNumber = getBuildNumber()
if (buildNumber != "") {
version += "." + buildNumber
}
}
return version
}
static String getBuildNumber() {
String buildNumber = System.getenv("BUILD_NUMBER") != null ? System.getenv("BUILD_NUMBER") : ""
if (buildNumber == "") {
buildNumber = System.getenv("bamboo_buildNumber") != null ? System.getenv("bamboo_buildNumber") : ""
}
return buildNumber
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "100000"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment