7dadff4219
By default the fabric build folder needs this file to run, but it wasn't being copied over, now it should be.
225 lines
6.9 KiB
Groovy
225 lines
6.9 KiB
Groovy
import io.github.ran.jarmerger.JarMergerPlugin
|
|
|
|
|
|
buildscript {
|
|
dependencies{
|
|
classpath files('plugins/DHJarMerger-1.0.jar')
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id "architectury-plugin" version "3.4-SNAPSHOT"
|
|
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false
|
|
}
|
|
|
|
def writeBuildGradlePredefine() {
|
|
def excapedMCVersion = rootProject.minecraft_version.replace(".", "_")
|
|
new File(projectDir, "build.properties").text = "MC_VERSION_${excapedMCVersion}=\n"
|
|
}
|
|
|
|
def loadProperties() {
|
|
def defaultMcVersion = '1.18.2'
|
|
if (!project.hasProperty("mcVer")) {
|
|
println "No mcVer set! Defaulting to ${defaultMcVersion}."
|
|
println "Tip: Use -PmcVer='${defaultMcVersion}' in cmd arg to set mcVer."
|
|
}
|
|
def mcVersion = project.hasProperty("mcVer") ? mcVer : defaultMcVersion
|
|
|
|
println "Loading properties file at " + mcVersion + ".properties"
|
|
def props = new Properties()
|
|
props.load(new FileInputStream("$rootProject.rootDir/"+"$mcVersion"+".properties"))
|
|
|
|
props.each { prop ->
|
|
rootProject.ext.set(prop.key, prop.value)
|
|
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
|
|
}
|
|
writeBuildGradlePredefine()
|
|
}
|
|
loadProperties()
|
|
|
|
apply plugin: JarMergerPlugin
|
|
|
|
architectury {
|
|
minecraft = rootProject.minecraft_version
|
|
}
|
|
|
|
subprojects { p ->
|
|
apply plugin: "dev.architectury.loom"
|
|
|
|
loom {
|
|
silentMojangMappingsLicense()
|
|
}
|
|
|
|
configurations {
|
|
common
|
|
shadowMe
|
|
implementation.extendsFrom shadowMe
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
|
// The following line declares the mojmap mappings
|
|
mappings loom.officialMojangMappings()
|
|
|
|
//Manifold
|
|
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
|
|
|
|
// Toml
|
|
implementation("com.electronwill.night-config:toml:${rootProject.toml_version}")
|
|
|
|
if (p != project(":forge")) {
|
|
// 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}"
|
|
}
|
|
|
|
if (p != project(":core")) {
|
|
common(project(":core")) { transitive false }
|
|
shadowMe(project(":core")) { transitive false }
|
|
}
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes 'Implementation-Title': rootProject.archives_base_name,
|
|
'Implementation-Version': rootProject.mod_version,
|
|
'Main-Class': 'com.seibel.lod.core.JarMain'
|
|
}
|
|
}
|
|
}
|
|
|
|
allprojects { p ->
|
|
apply plugin: "java"
|
|
apply plugin: "architectury-plugin"
|
|
apply plugin: "maven-publish"
|
|
|
|
archivesBaseName = rootProject.archives_base_name
|
|
version = rootProject.mod_version
|
|
group = rootProject.maven_group
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
// 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"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Put stuff from gradle.properties into the mod info
|
|
processResources {
|
|
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,
|
|
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,41)"
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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
|
|
if (p != project(":core")) {
|
|
options.compilerArgs += ['-Xplugin:Manifold']
|
|
options.release = rootProject.java_version as Integer
|
|
}
|
|
}
|
|
|
|
java {
|
|
withSourcesJar()
|
|
}
|
|
|
|
if (p == project(":core") || p == project(":common")) {
|
|
runClient.enabled = false
|
|
runServer.enabled = false
|
|
}
|
|
|
|
|
|
// this is necessary for running the fabric build
|
|
if (p == project(":common")) {
|
|
println "Coping [common/src/main/resources/lod.accesswidner] to [fabric/build/resources/main]."
|
|
|
|
copy {
|
|
from "$rootProject.rootDir/common/src/main/resources"
|
|
into "$rootProject.rootDir/fabric/build/resources/main"
|
|
include "*.accesswidener"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// this deletes the merged folder so we don't carry over
|
|
// the previous merges to each new build job in the CI/CD pipeline
|
|
task deleteMerged(type: Delete) {
|
|
delete files("./Merged")
|
|
} |