aboutsummaryrefslogtreecommitdiff
path: root/smali/build.gradle
diff options
context:
space:
mode:
authorBen Gruver <bgruv@google.com>2012-09-15 22:56:10 -0700
committerBen Gruver <bgruv@google.com>2012-09-15 22:56:10 -0700
commitc9afead1a95863a28f58df4a46d9395c2a918ad5 (patch)
treef119189a5489302d1894102297e20ea0b31b14e8 /smali/build.gradle
parent5cf9fe7c0af588670265a5804dfae9ab8bb5c391 (diff)
downloadsmali-c9afead1a95863a28f58df4a46d9395c2a918ad5.tar.gz
Implement proguard support
Diffstat (limited to 'smali/build.gradle')
-rw-r--r--smali/build.gradle51
1 files changed, 39 insertions, 12 deletions
diff --git a/smali/build.gradle b/smali/build.gradle
index 257c2703..b5f9cb17 100644
--- a/smali/build.gradle
+++ b/smali/build.gradle
@@ -1,7 +1,7 @@
configurations {
antlr3
-
jflex
+ proguard
}
ext.antlrSource = 'src/main/antlr3'
@@ -28,6 +28,7 @@ dependencies {
antlr3 'org.antlr:antlr:3.2'
jflex 'de.jflex:jflex:1.4.3'
+ proguard 'net.sf.proguard:proguard-base:4.8'
}
task generateAntlrSource {
@@ -78,18 +79,44 @@ task generateJflexSource {
compileJava.dependsOn generateAntlrSource, generateJflexSource
compileTestJava.dependsOn generateTestAntlrSource
-processResources.inputs.properties('version': { -> version})
-processResources.expand('version': { -> version})
-
// We have to do this in taskGraph.whenReady, so that we use the correct
// version to resolve the project dependencies
gradle.taskGraph.whenReady {
- // build a jar containing all dependencies
- jar {
- from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
-
- manifest {
- attributes("Main-Class": "org.jf.smali.main")
- }
- }
+ // build a jar containing all dependencies
+ jar {
+ from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
+
+ manifest {
+ attributes("Main-Class": "org.jf.smali.main")
+ }
+ }
+
+ processResources.inputs.properties('version': version)
+ processResources.expand('version': version)
+
+ proguard {
+ def outFile = relativePath(buildDir) + '/libs/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
+
+ inputs.file jar.archivePath
+ outputs.file outFile
+
+ args '-injars ' + jar.archivePath + '(!**/TestStringTemplate*.class)'
+ args '-outjars ' + outFile
+ }
}
+
+task proguard(type: JavaExec, dependsOn: jar) {
+ setStandardOutput(java.lang.System.out);
+ setErrorOutput(java.lang.System.err);
+ classpath = files(configurations.proguard.asPath)
+ main = 'proguard.ProGuard'
+ args '-libraryjars ' + System.properties['java.home'] + '/lib/rt.jar'
+ args '-dontobfuscate'
+ args '-dontoptimize'
+ args '-keep public class org.jf.smali.main { public static void main(java.lang.String[]); }'
+ args '-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }'
+ args '-dontwarn com.google.common.base.**'
+ args '-dontnote com.google.common.base.**'
+}
+
+release.dependsOn(proguard) \ No newline at end of file