Use the proguard plugin for gradle

Conflicts:
	brut.apktool.smali/baksmali/build.gradle
	brut.apktool.smali/smali/build.gradle
	build.gradle
This commit is contained in:
Ben Gruver 2015-03-01 19:43:01 -08:00 committed by Connor Tumbleson
parent 46d2fb899f
commit b8016ae6ef
3 changed files with 52 additions and 40 deletions

View File

@ -28,9 +28,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
configurations {
proguard
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath depends.proguard_gradle
}
}
dependencies {
@ -41,8 +46,6 @@ dependencies {
testCompile depends.junit
testCompile project(':brut.apktool.smali:smali')
proguard depends.proguard
}
processResources.inputs.property('version', version)
@ -61,23 +64,22 @@ jar {
}
}
task proguard(type: JavaExec, dependsOn: jar) {
def outFile = jar.destinationDir.getPath() + '/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
inputs.file jar.archivePath
outputs.file outFile
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) {
def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' + fatJar.version + '-small' + '.' + fatJar.extension
classpath = configurations.proguard
main = 'proguard.ProGuard'
args '-injars ' + jar.archivePath
args '-outjars ' + outFile
args '-libraryjars ' + System.properties['java.home'] + '/lib/rt.jar'
args '-keepattributes Signature'
args '-dontobfuscate'
args '-dontoptimize'
args '-keep public class org.jf.baksmali.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.**'
args '-dontnote com.google.common.**'
injars fatJar.archivePath
outjars outFile
libraryjars "${System.properties['java.home']}/lib/rt.jar"
dontobfuscate
dontoptimize
keep 'public class org.jf.baksmali.main { public static void main(java.lang.String[]); }'
keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }'
dontwarn 'com.google.common.**'
dontnote 'com.google.common.**'
}
tasks.getByPath(':release').dependsOn(proguard)

View File

@ -32,7 +32,15 @@
configurations {
antlr3
jflex
proguard
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath depends.proguard_gradle
}
}
ext.antlrSource = 'src/main/antlr3'
@ -75,7 +83,6 @@ dependencies {
antlr3 depends.antlr
jflex depends.jflex
proguard depends.proguard
}
task generateParserAntlrSource(type: JavaExec) {
@ -147,25 +154,23 @@ jar {
}
}
processResources.inputs.property('version', version)
processResources.expand('version': version)
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) {
def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' +
fatJar.version + '-small' + '.' + fatJar.extension
task proguard(type: JavaExec, dependsOn: jar) {
def outFile = jar.destinationDir.getPath() + '/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
inputs.file jar.archivePath
outputs.file outFile
injars fatJar.archivePath
outjars outFile
classpath = configurations.proguard
main = 'proguard.ProGuard'
args "-injars ${jar.archivePath}(!**/TestStringTemplate*.class)"
args "-outjars ${outFile}"
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.**'
args '-dontnote com.google.common.**'
libraryjars "${System.properties['java.home']}/lib/rt.jar"
dontobfuscate
dontoptimize
keep 'public class org.jf.smali.main { public static void main(java.lang.String[]); }'
keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }'
dontwarn 'com.google.common.**'
dontnote 'com.google.common.**'
}
tasks.getByPath(':release').dependsOn(proguard)

View File

@ -98,12 +98,17 @@ subprojects {
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',
xmlunit: 'xmlunit:xmlunit:1.3',
]
}
jar {
version = jarVersion
}
repositories {
mavenCentral()
}