fix: use shadow jar in app bundle to reduce jars count (#1868)

This commit is contained in:
Skylot 2023-05-18 20:40:39 +01:00
parent ae1b1ce99e
commit ed4c5a3a17
No known key found for this signature in database
GPG Key ID: 1E23F5B52567AA39
4 changed files with 33 additions and 2 deletions

View File

@ -107,8 +107,22 @@ allprojects {
}
task copyArtifacts(type: Copy) {
from tasks.getByPath(":jadx-cli:installDist")
from tasks.getByPath(":jadx-gui:installDist")
from(tasks.getByPath(":jadx-cli:installShadowDist")) {
exclude '**/*.jar'
filter { line ->
line.replaceAll('jadx-cli-(.*)-all.jar', 'jadx-$1-all.jar')
.replace('-jar "\\"$CLASSPATH\\""', '-cp "\\"$CLASSPATH\\"" jadx.cli.JadxCLI')
.replace('-jar "%CLASSPATH%"', '-cp "%CLASSPATH%" jadx.cli.JadxCLI')
}
}
from(tasks.getByPath(":jadx-gui:installShadowDist")) {
exclude '**/*.jar'
filter { line -> line.replaceAll('jadx-gui-(.*)-all.jar', 'jadx-$1-all.jar') }
}
from(tasks.getByPath(":jadx-gui:installShadowDist")) {
include '**/*.jar'
rename 'jadx-gui-(.*)-all.jar', 'jadx-$1-all.jar'
}
into layout.buildDirectory.dir("jadx")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

View File

@ -1,5 +1,8 @@
plugins {
id 'application'
// use shadow only for application scripts, jar will be copied from jadx-gui
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
dependencies {
@ -22,6 +25,13 @@ application {
mainClass.set('jadx.cli.JadxCLI')
applicationDefaultJvmArgs = ['-Xms128M', '-XX:MaxRAMPercentage=70.0', '-XX:+UseG1GC']
}
shadow {
mainClassName = application.mainClass.get()
}
shadowJar {
// shadow jar not needed
configurations = []
}
applicationDistribution.with {
into('') {

View File

@ -74,6 +74,8 @@ public class JCommanderWrapper<T> {
}
public void printUsage() {
LogHelper.setLogLevel(LogHelper.LogLevelEnum.ERROR); // mute logger while printing help
// print usage in not sorted fields order (by default sorted by description)
PrintStream out = System.out;
out.println();

View File

@ -51,6 +51,11 @@ public class LogHelper {
return args.logLevel;
}
public static void setLogLevel(LogLevelEnum newLogLevel) {
logLevelValue = newLogLevel;
applyLogLevel(logLevelValue);
}
public static void setLogLevelsForLoadingStage() {
if (logLevelValue == null) {
return;