From 996a37d100dde100ae977ff3d73ff476ce193bea Mon Sep 17 00:00:00 2001 From: tunikakeks <54219265+tunikakeks@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:32:38 +0100 Subject: [PATCH 1/2] Refactor build.gradle.kts for publishing configuration Removed Java plugin configuration and updated publication details. --- build.gradle.kts | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8b8546e..22cce89 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - java `maven-publish` } @@ -12,19 +11,34 @@ allprojects { } } -java { - withSourcesJar() - withJavadocJar() -} - publishing { publications { create("maven") { - from(components["java"]) + // publish the module that actually contains the Java classes + from(project(":libdeflate-java-core").components["java"]) groupId = "org.powernukkitx" artifactId = "libdeflate-java" - version = "0.0.3.PNX-SNAPSHOT" + version = project.version.toString() + + pom { + name.set("libdeflate-java") + description.set("Java bindings for libdeflate used by PowerNukkitX") + url.set("https://github.com/PowerNukkitX/libdeflate-java") + + licenses { + license { + name.set("MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + scm { + connection.set("scm:git:git://github.com/PowerNukkitX/libdeflate-java.git") + developerConnection.set("scm:git:ssh://github.com/PowerNukkitX/libdeflate-java.git") + url.set("https://github.com/PowerNukkitX/libdeflate-java") + } + } } } @@ -37,6 +51,7 @@ publishing { username = providers.gradleProperty("pnxUsername") .orElse(providers.environmentVariable("PNX_REPO_USERNAME")) .orNull + password = providers.gradleProperty("pnxPassword") .orElse(providers.environmentVariable("PNX_REPO_PASSWORD")) .orNull From 7342f03a6fcc9356f6529f353212453c6f9bf431 Mon Sep 17 00:00:00 2001 From: tunikakeks <54219265+tunikakeks@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:33:44 +0100 Subject: [PATCH 2/2] Update build.gradle.kts for project configuration --- libdeflate-java-core/build.gradle.kts | 50 ++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/libdeflate-java-core/build.gradle.kts b/libdeflate-java-core/build.gradle.kts index 0d1a930..f127881 100644 --- a/libdeflate-java-core/build.gradle.kts +++ b/libdeflate-java-core/build.gradle.kts @@ -7,16 +7,21 @@ plugins { `java-library` } +group = "org.powernukkitx" version = "0.0.3-PNX" +java { + withSourcesJar() + withJavadocJar() +} + dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.7.0\"") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.7.0") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") } -task("compileNatives") { - // Note: we should prefer compilation with GCC +tasks.register("compileNatives") { val jniTempPath = Paths.get(project.rootDir.toString(), "tmp") doLast { @@ -25,7 +30,6 @@ task("compileNatives") { when { Os.isFamily(Os.FAMILY_MAC) -> { - // macOS is just a Unix like the rest. if (System.getenv("CC") == null) { env["CC"] = "clang" } @@ -45,16 +49,18 @@ task("compileNatives") { exec { executable = "make" - args = arrayListOf("clean", "all") - environment = env.toMap() + args = listOf("clean", "all") + environment = env } } + Os.isFamily(Os.FAMILY_UNIX) -> { - // Cover most Unices. It's 2020, so hopefully you're compiling on a modern open-source BSD or Linux distribution... if (System.getenv("CC") == null) { env["CC"] = "gcc" } - val osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) + + val osName = System.getProperty("os.name").lowercase(Locale.ENGLISH) + env["DYLIB_SUFFIX"] = "so" env["JNI_PLATFORM"] = osName env["LIB_DIR"] = Paths.get(jniTempPath.toString(), "compiled", osName, System.getProperty("os.arch")).toString() @@ -63,26 +69,22 @@ task("compileNatives") { exec { executable = "make" - args = arrayListOf("clean", "all") - environment = env.toMap() + args = listOf("clean", "all") + environment = env } } + Os.isFamily(Os.FAMILY_WINDOWS) -> { if (System.getenv("MSVC") != null) { - // Windows is a very, very special case... we compile with Microsoft Visual Studio, which is a mess. - // There is the `vswhere` utility, which brings a tiny bit of sanity, but alas... it is probably better - // to invoke the build from a batch script. - // - // We'll need `vswhere` (you can install it via Chocolatey). exec { executable = "cmd" - args = arrayListOf("/C", "windows_build.bat") + args = listOf("/C", "windows_build.bat") } } else { - // Attempt to build using an MSYS2 environment. if (System.getenv("CC") == null) { env["CC"] = "gcc" } + env["DYLIB_SUFFIX"] = "dll" env["JNI_PLATFORM"] = "win32" env["LIB_DIR"] = Paths.get(jniTempPath.toString(), "compiled", "windows", System.getProperty("os.arch")).toString() @@ -91,12 +93,12 @@ task("compileNatives") { exec { executable = "make" - args = arrayListOf("clean", "all") - environment = env.toMap() + args = listOf("clean", "all") + environment = env } } - } + else -> { throw RuntimeException("Your OS isn't supported. We'll take a PR!") } @@ -113,14 +115,14 @@ sourceSets { } tasks.named("processResources") { - dependsOn(tasks.get("compileNatives")) + dependsOn("compileNatives") } tasks.named("test") { - dependsOn(tasks.get("compileNatives")) + dependsOn("compileNatives") useJUnitPlatform() } tasks.jar { - dependsOn(tasks.get("compileNatives")) -} \ No newline at end of file + dependsOn("compileNatives") +}