创建包含 javadoc 和源代码的 Android 库 AAR [英] Create Android library AAR including javadoc and sources

查看:23
本文介绍了创建包含 javadoc 和源代码的 Android 库 AAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在开发一个 Android 库,用于一些同样由我们开发的示例应用程序.该库创建为 AAR 文件.这是它的 build.gradle

My team is developing an Android library, to be used in some example applications, also developed by us. The library is created as an AAR file. Here is its build.gradle

apply plugin: 'com.android.library'
apply from: 'deploy.gradle'

android {
    compileSdkVersion 20
    buildToolsVersion '20.0.0'
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'LICENSE'
        exclude 'NOTICE'
    }
    defaultConfig {
        // Excluded for brevity
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
        // if true, check all issues, including those that are off by default
        checkAllWarnings true
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v13:20.0.+'
    compile 'com.google.android.gms:play-services:5.+'
    compile 'com.squareup.retrofit:retrofit:1.6.1'
}

这里是应用的 build.gradle 的依赖部分

Here is the dependencies part of the app's build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ('com.mycompany.myapp:0.6.5-SNAPSHOT@aar') {
        transitive = true
        downloadJavadoc = true
        downloadSources = true
    }
}

我可以使用所有的 lib 类,但我看不到 Javadoc 和源代码.如何打包我的 AAR 以使其包含源代码和 Javadoc?

I can use all the lib classes, but I can't see the Javadocs nor the sources. How can I package my AAR so it includes the sources and Javadocs?

推荐答案

似乎暂时无法完成.但是,在 deploy.gradle 中添加这些 gradle 任务,会创建 -javadoc.jar 和 -sources.jar.

Seems like it can't be done for now. However, adding these gradle tasks in the deploy.gradle, the -javadoc.jar and -sources.jar are created.

task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
}

task androidJavadocsJar(type: Jar) {
    classifier = 'javadoc'
    baseName = artifact_id
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    baseName = artifact_id
    from android.sourceSets.main.java.srcDirs
}

artifacts {
//    archives packageReleaseJar
    archives androidSourcesJar
    archives androidJavadocsJar
}

之后,需要手动导入源代码和javadoc.根据这个帖子这个未解决的问题无法自动导入.

After that, the sources and javadoc need to be manually imported. According to this thread and this open issue they can't be automatically imported.

这篇关于创建包含 javadoc 和源代码的 Android 库 AAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆