java怎么导出安卓sdk,如何为android库生成javadoc,当它具有也是aar库的依赖项时?...

I have android library project which depends on other android library projects. I need to generate javadoc for library but it fails because gradle puts to javadoc classpath path to .aar locations but javadoc expects .jar files.

simplified gradle file:

android {

compileSdkVersion 23

buildToolsVersion "23.0.2"

configurations {

javadocDeps

}

defaultConfig {

minSdkVersion 7

targetSdkVersion 23

versionCode 1

versionName "0.1.0"

}

}

dependencies {

compile 'com.android.support:support-v4:23.2.0'

compile 'com.android.support:appcompat-v7:23.2.0'

compile 'com.nineoldandroids:library:2.4.0'

compile 'com.annimon:stream:1.0.7'

javadocDeps 'com.android.support:support-annotations:23.2.0'

javadocDeps 'com.nineoldandroids:library:2.4.0'

javadocDeps 'com.android.support:support-v4:23.2.0'

}

task sourcesJar(type: Jar) {

from android.sourceSets.main.java.srcDirs

classifier = 'sources'

}

task javadoc(type: Javadoc, dependsOn: explodeAars) {

source = android.sourceSets.main.java.srcDirs

classpath += project.files(android.getBootClasspath().join(File.pathSeparator))

classpath += configurations.javadocDeps

}

task javadocJar(type: Jar, dependsOn: javadoc) {

classifier = 'javadoc'

from javadoc.destinationDir

}

artifacts {

archives javadocJar

archives sourcesJar

}

3 solutions possible:

1) somehow to add to the classpath path classes.jar from every aar library it depends build/intermidiates/exploded-aar/library/version/jars/classes.jar

I don't know how to include these paths in javadoc task.

2) manually unpack classes.jar from aar file and add them to classpath of javadoc task

3) very dirty hack - hardcoded paths to library - but I think this is so WRONG.

How to achieve 1 or 2 with gradle dsl?

解决方案

The solution from @rve is now broken on Android Studio 2.3 / Gradle 3.3 as the exploded-aar no longer exists (with no alternative inside the build directory).

If the aar you depend on is not a module in your project, you will need first to extract the classes.jar before referencing it in the classpath (basically re-create intermediates/exploded-aar manually).

If the aar you depend on is just another module in your project you can also make your javadoc task depends on the compile task of that module and reference the intermediates/classes/release of that module (if you make javadoc depends on assembleRelease for example). An example of that workaround: https://github.com/Microsoft/mobile-center-sdk-android/pull/345/files

I really wish someone comes up with a better solution though.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值