android如何打带依赖树的aar

作者: 三十二蝉 | 来源:发表于2018-01-28 23:06 被阅读55次

引言

Android Studio默认打出的aar只会包含本工程的源代码,不会携带library依赖的源码;但是我们常用的一些依赖库一般都是带依赖关系的(通过设置transitive = true,来透传依赖树)。下面讲解下这种带依赖关系的aar是怎么生成的

代码

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'me.vigi.fat-aar'

buildscript {
    repositories {
        jcenter()
        maven {
            url  "http://dl.bintray.com/vigidroid/maven"
        }
    }
    dependencies {
        classpath 'me.vigi:fat-aar-plugin:0.2.8'
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    embed 'com.google.auto.service:auto-service:1.0-rc2'
    embed 'com.squareup:javapoet:1.7.0'
}

如上代码,已经有人写了一个专门的插件,来完成这个功能;对于想要带依赖关系的三方库,可用embed的方式引入。三方插件Github地址

相关文章

网友评论

    本文标题:android如何打带依赖树的aar

    本文链接:https://www.haomeiwen.com/subject/xtajvxtx.html