1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| void transform(Context context, Collection<TransformInput> inputs, Collection<TransformInput> referencedInputs, TransformOutputProvider outputProvider, boolean isIncremental) throws IOException, TransformException, InterruptedException {
// super.transform(context, inputs, referencedInputs, outputProvider, isIncremental)
ExtParams params = project.extParams
println " params.logEnable is ${ params.logEnable }"
println "transform method is invoked ====== --------------- " // System.out.println("=======================================doPathTransform{ context=${context}, inputs=${inputs}, referencedInputs=${referencedInputs}, outputProvider=${outputProvider}, isIncremental=${isIncremental}")
inputs.each { TransformInput input ->
input.directoryInputs.each { DirectoryInput directoryInput ->
//修改我们关注的类 InjectU.inject(directoryInput.file.absolutePath)
//获取输出目录 def dest = outputProvider.getContentLocation( directoryInput.name,directoryInput.contentTypes,directoryInput.scopes, Format.DIRECTORY)
// println "directory name location is ${directoryInput.name}"
com.android.utils.FileUtils.copyDirectory( directoryInput.file,dest) }
input.jarInputs.each { JarInput jarInput ->
//jar文件一般是第三方依赖库jar文件 // 重命名输出文件(同目录copyFile会冲突)
def jarName = jarInput.name def md5 = DigestUtils.md5Hex(jarInput.file.getAbsolutePath()) if (jarName.endsWith(".jar")) { jarName = jarName.substring(0,jarName.length() - 4 ) }
//输出 def dest = outputProvider.getContentLocation(jarName, jarInput.contentTypes,jarInput.scopes,Format.JAR)
// println " jar name location is ${jarInput.name}"
FileUtils.copyFile(jarInput.file,dest)
} }
}
|