Setup the API sub-project gradle dependencies

This commit is contained in:
James Seibel
2022-08-30 22:02:39 -05:00
parent f34be62af4
commit ef0d3b3957
3 changed files with 67 additions and 38 deletions
+62 -35
View File
@@ -140,20 +140,21 @@ architectury {
} }
subprojects { p -> 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: "application"
apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
apply plugin: "com.github.johnrengelman.shadow" apply plugin: "com.github.johnrengelman.shadow"
} else { }
else
{
apply plugin: "com.github.johnrengelman.shadow" apply plugin: "com.github.johnrengelman.shadow"
if (p != project(":api")) { // Don't add loom to the api project apply plugin: "dev.architectury.loom"
apply plugin: "dev.architectury.loom"
loom {
loom { silentMojangMappingsLicense()
silentMojangMappingsLicense()
}
} else {
apply plugin: "java" // Apply the java plugin early to the api project
} }
} }
@@ -164,34 +165,27 @@ subprojects { p ->
customModule customModule
implementation.extendsFrom customModule implementation.extendsFrom customModule
} }
if (p == project(":core")) { // Set up the minecraft non-dependency for core sub-projects
// Sets up minecraft for core if (p == project(":core") || p == project(":api") || p == project(":apiInterface") || p == project(":coreShared"))
{
minecraft { minecraft {
version("${rootProject.minecraft_version}") 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 { application {
mainClass.set('com.seibel.lod.core.JarMain') mainClass.set('com.seibel.lod.core.JarMain')
} }
} }
dependencies { dependencies {
// Sets up minecraft for projects other than core
if (p != project(":core") && p != project(":api")) { //=====================//
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" // shared dependencies //
// 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")
}
}
// Manifold // Manifold
annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}"
@@ -218,9 +212,30 @@ subprojects { p ->
// SVG // SVG
shadowMe "com.formdev:flatlaf-extras:${rootProject.flatlaf_version}" shadowMe "com.formdev:flatlaf-extras:${rootProject.flatlaf_version}"
shadowMe "com.formdev:svgSalamander:${rootProject.svgSalamander_version}" shadowMe "com.formdev:svgSalamander:${rootProject.svgSalamander_version}"
//==========================//
// conditional dependencies //
//==========================//
// Add the core as a dependency // Minecraft dependent sub-projects
if (p != project(":core")) { 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")) { customModule(project(":core")) {
// Remove Junit test libraries // Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter"
@@ -228,16 +243,28 @@ subprojects { p ->
exclude group: "junit", module: "junit" exclude group: "junit", module: "junit"
} }
} }
// Add the api as a dependency
if (p != project(":api") && p != project(":core")) { // Add coreShared to sub-projects that need core objects
customModule(project(":api")) { if (p == project(":core") || p == project(":apiInterface") || p == project(":api")) {
customModule(project(":coreShared")) {
// Remove Junit test libraries // Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter"
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
exclude group: "junit", module: "junit" 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 // Allows the jar to run standalone
+4 -2
View File
@@ -8,17 +8,19 @@ pluginManagement {
} }
} }
// Minecraft dependent sub-projects
include("common") include("common")
include("fabric") include("fabric")
include("forge") include("forge")
// Minecraft independent sub-projects
include("core") include("core")
project(":core").projectDir = file('coreSubProjects/core') project(":core").projectDir = file('coreSubProjects/core')
include("api") include("api")
project(":api").projectDir = file('coreSubProjects/api') project(":api").projectDir = file('coreSubProjects/api')
include("apiInterface") include("apiInterface")
project(":apiInterface").projectDir = file('coreSubProjects/apiInterface') project(":apiInterface").projectDir = file('coreSubProjects/apiInterface')
include("coreApiCommon") include("coreShared")
project(":coreApiCommon").projectDir = file('coreSubProjects/coreApiCommon') project(":coreShared").projectDir = file('coreSubProjects/coreShared')
rootProject.name = "DistantHorizons" rootProject.name = "DistantHorizons"