From f39ae98a4833c1714608f37c2586b6c897c41e4b Mon Sep 17 00:00:00 2001 From: Ran <43445785+RanCraftPlayz@users.noreply.github.com> Date: Thu, 25 Aug 2022 17:50:10 +0600 Subject: [PATCH] Add API module --- api/build.gradle | 38 ++++++++++++++++++++++++++++++++++++++ build.gradle | 38 ++++++++++++++++++++++++++++++-------- fabric/build.gradle | 2 +- forge/build.gradle | 2 +- settings.gradle | 1 + 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 api/build.gradle diff --git a/api/build.gradle b/api/build.gradle new file mode 100644 index 000000000..d01b7b924 --- /dev/null +++ b/api/build.gradle @@ -0,0 +1,38 @@ +version = "API-" + rootProject.versionStr + +configurations { + +} + +dependencies { + +} + +shadowJar { + exclude "architectury.common.json" + configurations = [project.configurations.shadowMe] + + // Compression + relocate 'org.tukaani', 'distanthorizons.libraries.tukaani' + relocate 'org.apache.commons.compress', 'distanthorizons.libraries.apache.commons.compress' + + // Toml & Json for config + relocate 'com.electronwill.nightconfig', 'distanthorizons.libraries.electronwill.nightconfig' + + // FIXME: This is a massive library that is located in lots of different spots + relocate 'com.googlecode.json-simple', 'distanthorizons.libraries.googlecode.json-simple' + relocate 'org.json.simple', 'distanthorizons.libraries.json.simple' + + // Theming + relocate 'com.formdev.flatlaf', 'distanthorizons.libraries.formdev.flatlaf' + + // SVG + relocate 'com.kitfox.svg', 'distanthorizons.libraries.kitfox.svg' + + classifier null + mergeServiceFiles() +} + +// Using jar.finalizedBy(shadowJar) causes issues so we do this scuffed bypass +jar.dependsOn(shadowJar) +jar.enabled(false) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7770de3c3..c8cb704a2 100644 --- a/build.gradle +++ b/build.gradle @@ -130,6 +130,9 @@ forgix { fabric { jarLocation = "build/libs/DistantHorizons-${rootProject.versionStr}.jar" } + + removeDuplicate "com.seibel.lod.core" + removeDuplicate "com.seibel.lod.api" } architectury { @@ -142,17 +145,24 @@ subprojects { p -> apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries apply plugin: "com.github.johnrengelman.shadow" } else { - apply plugin: "dev.architectury.loom" 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() + loom { + silentMojangMappingsLicense() + } + } else { + apply plugin: "java" // Apply the java plugin early to the api project } } configurations { shadowMe implementation.extendsFrom shadowMe + + customModule + implementation.extendsFrom customModule } if (p == project(":core")) { @@ -169,7 +179,7 @@ subprojects { p -> dependencies { // Sets up minecraft for projects other than core - if (p != project(":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() { @@ -209,9 +219,19 @@ subprojects { p -> shadowMe "com.formdev:flatlaf-extras:${rootProject.flatlaf_version}" shadowMe "com.formdev:svgSalamander:${rootProject.svgSalamander_version}" - // Add the core project as a dependency + // Add the core as a dependency if (p != project(":core")) { - shadowMe(project(":core")) { + customModule(project(":core")) { + // 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 the api as a dependency + if (p != project(":api") && p != project(":core")) { + customModule(project(":api")) { // Remove Junit test libraries exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" @@ -245,8 +265,10 @@ subprojects { p -> // } // Run mergeJars when running build - build.finalizedBy(mergeJars) - assemble.finalizedBy(mergeJars) + if (p != project(":api") && p != project(":api")) { + build.finalizedBy(mergeJars) + assemble.finalizedBy(mergeJars) + } } allprojects { p -> diff --git a/fabric/build.gradle b/fabric/build.gradle index c351e3019..55fa911ce 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -96,7 +96,7 @@ dependencies { shadowJar { exclude "architectury.common.json" - configurations = [project.configurations.shadowCommon, project.configurations.shadowMe] + configurations = [project.configurations.shadowCommon, project.configurations.shadowMe, project.configurations.customModule] // Compression relocate 'org.tukaani', 'distanthorizons.libraries.tukaani' diff --git a/forge/build.gradle b/forge/build.gradle index 4c6169b67..ef29edc40 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -66,7 +66,7 @@ processResources { shadowJar { exclude "architectury.common.json" - configurations = [project.configurations.shadowCommon, project.configurations.shadowMe] + configurations = [project.configurations.shadowCommon, project.configurations.shadowMe, project.configurations.customModule] // Compression relocate 'org.tukaani', 'distanthorizons.libraries.tukaani' diff --git a/settings.gradle b/settings.gradle index b5e3fa5a3..785ff685f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,5 +12,6 @@ include("common") include("fabric") include("forge") include("core") +include("api") rootProject.name = "DistantHorizons"