生成带assets文件夹的jar包
2016-09-20 本文已影响0人
无名大卒
(1)编写相应task
在build.gradle文件夹加入buildMyJar task
task buildJar(type: Jar, dependsOn: ['build']) {
//导出的jar文件名称
archiveName = 'aa.jar'
//从哪个目录打包jar
from('build/intermediates/classes/release')
//导出的jar文件的存放目录(未指定则默认存放在build/outputs/libs下)
destinationDir = file('build/outputs/libs')
//去掉不要的类
//exclude('com/aa/bb/BuildConfig\$*.class')
//exclude('**/R.class')
//exclude('**/R\$*.class')
//需要打包的类
include('**/*.class')
//include assets path
from fileTree(dir: './',includes: ['assets/**'])
include('assets/**')
}
}
(2)打开AS右侧面板的gradle projects,在相应工程的other找到buildMyJar 执行即可。