赞
踩
AS默认生成aar格式的文件 有时候需要生成jar包 可以通过grable命令去生成
//拷贝代码
task copyClass(type: Copy) {
delete('build/libs/')
from('build/intermediates/classes/debug')
into('build/libs/class/')
}
//拷贝并解压缩libs资源
task copyUnzipLibClass() {
ant.unzip(src: "libs/jar_1.jar", dest: "build/libs/class/")
ant.unzip(src: "libs/jar_2.jar", dest: "build/libs/class/")
ant.unzip(src: "libs/jar_3.jar", dest: "build/libs/class/")
}
//编译 Jar
task buildJar(type: Jar) {
//最终的 Jar包名
archiveName = "jar_name.jar"
//初始化资源路径集
from("build/libs/class/")
//去除路径集下部分的资源
exclude "**/R.class"
//集成下面的资源
include "/com/**"
include "/org/**"
}
copyClass.dependsOn(build)
copyUnzipLibClass.dependsOn(copyClass)
buildJar.dependsOn(copyUnzipLibClass)
//运行 gradlew buildJar
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。