plugins {
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version "${forgegradle_version}"
id 'org.spongepowered.mixin' version "${mixingradle_version}"
id 'org.parchmentmc.librarian.forgegradle' version "${librarian_version}"
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
}
apply from: './gradle/java.gradle'
jarJar.enable()
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false')
ext.buildNumber = System.getenv('BUILD_NUMBER')
base {
archivesName = "create-${artifact_minecraft_version}"
group = 'com.simibubi.create'
version = mod_version + (dev && buildNumber != null ? "-${buildNumber}" : '')
}
// jozu: I use a gradle workspace with both projects.
// The project is named Flywheel-Forge, but sub-projects are named by folder.
boolean flywheelInWorkspace = findProject(':Flywheel') != null
boolean inMultiModWorkspace = rootProject.hasProperty('multiModWorkspace.enabled')
boolean catnipInWorkspace = rootProject.hasProperty('multiModWorkspace.catnip')
boolean ponderInWorkspace = rootProject.hasProperty('multiModWorkspace.ponder')
if (catnipInWorkspace) {
evaluationDependsOn(":catnip")
}
if (ponderInWorkspace) {
evaluationDependsOn(":Ponder")
}
project.logger.lifecycle("MultiModWorkspace ${inMultiModWorkspace || flywheelInWorkspace ? 'enabled' : 'disabled'} for project ${project.name}.")
project.logger.lifecycle("Dependencies included in Workspace: [Flywheel: ${flywheelInWorkspace}], [Catnip: ${catnipInWorkspace}], [Ponder: ${ponderInWorkspace}]")
mixin {
add sourceSets.main, 'create.refmap.json'
config 'create.mixins.json'
}
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
if (Boolean.parseBoolean(project.use_parchment)) {
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
} else {
mappings channel: 'official', version: "${minecraft_version}"
}
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
copyIdeResources = true
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
}
runs {
// applies to all the run configs below
configureEach {
workingDirectory project.file('run')
if (inMultiModWorkspace)
ideaModule "createmod.Create.main"
else
ideaModule "Create.main"
property 'forge.logging.console.level', 'info'
jvmArgs '-XX:+IgnoreUnrecognizedVMOptions', '-XX:+AllowEnhancedClassRedefinition' // uncomment with jbr
//jvmArgs("-XX:-OmitStackTraceInFastThrow") // uncomment when you get exceptions with null messages etc
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
arg '-mixin.config=create.mixins.json'
arg '-mixin.config=catnip.mixins.json'
mods {
create {
source sourceSets.main
}
if (catnipInWorkspace) {
catnip {
source project(":catnip:Common").sourceSets.main
source project(":catnip:Forge").sourceSets.main
}
}
if (ponderInWorkspace) {
ponder {
source project(":Ponder:Common").sourceSets.main
source project(":Ponder:Forge").sourceSets.main
}
}
}
}
client {
arg '-mixin.config=flywheel.mixins.json'
mods {
if (flywheelInWorkspace) {
flywheel {
source project(":Flywheel").sourceSets.main
}
}
}
}
server {
workingDirectory project.file('run/server')
}
data {
property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
args '--mod', 'create', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
mods {
if (flywheelInWorkspace) {
flywheel {
source project(":Flywheel").sourceSets.main
}
}
}
}
gameTestServer {
workingDirectory project.file('run/gametest')
//setForceExit false
}
}
}
repositories {
maven {
// location of the maven for Registrate and Flywheel
name = 'tterrag maven'
url = 'https://maven.tterrag.com'
}
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/"
}
/*maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.dev"
}*/
maven {
// location of the maven for Dynamic Trees
url = 'https://harleyoconnor.com/maven'
}
maven {
// location of the maven for Curios API
url = "https://maven.theillusivec4.top/"
}
maven {
// location of maven for CC: Tweaked
name = "squiddev"
url = "https://squiddev.cc/maven/"
content {
includeGroup "org.squiddev"
}
}
maven {
url = 'https://www.cursemaven.com'
content {
includeGroup "curse.maven"
}
}
maven {
// Location of the maven for Ponder, Catnip
name 'createmod maven'
url 'https://maven.createmod.net'
}
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
mavenLocal()
flatDir {
dirs 'libs'
}
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
exclude '.cache/'
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
jarJar("com.tterrag.registrate:Registrate:${registrate_version}") {
jarJar.ranged(it, '[MC1.19-1.1.5,)')
}
jarJar("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") {
jarJar.ranged(it, '[0.6.9,0.6.10)')
}
implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}")
if (flywheelInWorkspace) {
implementation project(':Flywheel')
} else {
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}")
}
if (catnipInWorkspace) {
implementation project(":catnip:Common")
implementation project(":catnip:Forge")
} else {
implementation fg.deobf("net.createmod.catnip:Catnip-Forge-${minecraft_version}:${catnip_version}")
}
if (ponderInWorkspace) {
implementation project(":Ponder:Common")
implementation project(":Ponder:Forge")
} else {
implementation fg.deobf("net.createmod.ponder:Ponder-Forge-${minecraft_version}:${ponder_version}")
}
compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge:${jei_version}")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_minecraft_version}-${curios_version}:api")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_minecraft_version}-${curios_version}")
if (cc_tweaked_enable.toBoolean()) {
compileOnly fg.deobf("org.squiddev:cc-tweaked-${cc_tweaked_minecraft_version}:${cc_tweaked_version}:api")
runtimeOnly fg.deobf("org.squiddev:cc-tweaked-${cc_tweaked_minecraft_version}:${cc_tweaked_version}")
}
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
// implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta25")
// runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69")
// runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984")
// runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.5-1.6.115")
// runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.5-3.1.1.252")
// runtimeOnly fg.deobf("maven.modrinth:rubidium:0.5.3")
// implementation fg.deobf("com.railwayteam.railways:railways-1.18.2-1.1.1:all") { transitive = false }
// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
// This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly
if (!Boolean.getBoolean('idea.sync.active')) {
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
}
}
sourceSets.main.java {
if (!cc_tweaked_enable.toBoolean()) {
exclude 'com/simibubi/create/compat/computercraft/implementation/**'
}
}
// Workaround for SpongePowered/MixinGradle#38
afterEvaluate {
//tasks.configureReobfTaskForReobfJar.mustRunAfter(tasks.compileJava)
//tasks.configureReobfTaskForReobfJarJar.mustRunAfter(tasks.compileJava)
}
processResources {
def buildProps = project.properties.clone()
// Replaces FML's magic file.jarVersion string with the correct version at build time.
buildProps.put('file', [jarVersion: project.version])
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand buildProps
}
}
compileJava {
options.compilerArgs = ['-Xdiags:verbose']
}
void addLicense(jarTask) {
jarTask.from('LICENSE') {
rename { "${it}_${project.archivesBaseName}" }
}
}
tasks.jar {
archiveClassifier = 'slim'
finalizedBy('reobfJar')
addLicense it
}
tasks.jarJar {
finalizedBy('reobfJarJar')
addLicense it
}
task jarJarRelease {
group = 'jarjar'
doLast {
tasks.jarJar {
archiveClassifier = ''
}
}
finalizedBy tasks.jarJar
}
project.publishing {
publications {
mavenJava(MavenPublication) {
artifactId base.archivesName.get()
from components.java
fg.component(it)
jarJar.component(it)
}
}
repositories {
if (project.hasProperty('mavendir')) {
maven { url mavendir }
}
}
}
String getChangelogText() {
def changelogFile = file('changelog.txt')
String str = ''
int lineCount = 0
boolean done = false
changelogFile.eachLine {
if (done || it == null) {
return
}
if (it.size() > 1) {
def temp = it
if (lineCount == 0) {
temp = "Create ${version}"
temp = "Create v${mod_version} for Minecraft ${minecraft_version}
"
} else if (it.startsWith('-')) {
temp = " $temp
"
temp = temp.replaceAll("(\\S+\\/\\S+)#([0-9]+)\\b", "\$0");
temp = temp.replaceAll("#([0-9]+)\\b(?!<\\/a>)", "\$0");
} else {
temp = "
Please submit any Issues you come across on the Issue Tracker.
" done = true } } return str } // changelog debugging // new File("changelog.html").write getChangelogText() // tasks.curseforge.enabled = !dev && project.hasProperty('simi_curseforge_key') // curseforge { // if (project.hasProperty('simi_curseforge_key')) { // apiKey = project.simi_curseforge_key // } // // project { // id = project.projectId // changelog = System.getenv('CHANGELOG') == null || System.getenv('CHANGELOG').equals('none') ? getChangelogText() : System.getenv('CHANGELOG') // changelogType = 'html' // releaseType = project.curse_type // mainArtifact(shadowJar) { // displayName = "Create - ${version}" // } // relations { // optionalDependency 'jei' // } // } // }