From 7d6346c0887303a136e797c02910834651bcda8a Mon Sep 17 00:00:00 2001 From: comp500 Date: Fri, 21 Jan 2022 00:36:33 +0000 Subject: [PATCH] Shade and relocate Commons CLI, update to 1.5.0 --- build.gradle.kts | 21 +++++++------------ .../packwiz/installer/RequiresBootstrap.java | 2 -- src/main/resources/META-INF/LICENSES.md | 2 +- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 215c475..1c33397 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,15 +24,12 @@ java { sourceCompatibility = JavaVersion.VERSION_1_8 } -val shrinkClasspath: Configuration by configurations.creating - repositories { mavenCentral() } dependencies { - implementation("commons-cli:commons-cli:1.4") - shrinkClasspath("commons-cli:commons-cli:1.4") + implementation("commons-cli:commons-cli:1.5.0") implementation("com.moandjiezana.toml:toml4j:0.7.2") implementation("com.google.code.gson:gson:2.8.9") implementation("com.squareup.okio:okio:3.0.0") @@ -60,22 +57,22 @@ licenseReport { filters = arrayOf(com.github.jk1.license.filter.LicenseBundleNormalizer()) } -// Commons CLI and Minimal JSON are already included in packwiz-installer-bootstrap tasks.shadowJar { - dependencies { - exclude(dependency("commons-cli:commons-cli:1.4")) - exclude(dependency("com.eclipsesource.minimal-json:minimal-json:0.9.5")) - // TODO: exclude unnecessary meta inf files - } exclude("**/*.kotlin_metadata") exclude("**/*.kotlin_builtins") exclude("META-INF/maven/**/*") exclude("META-INF/proguard/**/*") + + // Relocate Commons CLI, so that it doesn't clash with old packwiz-installer-bootstrap (that shades it) + relocate("org.apache.commons.cli", "link.infra.packwiz.installer.deps.commons-cli") + + // from Commons CLI + exclude("META-INF/LICENSE.txt") + exclude("META-INF/NOTICE.txt") } tasks.register("shrinkJar") { injars(tasks.shadowJar) - libraryjars(files(shrinkClasspath.files)) outjars("build/libs/" + tasks.shadowJar.get().outputs.files.first().name.removeSuffix(".jar") + "-shrink.jar") if (System.getProperty("java.version").startsWith("1.")) { libraryjars("${System.getProperty("java.home")}/lib/rt.jar") @@ -95,8 +92,6 @@ tasks.register("shrinkJar") { dontoptimize() dontobfuscate() dontwarn("org.codehaus.mojo.animal_sniffer.*") - - // TODO: repackage commons CLI } // Used for vscode launch.json diff --git a/src/main/java/link/infra/packwiz/installer/RequiresBootstrap.java b/src/main/java/link/infra/packwiz/installer/RequiresBootstrap.java index 813a37b..c820453 100644 --- a/src/main/java/link/infra/packwiz/installer/RequiresBootstrap.java +++ b/src/main/java/link/infra/packwiz/installer/RequiresBootstrap.java @@ -8,8 +8,6 @@ public class RequiresBootstrap { public static void main(String[] args) { // Very small CLI implementation, because Commons CLI complains on unexpected // options - // Also so that Commons CLI can be excluded from the shaded JAR, as it is - // included in the bootstrap if (Arrays.stream(args).map(str -> { if (str == null) return ""; if (str.startsWith("--")) { diff --git a/src/main/resources/META-INF/LICENSES.md b/src/main/resources/META-INF/LICENSES.md index a2f265e..cba7d61 100644 --- a/src/main/resources/META-INF/LICENSES.md +++ b/src/main/resources/META-INF/LICENSES.md @@ -5,7 +5,7 @@ packwiz-installer itself is under the MIT license, except for Murmur2Lib and bun - Murmur2Lib: Apache 2.0 ([Source](https://github.com/prasanthj/hasher/blob/master/src/main/java/hasher/Murmur2.java)) - Google Gson 2.8.9: Apache 2.0 ([Source](https://github.com/google/gson)) - Okio 3.0.0: Apache 2.0 ([Source](https://github.com/square/okio/)) -- Commons CLI 1.4: Apache 2.0 ([Source](http://commons.apache.org/proper/commons-cli/)) +- Commons CLI 1.5: Apache 2.0 ([Source](http://commons.apache.org/proper/commons-cli/)) - Jetbrains Annotations 13.0: Apache 2.0 ([Source](https://github.com/JetBrains/java-annotations)) - Kotlin Standard Library 1.6.10: Apache 2.0 ([Source](https://github.com/JetBrains/kotlin)) - toml4j 0.7.2: MIT ([Source](https://github.com/mwanji/toml4j))