android gradle 3.1后gradle打包jar
1.gradle 3.1 后build module后在build文件找不到jar文件的路径,只能找到aar的文件
2.我们可以拿到aar文件的jar文件使用
moduel:build.gradle 我们可以这样:
//aar的文件路径
def zipFile = file('build/outputs/aar/xxxx-release.aar')
//解压得到的jar的文件路径
def unzipFile = file('build/outputs/xxxx/classes.jar')
task makeJar(type: Jar) {
//解压aar拿到里面的jar文件跟assets资源文件
copy {
from zipTree(zipFile)
from fileTree(dir: 'src/main', includes: ['assets/**'])
into('build/outputs/xxxx/')
include('classes.jar')
include('assets/**')
}
from zipTree(unzipFile)
from fileTree(dir: 'src/main', includes: ['assets/**'])
baseName = SDK_BASENAME + SDK_VERSION
destinationDir = file("build")
}
makeJar.dependsOn(build)