摇篮,Javadoc和Android的文件 [英] Gradle, Javadoc and Android documentation

查看:146
本文介绍了摇篮,Javadoc和Android的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在使用摇篮为我所有的项目,甚至Javadoc生成。

  android.libraryVariants.all {变种 - >

    任务(产生$ {variant.name}的Javadoc,键入:Javadoc中){
        标题=$名称$版本的API
        来源= variant.javaCompile.source
        ext.androidJar =$ {android.plugin.sdkDirectory} /平台/ $ {android.compileSdkVersion} /android.jar
        ext.googlePlayServicesJar = "${android.plugin.sdkDirectory}/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar"
        CLASSPATH =文件(variant.javaCompile.classpath.files,ext.androidJar,ext.googlePlayServicesJar)
        options.links(http://docs.oracle.com/javase/7/docs/api/);
        options.links(http://d.android.com/reference/);
        //options.linksOffline("http://d.android.com/reference,$ {android.plugin.sdkDirectory} /文档/参考);
        排除** / BuildConfig.java
        排除** / R.java
    }

}
 

使用了code我得到了一切,除了一件事情的工作,:类似的活动规律Android的API对象,位图等。 Java的链接工作正常。

最后生成的文档没有链接 http://d.android.com/reference。 我想这两个options.links()和 options.linksOffline()没有成功。

修改

由于@ejb,问题是,你不能提供多个 options.links()在同一时间。 所以我用两个 options.links() for Java的文件和 options.linksOffline()为Android的文档:

 选项{
    链接(http://docs.oracle.com/javase/7/docs/api/);
    linksOffline(http://d.android.com/reference,$ {android.plugin.sdkDirectory} /文档/参考);
    // stylesheetFile =新的文件(PROJECTDIR,stylesheet.css中);
}
 

解决方案

我是能够成功地链接到 http://d.android。 COM /参考使用下面的代码片段的它在功能正是你的(据我可以告诉)。

  android.libraryVariants.all {变种 - >
   任务(产生$ {variant.name.capitalize()}的Javadoc,键入:Javadoc中){
     //标题=''
     //说明=''
     来源= variant.javaCompile.source
     CLASSPATH =文件(variant.javaCompile.classpath.files,project.android.getBootClasspath())
     选项​​{
       链接http://docs.oracle.com/javase/7/docs/api/
       linksOfflinehttp://d.android.com/reference","${android.sdkDirectory}/docs/reference
     }
     排除** / BuildConfig.java
     排除** / R.java
   }
 }
 

那么还有别的东西不对劲这里。

您有离线的javadoc建,因为它似乎在包清单上是可用的Web服务的道路。也许仔细检查你确实有本地加载的文档,并确保有一个包列表 / [Android的SDK] /文档/参照目录。

如果您仍然无法弄清楚,也许你可以张贴输出。

您可能要检查的另一件事是 ./构建的/ tmp / [TASKNAME] /javadoc.options 表示,文件应显示精心设置相应的选项。要检查的事项将包括适当列入的android.jar在-classpath和linksOffline的预期参数presence的:<一href="http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#linkoffline"><$c$c>-linksoffline extDocURL packageListLoc

javadoc.options 应该有两个选项,只有相应的参数:

  -linksofflineHTTP://d.android.come/reference''[sdkDir] /文档/参考
-linkshttp://docs.oracle.com/javase/7/docs/api/
 

修改 android.getBootClasspath()是更好的,这要归功于P-CHAN

I'm now using Gradle for all my projects, and even for javadoc generation.

android.libraryVariants.all { variant ->

    task("generate${variant.name}Javadoc", type: Javadoc) {
        title = "$name $version API"
        source = variant.javaCompile.source
        ext.androidJar = "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
        ext.googlePlayServicesJar = "${android.plugin.sdkDirectory}/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar"
        classpath = files(variant.javaCompile.classpath.files, ext.androidJar, ext.googlePlayServicesJar)
        options.links("http://docs.oracle.com/javase/7/docs/api/");
        options.links("http://d.android.com/reference/");
        //options.linksOffline("http://d.android.com/reference", "${android.plugin.sdkDirectory}/docs/reference");
        exclude '**/BuildConfig.java'
        exclude '**/R.java'
    }

}

With that code I got everything working, except one thing: regular Android API objects like Activity, Bitmap etc. Java's links are working fine.

The final generated documentation does not link to http://d.android.com/reference. I tried both options.links() and options.linksOffline() without success.

EDIT

Thanks to @ejb, the problem was that you cannot provide multiple options.links() at the same time. So I used both options.links() for Java's documentation and options.linksOffline() for Android's documentation:

options {
    links("http://docs.oracle.com/javase/7/docs/api/");
    linksOffline("http://d.android.com/reference", "${android.plugin.sdkDirectory}/docs/reference");
    //stylesheetFile = new File(projectDir, "stylesheet.css");
}

解决方案

I was able to successfully link to http://d.android.com/reference using the following snippet which is functionally exactly what you have (as far as I can tell).

 android.libraryVariants.all { variant -> 
   task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
     // title = ''
     // description = ''
     source = variant.javaCompile.source 
     classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath()) 
     options { 
       links "http://docs.oracle.com/javase/7/docs/api/" 
       linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference" 
     } 
     exclude '**/BuildConfig.java' 
     exclude '**/R.java' 
   } 
 }

So there is something else amiss here.

You have to build the javadoc offline, as it doesn't seem the package-list is available on the path of the web service. Maybe double check that you actually have the docs loaded locally, and make sure there is a package-list in the /[android-sdk]/docs/reference directory.

If you still can't figure it out, perhaps you could post output.

Another thing you might check is the ./build/tmp/[taskname]/javadoc.options, the head of said file should show the appropriate options carefully set. Things to check for would include the proper inclusion of the android.jar in the -classpath and the presence of linksOffline with expected arguments: -linksoffline extDocURL packageListLoc

javadoc.options should have both options with only the respective arguments:

-linksoffline 'http://d.android.come/reference' '[sdkDir]/docs/reference'
-links 'http://docs.oracle.com/javase/7/docs/api/' 

EDIT: android.getBootClasspath() is nicer, thanks to P-chan.

这篇关于摇篮,Javadoc和Android的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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