From 0003d56389b83f6da050ff39e017cc00b541cca8 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Fri, 1 May 2015 10:26:10 -0500 Subject: [PATCH] Switch to Proguard Gradle --- brut.apktool.smali/baksmali/build.gradle | 7 +--- brut.apktool.smali/build.gradle | 2 +- brut.apktool.smali/smali/build.gradle | 10 ++--- brut.apktool/apktool-cli/build.gradle | 50 +++++++++++++----------- build.gradle | 5 --- 5 files changed, 35 insertions(+), 39 deletions(-) diff --git a/brut.apktool.smali/baksmali/build.gradle b/brut.apktool.smali/baksmali/build.gradle index a06452ed..61304950 100644 --- a/brut.apktool.smali/baksmali/build.gradle +++ b/brut.apktool.smali/baksmali/build.gradle @@ -52,16 +52,13 @@ processResources.inputs.property('version', version) processResources.expand('version': version) // build a jar containing all dependencies -jar { +task fatJar (type: Jar) { + from sourceSets.main.output from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { attributes("Main-Class": "org.jf.baksmali.main") } - - doLast { - //ant.symlink(link: file("${destinationDir}/baksmali.jar"), resource: archivePath, overwrite: true) - } } task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { diff --git a/brut.apktool.smali/build.gradle b/brut.apktool.smali/build.gradle index 22a099c6..42ca8595 100644 --- a/brut.apktool.smali/build.gradle +++ b/brut.apktool.smali/build.gradle @@ -82,7 +82,7 @@ subprojects { stringtemplate: 'org.antlr:stringtemplate:3.2.1', commons_cli: 'commons-cli:commons-cli:1.2', jflex: 'de.jflex:jflex:1.4.3', - proguard: 'net.sf.proguard:proguard-base:5.2' + proguard_gradle: 'net.sf.proguard:proguard-gradle:5.1' ] } diff --git a/brut.apktool.smali/smali/build.gradle b/brut.apktool.smali/smali/build.gradle index 1b859d1c..4dcf7f36 100644 --- a/brut.apktool.smali/smali/build.gradle +++ b/brut.apktool.smali/smali/build.gradle @@ -141,17 +141,17 @@ task generateJflexSource(type: JavaExec) { compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource, generateJflexSource compileTestJava.dependsOn generateTestAntlrSource +processResources.inputs.property('version', version) +processResources.expand('version': version) + // build a jar containing all dependencies -jar { +task fatJar (type: Jar) { + from sourceSets.main.output from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { attributes("Main-Class": "org.jf.smali.main") } - - doLast { - // ant.symlink(link: file("${destinationDir}/smali.jar"), resource: archivePath, overwrite: true) - } } task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { diff --git a/brut.apktool/apktool-cli/build.gradle b/brut.apktool/apktool-cli/build.gradle index 8a853b5e..e33e79c9 100644 --- a/brut.apktool/apktool-cli/build.gradle +++ b/brut.apktool/apktool-cli/build.gradle @@ -15,13 +15,18 @@ */ apply plugin: 'eu.appsatori.fatjar' -configurations { - proguard +dependencies { + compile project(':brut.apktool:apktool-lib') } -dependencies { - compile project(':brut.apktool:apktool-lib') - proguard depends.proguard +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath depends.proguard_gradle + } } gradle.taskGraph.whenReady { @@ -36,26 +41,25 @@ task cleanOutputDirectory(type: Delete) { delete fileTree(dir: jar.destinationDir.getPath(), exclude: "apktool-cli.jar") } -task proguard(type: JavaExec, dependsOn: fatJar) { +task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { def outFile = jar.destinationDir.getPath() + '/' + "apktool" + '-' + project.apktool_version + '-small' + '.' + jar.extension - inputs.file jar.archivePath - outputs.file outFile - classpath = configurations.proguard - main = 'proguard.ProGuard' - args '-injars ' + "${jar.archivePath}" + ' (!META-INF/LICENSE.txt,!META-INF/NOTICE.txt,!README)' - args "-outjars ${outFile}" - args "-libraryjars ${System.properties['java.home']}/lib/rt.jar" - args '-dontobfuscate' - args '-dontoptimize' - args '-keep public class brut.apktool.Main { public static void main(java.lang.String[]); }' - args '-keep class org.yaml.snakeyaml.** { public protected private *; }' - args '-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }' - args '-dontwarn com.google.common.base.**' - args '-dontwarn com.google.common.collect.**' - args '-dontwarn com.google.common.util.**' - args '-dontwarn javax.xml.xpath.**' - args '-dontnote **' + injars fatJar.archivePath + outjars outFile + + libraryjars "${System.properties['java.home']}/lib/rt.jar" + + dontobfuscate + dontoptimize + + keep 'public class brut.apktool.Main { public static void main(java.lang.String[]); }' + keep 'class org.yaml.snakeyaml.** { public protected private *; }' + keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }' + dontwarn 'com.google.common.base.**' + dontwarn 'com.google.common.collect.**' + dontwarn 'com.google.common.util.**' + dontwarn 'javax.xml.xpath.**' + dontnote '**' } proguard.dependsOn cleanOutputDirectory diff --git a/build.gradle b/build.gradle index b4b61fa3..626e6262 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,6 @@ subprojects { guava: 'com.google.guava:guava:14.0', jflex: 'de.jflex:jflex:1.4.3', junit: 'junit:junit:4.6', - proguard: 'net.sf.proguard:proguard-base:5.2', proguard_gradle: 'net.sf.proguard:proguard-gradle:5.1', snakeyaml: 'org.yaml:snakeyaml:1.12', xmlpull: 'xpp3:xpp3:1.1.4c', @@ -105,10 +104,6 @@ subprojects { ] } - jar { - version = jarVersion - } - repositories { mavenCentral() }