Skip to content

Commit

Permalink
split dependencies into their own jar
Browse files Browse the repository at this point in the history
  • Loading branch information
nextdayy committed Jun 3, 2024
1 parent abcc71f commit 8ef1845
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 102 deletions.
32 changes: 0 additions & 32 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=OneConfig
mod_id=oneconfig
version_major=1
version_minor=0
version_patch=0-alpha5
version_patch=0-alpha6

polyfrost.defaults.loom=2

Expand Down
32 changes: 32 additions & 0 deletions modules/dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

val shade by configurations.creating {
configurations.api.get().extendsFrom(this)
}

allprojects {
base.archivesName = "deps"
tasks.jar.get().enabled = false
tasks.javadocJar.get().enabled = false
tasks.sourcesJar.get().enabled = false
}

dependencies {
shade(libs.polyui)

shade(libs.bundles.kotlin)
shade(libs.bundles.kotlinx)

shade(libs.hypixel.modapi)

shade(libs.bundles.nightconfig)
}

tasks {
create("deps", ShadowJar::class.java) {
configurations = listOf(shade)
}
build {
dependsOn("deps")
}
}
27 changes: 27 additions & 0 deletions modules/dependencies/bundled/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

val shade by configurations.creating {
configurations.api.get().extendsFrom(this)
}

base.archivesName = "oneconfig-api"

dependencies {
for (project in rootProject.project(":modules").subprojects) {
if("dependencies" !in project.path) {
shade(project(project.path)) {
isTransitive = false
}
}
}
}

tasks {
create("bundle", ShadowJar::class.java) {
configurations = listOf(shade)
}

build {
dependsOn("bundle")
}
}
32 changes: 32 additions & 0 deletions modules/dependencies/legacy/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

val shade by configurations.creating {
configurations.api.get().extendsFrom(this)
}

val natives = listOf("windows", "windows-arm64", "linux", "macos", "macos-arm64")

dependencies {
val lwjglVersion = libs.versions.lwjgl.get()
for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) {
val lwjglDep = "org.lwjgl:lwjgl$dep:$lwjglVersion"
shade(lwjglDep) {
isTransitive = false
}
for (native in natives) {
shade("$lwjglDep:natives-$native") {
isTransitive = false
}
}
}
}

tasks {
create("deps", ShadowJar::class.java) {
archiveClassifier = "legacy"
configurations = listOf(shade)
}
build {
dependsOn("deps")
}
}
30 changes: 30 additions & 0 deletions modules/dependencies/modern/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

val shade by configurations.creating {
configurations.api.get().extendsFrom(this)
}

val natives = listOf("windows", "windows-arm64", "linux", "macos", "macos-arm64")

dependencies {
shade(libs.lwjgl.nvg) {
isTransitive = false
}
val nvg = libs.lwjgl.nvg.get()
val nvgDep = "${nvg.module}:${nvg.version}:natives-"
for (native in natives) {
shade("$nvgDep$native") {
isTransitive = false
}
}
}

tasks {
create("deps", ShadowJar::class.java) {
archiveClassifier = "modern"
configurations = listOf(shade)
}
build {
dependsOn("deps")
}
}
4 changes: 4 additions & 0 deletions modules/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ apiValidation {
}
ignoredPackages.add("org.polyfrost.oneconfig.api.hypixel.v0.internal")
ignoredProjects.add("internal")
ignoredProjects.add("dependencies")
ignoredProjects.add("legacy")
ignoredProjects.add("modern")
ignoredProjects.add("bundled")
}
8 changes: 4 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ pluginManagement {
}
}

dependencyResolutionManagement {
pluginManagement.repositories.forEach { repositories.add(it) }
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}
Expand Down Expand Up @@ -41,6 +37,10 @@ listOf(
"events",
"ui",
"internal",
"dependencies",
"dependencies:legacy",
"dependencies:modern",
"dependencies:bundled",
"utils"
).forEach { module ->
include(":modules:$module")
Expand Down
72 changes: 7 additions & 65 deletions versions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import net.fabricmc.loom.task.RemapSourcesJarTask
import org.polyfrost.gradle.util.noServerRunConfigs
import org.polyfrost.gradle.util.prebundle
import java.text.SimpleDateFormat

plugins {
Expand All @@ -22,7 +21,6 @@ val modId = properties["mod_id"] as String
version = rootProject.version
group = rootProject.group

val natives = listOf("windows", "windows-arm64", "linux", "macos", "macos-arm64")
val tweakClass = "org.polyfrost.oneconfig.internal.legacy.OneConfigTweaker"

base {
Expand Down Expand Up @@ -59,10 +57,6 @@ repositories {
maven("https://repo.hypixel.net/repository/Hypixel")
}

val shade: Configuration by configurations.creating {
configurations.api.get().extendsFrom(this)
}

val shadeMod: Configuration by configurations.creating {
configurations.modApi.get().extendsFrom(this)
}
Expand All @@ -74,71 +68,23 @@ dependencies {

shadeMod("org.polyfrost:universalcraft-$platform:${libs.versions.universalcraft.get()}")

shade(libs.polyui)
if (platform.isLegacyForge || platform.isFabric) {
shade(libs.bundles.nightconfig)
if (platform.isLegacyForge || platform.isLegacyFabric) {
implementation(project(":modules:dependencies:legacy"))
} else {
// modern forge includes nightconfig-core and nightconfig-toml
// so, we can just include the ones we need
shade(libs.nightconfig.json) {
isTransitive = false
}
shade(libs.nightconfig.yaml) {
isTransitive = false
}
}

// for other mods and universalcraft
shade(libs.bundles.kotlin)
shade(libs.bundles.kotlinx)

shade(libs.hypixel.modapi)

for (project in rootProject.project(":modules").subprojects) {
// TODO: ModLauncher (forge-1.17+) fails due to module export issues
shade(project(project.path)) {
isTransitive = false
}
implementation(project(":modules:dependencies:modern"))
}
implementation(project(":modules:dependencies"))
implementation(project(":modules:dependencies:bundled"))

if (platform.isLegacyForge) {
shade(libs.mixin) {
implementation(libs.mixin) {
isTransitive = false
}
compileOnly("cc.polyfrost:oneconfig-${platform}:0.2.2-alpha195") {
isTransitive = false
}
}


val isLegacy = platform.isLegacyForge || platform.isLegacyFabric
val lwjglVersion = libs.versions.lwjgl.get()
if (isLegacy) {
val cfg = configurations.create("lwjglBundleForLegacy")
for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) {
val lwjglDep = "org.lwjgl:lwjgl$dep:$lwjglVersion"
compileOnly(cfg(lwjglDep) {
isTransitive = false
})
for (native in natives) {
runtimeOnly(cfg("$lwjglDep:natives-$native") {
isTransitive = false
})
}
}
shade(prebundle(cfg, "lwjgl-legacy.jar"))
} else {
val nvgDep = "org.lwjgl:lwjgl-nanovg:$lwjglVersion"
shade(nvgDep) {
isTransitive = false
}
for (native in natives) {
shade("$nvgDep:natives-$native") {
isTransitive = false
}
}
}

if (!platform.isLegacyFabric) {
modRuntimeOnly(
"me.djtheredstoner:DevAuth-" +
Expand Down Expand Up @@ -208,12 +154,8 @@ tasks {
}
}

jar {
exclude("**/internal/**")
}

shadowJar {
configurations = listOf(shade, shadeMod)
configurations = listOf(shadeMod)
dependsOn(jar)
}

Expand Down

0 comments on commit 8ef1845

Please sign in to comment.