首页 > 代码库 > gradle 构建apktool.jar

gradle 构建apktool.jar

apktool由gradle编译构建,但在apktool源码根目录运行gradle build, 没有生成apktool.jar,

basmali.jar, smali.jar 倒是生成了,后看apktool.jar的入口在brut.apktool/apktool-cli目录下

看gradle脚本:

 16 apply plugin: ‘eu.appsatori.fatjar‘
 17 
 18 configurations {
 19     proguard
 20 }
 21 
 22 dependencies {
 23   compile project(‘:brut.apktool:apktool-lib‘)
 24   proguard depends.proguard
 25 }
 26 
 27 gradle.taskGraph.whenReady {
 28   fatJar {
 29     manifest {
 30       attributes("Main-Class": "brut.apktool.Main")
 31     }
 32   }
 33 }
 34 
 35 task cleanOutputDirectory(type: Delete) {
 36     delete fileTree(dir: jar.destinationDir.getPath(), exclude: "apktool-cli.jar")
 37 }
 38 
 39 task proguard(type: JavaExec, dependsOn: fatJar) {
 40     def outFile = jar.destinationDir.getPath() + ‘/‘ + "apktool" + ‘-‘ + project.apktool_version + ‘-small‘ + ‘.‘ + jar.extension
 41     inputs.file jar.archivePath
 42     outputs.file outFile
 43 
 44     println "${jar.archivePath}"
 45     println "${outFile}"
 46     classpath = configurations.proguard
 47     main = ‘proguard.ProGuard‘
 48     args ‘-injars ‘ + "${jar.archivePath}" + ‘ (!META-INF/LICENSE.txt,!META-INF/NOTICE.txt,!README)‘
 49     args "-outjars ${outFile}"
 50     args "-libraryjars ${System.properties[‘java.home‘]}/lib/rt.jar"
 51     args ‘-dontobfuscate

 52     args ‘-dontoptimize‘
 53     args ‘-keep public class brut.apktool.Main { public static void main(java.lang.String[]); }‘
 54     args ‘-keep class org.yaml.snakeyaml.** { public protected private *; }‘
 55     args ‘-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }‘
 56     args ‘-dontwarn com.google.common.base.**‘
 57     args ‘-dontwarn com.google.common.collect.**‘
 58     args ‘-dontwarn com.google.common.util.**‘
 59     args ‘-dontwarn javax.xml.xpath.**‘
 60     args ‘-dontnote **‘

 61 }
 62 
 63 proguard.dependsOn cleanOutputDirectory
 64 tasks.getByPath(‘:release‘).dependsOn(proguard)


task生成相应的jar, 怀疑这个task没有默认执行

敲gradle proguard


果然生成的我们需要的东西。

apktool-2.0.0-dirty-small.jar




gradle 构建apktool.jar