[英]How to exclude library jars during build process from android library project aar artifacts?
I have Android Library Project and I have to generate aar artifacts without including any jars from libs directory in my project. 我有Android Library Project,并且必须生成aar工件,而在我的项目中不包含libs目录中的任何jar。
One of the approach I thought is extracting classes.jar from aar file and then use classes.jar as a dependency in other projects. 我认为的方法之一是从aar文件中提取classes.jar,然后将classes.jar用作其他项目中的依赖项。
Is there a better way ? 有没有更好的办法 ?
I use following plugin to generate aar 我使用以下插件生成aar
apply plugin: 'com.android.library'
Roughly the same idea, but after you run uploadArchives, you can run this gradle task: 大致相同的想法,但是在运行uploadArchives之后,可以运行以下gradle任务:
task makeJarRelease(type: Copy) {
from("build/intermediates/bundles/release/")
into("release/")
include("classes.jar")
rename("classes.jar", "somename.jar")
println "made jar"
}
That jar is the same jar that will be in your .aar file, so long as you run uploadArchives first. 只要您先运行uploadArchives,该jar就会与您的.aar文件中的jar相同。 I had this step:
我执行了以下步骤:
makeJarRelease.dependsOn(uploadArchives)
Used to use it back when I supported eclipse with my library. 当我在库中支持eclipse时,可以使用它。 Hope it helps!
希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.