Shade and relocate Commons CLI, update to 1.5.0

This commit is contained in:
comp500 2022-01-21 00:36:33 +00:00
parent aff921f67e
commit 7d6346c088
3 changed files with 9 additions and 16 deletions

View File

@ -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.DependencyFilter>(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<proguard.gradle.ProGuardTask>("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<proguard.gradle.ProGuardTask>("shrinkJar") {
dontoptimize()
dontobfuscate()
dontwarn("org.codehaus.mojo.animal_sniffer.*")
// TODO: repackage commons CLI
}
// Used for vscode launch.json

View File

@ -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("--")) {

View File

@ -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))