From ef0d3b3957a2582dd635d9d2c11642c659014ab5 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 30 Aug 2022 22:02:39 -0500 Subject: [PATCH] Setup the API sub-project gradle dependencies --- build.gradle | 97 +++++++++++++++++++++++++++++++------------------ coreSubProjects | 2 +- settings.gradle | 6 ++- 3 files changed, 67 insertions(+), 38 deletions(-) diff --git a/build.gradle b/build.gradle index c8cb704a2..5f53fdbd9 100644 --- a/build.gradle +++ b/build.gradle @@ -140,20 +140,21 @@ architectury { } subprojects { p -> - if (p == project(":core")) { + + // setup Architectury + if (p == project(":core") || p == project(":api") || p == project(":apiInterface") || p == project(":coreShared")) + { apply plugin: "application" apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries apply plugin: "com.github.johnrengelman.shadow" - } else { + } + else + { apply plugin: "com.github.johnrengelman.shadow" - if (p != project(":api")) { // Don't add loom to the api project - apply plugin: "dev.architectury.loom" - - loom { - silentMojangMappingsLicense() - } - } else { - apply plugin: "java" // Apply the java plugin early to the api project + apply plugin: "dev.architectury.loom" + + loom { + silentMojangMappingsLicense() } } @@ -164,34 +165,27 @@ subprojects { p -> customModule implementation.extendsFrom customModule } - - if (p == project(":core")) { - // Sets up minecraft for core + + // Set up the minecraft non-dependency for core sub-projects + if (p == project(":core") || p == project(":api") || p == project(":apiInterface") || p == project(":coreShared")) + { minecraft { version("${rootProject.minecraft_version}") } - - // Sets the main standalone jar entrypoint + + // Set the standalone jar entrypoint + // (This will point to a non-existent class in all sub-projects except "Core") application { mainClass.set('com.seibel.lod.core.JarMain') } } dependencies { - // Sets up minecraft for projects other than core - if (p != project(":core") && p != project(":api")) { - 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") - parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") - else // As 1.19 dosnt have parchment mappings yet, we use 1.18.2 mapping - parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") - } - } + + //=====================// + // shared dependencies // + //=====================// + // Manifold annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" @@ -218,9 +212,30 @@ subprojects { p -> // SVG shadowMe "com.formdev:flatlaf-extras:${rootProject.flatlaf_version}" shadowMe "com.formdev:svgSalamander:${rootProject.svgSalamander_version}" + + + + //==========================// + // conditional dependencies // + //==========================// - // Add the core as a dependency - if (p != project(":core")) { + // Minecraft dependent sub-projects + if (p == project(":common") || p == project(":forge") || p == project(":fabric")) + { + // Add Minecraft + 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") + parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") + else // As 1.19 doesn't have parchment mappings yet, we use 1.18.2 mapping + parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") + } + + // Add core customModule(project(":core")) { // Remove Junit test libraries exclude group: "org.junit.jupiter", module: "junit-jupiter" @@ -228,16 +243,28 @@ subprojects { p -> exclude group: "junit", module: "junit" } } - - // Add the api as a dependency - if (p != project(":api") && p != project(":core")) { - customModule(project(":api")) { + + + // Add coreShared to sub-projects that need core objects + if (p == project(":core") || p == project(":apiInterface") || p == project(":api")) { + customModule(project(":coreShared")) { // Remove Junit test libraries exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" exclude group: "junit", module: "junit" } } + + // Add apiInterface to core and the API + if (p == project(":core") || p == project(":api")) { + customModule(project(":apiInterface")) { + // Remove Junit test libraries + exclude group: "org.junit.jupiter", module: "junit-jupiter" + exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" + exclude group: "junit", module: "junit" + } + } + } // Allows the jar to run standalone diff --git a/coreSubProjects b/coreSubProjects index 55463f237..2fdf2b9cf 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 55463f237700a6b48774f9b7a5582b8433fbac96 +Subproject commit 2fdf2b9cfc1be360c84fa4238fd439427278fbfb diff --git a/settings.gradle b/settings.gradle index 4d6d1b328..d6894ad46 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,17 +8,19 @@ pluginManagement { } } +// Minecraft dependent sub-projects include("common") include("fabric") include("forge") +// Minecraft independent sub-projects include("core") project(":core").projectDir = file('coreSubProjects/core') include("api") project(":api").projectDir = file('coreSubProjects/api') include("apiInterface") project(":apiInterface").projectDir = file('coreSubProjects/apiInterface') -include("coreApiCommon") -project(":coreApiCommon").projectDir = file('coreSubProjects/coreApiCommon') +include("coreShared") +project(":coreShared").projectDir = file('coreSubProjects/coreShared') rootProject.name = "DistantHorizons"