From e3e2a7e1d67ac4431b8c9ae889ba28347f6a569d Mon Sep 17 00:00:00 2001 From: sv99 Date: Thu, 20 Jul 2023 13:03:47 +0300 Subject: [PATCH] Allows run app from gradle for debugging purposes (#3179) Co-authored-by: Connor Tumbleson --- brut.apktool/apktool-cli/build.gradle | 11 +++++++++-- .../apktool-cli/src/main/java/brut/apktool/Main.java | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/brut.apktool/apktool-cli/build.gradle b/brut.apktool/apktool-cli/build.gradle index 52d051ed..c8ea405d 100644 --- a/brut.apktool/apktool-cli/build.gradle +++ b/brut.apktool/apktool-cli/build.gradle @@ -42,17 +42,24 @@ application { mainClass = 'brut.apktool.Main' } +tasks.named('run') { + // run from root directory + // otherwise run from brut.apktool/apktool-cli + workingDir = file(System.getProperty('user.dir')) +} + jar { manifest { attributes 'Main-Class': 'brut.apktool.Main' } } -task cleanOutputDirectory(type: Delete) { +tasks.register('cleanOutputDirectory', Delete) { delete fileTree(dir: jar.getDestinationDirectory().getAsFile(), exclude: "apktool-cli-all.jar") } -task proguard(type: ProGuardTask, dependsOn: shadowJar) { +tasks.register('proguard', ProGuardTask) { + dependsOn shadowJar injars shadowJar.getArchiveFile() // Java 9 and prior uses merged package for runtime, later uses split jmod files. diff --git a/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java index b2dbf7f5..e8cb9996 100644 --- a/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java +++ b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java @@ -183,7 +183,8 @@ public class Main { outDir = new File(outName); } - ApkDecoder decoder = new ApkDecoder(config, new ExtFile(apkName)); + ExtFile apkFile = new ExtFile(apkName); + ApkDecoder decoder = new ApkDecoder(config, apkFile); try { decoder.decode(outDir); @@ -195,7 +196,7 @@ public class Main { + "already exists. Use -f switch if you want to overwrite it."); System.exit(1); } catch (InFileNotFoundException ex) { - System.err.println("Input file (" + apkName + ") " + "was not found or was not readable."); + System.err.println("Input file (" + apkFile.getAbsolutePath() + ") " + "was not found or was not readable."); System.exit(1); } catch (CantFindFrameworkResException ex) { System.err