参考:
https://stackoverflow.com/questions/40616077/using-proguard-in-java-modules-android-studio
https://segmentfault.com/a/1190000010338331
Project:
-app (android application)
-common (java library)
-build.gradle
import proguard.gradle.ProGuardTask
buildscript {
classpath"net.sf.proguard:proguard-gradle:5.3.3"
}
task proguardFiles(type: ProGuardTask,dependsOn: compileJava) {
// make jar task wait for proguardFiles task finish
tasks.jar.dependsOn.add(proguardFiles)
println"proguarding"
// build\classes\java\main
println"${sourceSets.main.java.outputDir}"
// main classes
println"${sourceSets.main.output}"
printmapping"$buildDir/mapping.txt"
configuration'proguard-rules.pro'
libraryjars files(configurations.compile.findAll {}.collect())
injarssourceSets.main.output
// setup proguard output classes: output not .jar
outjars"$buildDir/libs/${project.name}"
// delete previous outputs
delete"$buildDir/libs/${project.name}"
// replace the original classes
doLast {
println"copying product"
// delete original classes in "${sourceSets.main.java.outputDir}"
delete"${sourceSets.main.java.outputDir}" //"${sourceSets.main.output.classesDir}"
copy {
from"$buildDir/libs/${project.name}"
// copy proguard outputs into "${sourceSets.main.java.outputDir}"
into"${sourceSets.main.java.outputDir}" //"${sourceSets.main.output.classesDir}"
}
}
}
依赖的jar需不需要打包进来,如果需要怎么搞?
如何在该模块内区分release/debug,让debug不混淆?
网友评论