Best that I can do with the build system for now (forgegradle hates me for some reason)

This commit is contained in:
coolGi
2022-11-17 19:10:01 +10:30
parent 4fe24abc51
commit d538b5c12b
4 changed files with 85 additions and 46 deletions
+33 -20
View File
@@ -8,7 +8,7 @@ plugins {
id "io.github.pacifistmc.forgix" version "1.2.6"
// Manifold preprocessor
id 'systems.manifold.manifold-gradle-plugin' version '0.0.2-alpha'
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
// Provides mc libraries to core
// id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false
@@ -119,12 +119,22 @@ forgix {
subprojects { p ->
// Apply plugins
apply plugin: "java"
apply plugin: "systems.manifold.manifold-gradle-plugin"
apply plugin: "com.github.johnrengelman.shadow"
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
if (p == project(":core")) {
apply plugin: "application"
}
// Set the manifold version (may not be required tough)
manifold {
manifoldVersion = rootProject.manifold_version
}
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge")"
// Usefull later on so we dont have duplicated code
def isMinecraftSubProject = p != project(":core") && p != project(":api")
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
@@ -136,7 +146,7 @@ subprojects { p ->
customModule
implementation.extendsFrom(customModule)
if (p == project(":fabric") /* || p == project(":quilt") */ || p == project(":forge")) {
if (p != project(":api") && p != project(":core")) {
// Shadow common
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
@@ -147,7 +157,7 @@ subprojects { p ->
}
// Set the standalone jar entrypoint
// Let the application plugin know where the main class is
// (This will point to a non-existent class in all sub-projects except "Core")
if (p == project(":core")) {
application {
@@ -191,7 +201,7 @@ subprojects { p ->
//==========================//
// Add core
if (p != project(":api") && p != project(":core")) {
if (isMinecraftSubProject) {
implementation(project(":core")) {
// Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter"
@@ -221,22 +231,24 @@ subprojects { p ->
}
// this can be un-commented if we ever wanted to make DH modular (AKA use a module-info.java file) again
// // Tells gradle where to look for other modules
// // Why isn't the classpath added to the modules path by default?
// if (p == project(":core")) {
// compileJava {
// inputs.property('moduleName', 'dhApi')
// doFirst {
// options.compilerArgs = [
// '--module-path', classpath.asPath
// ]
// classpath = files()
// }
// }
// }
/*
// Tells gradle where to look for other modules
// Why isn't the classpath added to the modules path by default?
if (p == project(":core")) {
compileJava {
inputs.property('moduleName', 'dhApi')
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath
]
classpath = files()
}
}
}
*/
// Run mergeJars when running build
if (p != project(":api") && p != project(":core")) {
if (isMinecraftSubProject) {
build.finalizedBy(mergeJars)
assemble.finalizedBy(mergeJars)
}
@@ -385,13 +397,14 @@ allprojects { p ->
}
tasks.withType(JavaCompile) {
if (p != project(":core")) {
if (isMinecraftSubProject) {
options.release = rootProject.java_version as Integer
options.compilerArgs += ['-Xplugin:Manifold']
} else {
// options.release = 8; // Core should use Java 8 no matter what
// options.release = 8; // Core & Api should use Java 8 no matter what
// No it shouldn't cause it fails to find minecraft if it uses Java 8
options.release = rootProject.java_version as Integer
// TODO: Once the new build system is done, check if there is a way to make core/api only use java 8 again
}
options.encoding = "UTF-8"
}
+11 -9
View File
@@ -1,9 +1,10 @@
plugins {
id "fabric-loom" version "0.12-SNAPSHOT"
id "fabric-loom" version "1.0-SNAPSHOT"
}
loom {
accessWidenerPath = project(":common").file("src/main/resources/${rootProject.accessWidenerVersion}.lod.accesswidener")
// FIXME: AccessWidener
// accessWidenerPath = project(":common").file("src/main/resources/${rootProject.accessWidenerVersion}.lod.accesswidener")
runs {
client {
client()
@@ -49,11 +50,11 @@ dependencies {
implementation project(":common")
// Architectury API
if (minecraft_version == "1.16.5") {
addModJar("me.shedaniel:architectury-fabric:${rootProject.architectury_version}")
} else {
addModJar("dev.architectury:architectury-fabric:${rootProject.architectury_version}")
}
// if (minecraft_version == "1.16.5") {
// addModJar("me.shedaniel:architectury-fabric:${rootProject.architectury_version}")
// } else {
// addModJar("dev.architectury:architectury-fabric:${rootProject.architectury_version}")
// }
// Fabric API
addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
@@ -133,7 +134,8 @@ shadowJar {
}
remapJar {
injectAccessWidener = true
// FIXME: AccessWidener
// injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
@@ -174,7 +176,7 @@ components.java {
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
artifactId = rootProject.mod_name + "-" + project.name
from components.java
}
}
+33 -16
View File
@@ -1,16 +1,19 @@
buildscript {
repositories {
maven { url = "https://maven.minecraftforge.net" }
maven { url = 'https://maven.parchmentmc.org' }
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'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: "net.minecraftforge.gradle"
apply plugin: "org.parchmentmc.librarian.forgegradle"
apply plugin: "org.spongepowered.mixin"
mixin {
add sourceSets.main, "DistantHorizons.refmap.json"
@@ -19,13 +22,8 @@ mixin {
}
minecraft {
mappings channel: 'official', version: minecraft_version
// mappings loom.layered() {
// // Mojmap mappings
// officialMojangMappings()
// // Parchment mappings (it adds parameter mappings & javadoc)
// parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
// }
// mappings channel: 'official', version: minecraft_version // Vanilla mappings
mappings channel: "parchment", version: "${rootProject.parchment_version}-${rootProject.minecraft_version}" // Parchment mappings
runs {
client {
@@ -47,10 +45,25 @@ minecraft {
ideaModule "${rootProject.name}.${project.name}.main"
args '--mod', "lod", '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
taskName 'Data'
args "-mixins.config=DistantHorizons.mixins.json"
args "-mixins.config=DistantHorizons.mixins.json" // To add more mixins, you can just add a comma for another arg
// These may be needed altough im not sure
// mods {
// modDataRun {
// source sourceSets.main
// source project(":common").sourceSets.main
// }
// }
}
}
}
// TODO: Check if the next 7 lines are necessary
sourceSets.main.resources.srcDir "src/generated/resources"
minecraft.runs.all {
lazyToken('minecraft_classpath') {
configurations.library.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
configurations.runtimeLibrary.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
}
}
//loom {
// forge {
@@ -83,11 +96,11 @@ dependencies {
minecraft "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
// Architectury API
if (minecraft_version == "1.16.5") {
implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
} else {
implementation("dev.architectury:architectury-forge:${rootProject.architectury_version}")
}
// if (minecraft_version == "1.16.5") {
// implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
// } else {
// implementation("dev.architectury:architectury-forge:${rootProject.architectury_version}")
// }
// Starlight
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
@@ -95,6 +108,10 @@ dependencies {
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
if (System.getProperty('idea.sync.active') != 'true') {
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
}
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
}
@@ -151,7 +168,7 @@ components.java {
publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
artifactId = rootProject.mod_name + "-" + project.name
from components.java
}
}
+8 -1
View File
@@ -1,6 +1,6 @@
modLoader="javafml" #//mandatory
loaderVersion="[36,42)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="*" # // mandatory. Allow all forge versions as we are definding what Minecraft versions we requre later on
license="LGPL"
issueTrackerURL="${issues}"
@@ -24,3 +24,10 @@ issueTrackerURL="${issues}"
#// Allow any version to be present (or not) on the server
acceptableRemoteVersions="*"
# TODO: Add this for versioning in the build script
#[[dependencies.lod]]
# modId="minecraft"
# mandatory=true
# versionRange="[1.18.2,)"
# ordering="NONE"
# side="BOTH"