352 lines
12 KiB
Groovy
352 lines
12 KiB
Groovy
plugins {
|
|
id "com.github.johnrengelman.shadow" version "7.1.0"
|
|
}
|
|
|
|
// From parent
|
|
apply plugin: "java"
|
|
apply plugin: "architectury-plugin"
|
|
apply plugin: "maven-publish"
|
|
apply plugin: "dev.architectury.loom"
|
|
|
|
archivesBaseName = rootProject.archives_base_name
|
|
version = rootProject.mod_version //FIXME: Redef
|
|
group = rootProject.maven_group
|
|
|
|
version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm")
|
|
|
|
loom {
|
|
silentMojangMappingsLicense()
|
|
accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener"))
|
|
}
|
|
|
|
|
|
architectury {
|
|
platformSetupLoomIde()
|
|
fabric()
|
|
}
|
|
|
|
configurations {
|
|
common
|
|
shadowMe
|
|
implementation.extendsFrom shadowMe
|
|
|
|
compileClasspath.extendsFrom common
|
|
runtimeClasspath.extendsFrom common
|
|
developmentFabric.extendsFrom common
|
|
|
|
addModJar
|
|
include.extendsFrom addModJar
|
|
modImplementation.extendsFrom addModJar
|
|
}
|
|
|
|
java {
|
|
withSourcesJar()
|
|
}
|
|
|
|
jar.dependsOn(project(":core").remapJar)
|
|
remapSourcesJar.dependsOn(project(":core").remapJar)
|
|
|
|
repositories {
|
|
// Required for ModMenu
|
|
maven { url "https://maven.terraformersmc.com/" }
|
|
|
|
mavenCentral()
|
|
|
|
// For parchment mappings
|
|
maven { url "https://maven.parchmentmc.org" }
|
|
|
|
// used to download and compile dependencies from git repos
|
|
maven { url 'https://jitpack.io' }
|
|
|
|
// For Manifold Preprocessor
|
|
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
|
|
|
// Required for importing Modrinth mods
|
|
maven {
|
|
name = "Modrinth"
|
|
url = "https://api.modrinth.com/maven"
|
|
content {
|
|
includeGroup "maven.modrinth"
|
|
}
|
|
}
|
|
|
|
// Required for importing CursedForge mods
|
|
maven {
|
|
url "https://www.cursemaven.com"
|
|
content {
|
|
includeGroup "curse.maven"
|
|
}
|
|
}
|
|
|
|
// These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource
|
|
flatDir {
|
|
dirs "${rootDir}/mods/fabric"
|
|
content {
|
|
includeGroup "fabric-mod"
|
|
}
|
|
}
|
|
flatDir {
|
|
dirs "${rootDir}/mods/forge"
|
|
content {
|
|
includeGroup "forge-mod"
|
|
}
|
|
}
|
|
}
|
|
|
|
def addMod(path, enabled) {
|
|
if (enabled == "2")
|
|
dependencies { modImplementation(path) }
|
|
else if (enabled == "1")
|
|
dependencies { modCompileOnly(path) }
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
|
// The following line declares the mojmap mappings & parchment mappings
|
|
mappings loom.layered() {
|
|
// Mojmap mappings
|
|
officialMojangMappings()
|
|
// Parchment mappings (it adds parameter mappings & javadoc)
|
|
if (
|
|
rootProject.minecraft_version != "1.19"
|
|
&& rootProject.minecraft_version != "1.19.1"
|
|
&& rootProject.minecraft_version != "1.19.2"
|
|
&& rootProject.minecraft_version != "1.19.3"
|
|
&& rootProject.minecraft_version != "1.19.4"
|
|
) // We are not gonna use this build script anymore so dont bother fixing this
|
|
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
|
|
else
|
|
parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19.x or higher doesnt have parchment mappings yet, we use 1.18.2 mapping
|
|
// Note: parchment may have later mappings at the time you are reading this, but at the time this was written, it didnt
|
|
// Check the main branch for the new build system, with the working mappings
|
|
}
|
|
|
|
//Manifold
|
|
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
|
|
|
// Toml
|
|
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
|
|
|
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
|
// Do NOT use other classes from fabric loader unless working with fabric
|
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
|
|
|
common(project(":core"))
|
|
|
|
// Fabric loader
|
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
|
|
|
// Fabric API
|
|
addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
|
|
addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version))
|
|
addModJar(fabricApi.module("fabric-key-binding-api-v1", rootProject.fabric_api_version))
|
|
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
|
|
addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version))
|
|
|
|
// Mod Menu
|
|
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
|
|
|
|
// Starlight
|
|
addMod("curse.maven:starlight-521783:${rootProject.starlight_version_fabric}", rootProject.enable_starlight)
|
|
|
|
// Phosphor
|
|
addMod("curse.maven:phosphor-372124:${rootProject.phosphor_version_fabric}", rootProject.enable_phosphor)
|
|
|
|
// Sodium
|
|
addMod("curse.maven:sodium-394468:${rootProject.sodium_version}", rootProject.enable_sodium)
|
|
implementation "org.joml:joml:1.10.2"
|
|
modImplementation(fabricApi.module("fabric-rendering-data-attachment-v1", rootProject.fabric_api_version))
|
|
modImplementation(fabricApi.module("fabric-rendering-fluids-v1", rootProject.fabric_api_version))
|
|
|
|
// Lithium
|
|
addMod("maven.modrinth:lithium:${rootProject.lithium_version}", rootProject.enable_lithium)
|
|
|
|
// Iris
|
|
addMod("maven.modrinth:iris:${rootProject.iris_version}", rootProject.enable_iris)
|
|
|
|
// BCLib
|
|
addMod("com.github.paulevsGitch:BCLib:${rootProject.bclib_version}", rootProject.enable_bclib)
|
|
|
|
// Immersive Portals
|
|
/*
|
|
modImplementation("com.github.qouteall.ImmersivePortalsMod:build:${rootProject.immersive_portals_version}") {
|
|
exclude(group: "net.fabricmc.fabric-api")
|
|
transitive(false)
|
|
}
|
|
modImplementation("com.github.qouteall.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version}") {
|
|
exclude(group: "net.fabricmc.fabric-api")
|
|
transitive(false)
|
|
}
|
|
modImplementation("com.github.qouteall.ImmersivePortalsMod:q_misc_util:${rootProject.immersive_portals_version}") {
|
|
exclude(group: "net.fabricmc.fabric-api")
|
|
transitive(false)
|
|
}
|
|
*/
|
|
|
|
// Toml
|
|
shadowMe("com.electronwill.night-config:toml:${rootProject.toml_version}") {}
|
|
|
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
|
shadowMe(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
|
shadowMe files(project(":core").file("build/libs/DistantHorizons-${rootProject.mod_version}.jar"))
|
|
|
|
// Compression
|
|
common 'org.tukaani:xz:1.9'
|
|
common 'org.apache.commons:commons-compress:1.21'
|
|
shadowMe 'org.tukaani:xz:1.9'
|
|
shadowMe 'org.apache.commons:commons-compress:1.21'
|
|
}
|
|
|
|
task deleteResources(type: Delete) {
|
|
delete file("build/resources/main")
|
|
}
|
|
// Copies the correct accesswidener and renames it
|
|
task copyAccessWidener(type: Copy) {
|
|
from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener")
|
|
into(file("build/resources/main"))
|
|
rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
|
|
}
|
|
|
|
task copyCoreResources(type: Copy) {
|
|
from fileTree(project(":core").file("src/main/resources"))
|
|
into file("build/resources/main")
|
|
}
|
|
|
|
task copyCommonResources(type: Copy) {
|
|
from fileTree(project(":common").file("src/main/resources"))
|
|
into file("build/resources/main")
|
|
}
|
|
|
|
processResources {
|
|
dependsOn(copyCoreResources)
|
|
dependsOn(copyCommonResources)
|
|
dependsOn(copyAccessWidener)
|
|
|
|
def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put
|
|
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
|
|
def replaceProperties = [
|
|
version : mod_version,
|
|
mod_name : mod_name,
|
|
authors : mod_authors,
|
|
description : mod_description,
|
|
homepage : mod_homepage,
|
|
source : mod_source,
|
|
issues : mod_issues,
|
|
minecraft_version : minecraft_version,
|
|
compatible_minecraft_versions: compatible_minecraft_versions,
|
|
java_version : java_version
|
|
]
|
|
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
|
|
//TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)"
|
|
|
|
inputs.properties replaceProperties
|
|
replaceProperties.put 'project', project
|
|
filesMatching(resourceTargets) {
|
|
expand replaceProperties
|
|
}
|
|
|
|
intoTargets.each { target ->
|
|
if (file(target).exists()) {
|
|
copy {
|
|
from(sourceSets.main.resources) {
|
|
include resourceTargets
|
|
expand replaceProperties
|
|
}
|
|
into target
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
runClient {
|
|
dependsOn(copyCoreResources)
|
|
dependsOn(copyCommonResources)
|
|
dependsOn(copyAccessWidener)
|
|
jvmArgs "-XX:-OmitStackTraceInFastThrow"
|
|
finalizedBy(deleteResources)
|
|
}
|
|
|
|
shadowJar {
|
|
configurations = [project.configurations.shadowMe]
|
|
relocate 'org.tukaani', 'shaded.tukaani'
|
|
relocate 'org.apache.commons.compress', 'shaded.apache.commons.compress'
|
|
relocate 'com.electronwill.nightconfig', 'shaded.electronwill.nightconfig'
|
|
|
|
relocate 'com.seibel.lod.common', 'fabric.com.seibel.lod.common'
|
|
|
|
classifier "dev-shadow"
|
|
}
|
|
|
|
remapJar {
|
|
input.set shadowJar.archiveFile
|
|
dependsOn shadowJar
|
|
classifier null
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes 'Implementation-Title': rootProject.archives_base_name,
|
|
'Implementation-Version': rootProject.mod_version,
|
|
'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line
|
|
}
|
|
classifier "dev"
|
|
}
|
|
|
|
sourcesJar {
|
|
def commonSources = project(":common").sourcesJar
|
|
dependsOn commonSources
|
|
from commonSources.archiveFile.map { zipTree(it) }
|
|
}
|
|
|
|
components.java {
|
|
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
|
skip()
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenFabric(MavenPublication) {
|
|
artifactId = rootProject.archives_base_name + "-" + project.name
|
|
from components.java
|
|
}
|
|
}
|
|
|
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
|
repositories {
|
|
// Add repositories to publish to here.
|
|
}
|
|
}
|
|
|
|
task printConfigurations {
|
|
doLast {task ->
|
|
println "Project Name: $name configurations:"
|
|
configurations.each {
|
|
println " $it.name"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
// Add Manifold Preprocessor
|
|
// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
|
// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"]
|
|
//
|
|
//options.compilerArgs += ['-deprecation']
|
|
//options.compilerArgs += ['-verbose']
|
|
//options.compilerArgs += ['-Xlint:unchecked']
|
|
//options.compilerArgs += ['-Xdiags:verbose']
|
|
//options.compilerArgs += ['-Xprint']
|
|
//options.compilerArgs += ['-XprintProcessorInfo']
|
|
//options.compilerArgs += ['-XprintRounds']
|
|
|
|
// println options.compilerArgs
|
|
|
|
// Set the java version
|
|
options.compilerArgs += ['-Xplugin:Manifold']
|
|
options.release = rootProject.java_version as Integer
|
|
// TODO: make everything use java 8
|
|
// options.release = 8 // Use Java 8 for everything so back porting is easier
|
|
}
|