我每次构建项目时都会自动生成JavaDoc。根据{{3}},我有一个非常简单的gradle代码:
android.applicationVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
title = "Documentation for Android $android.defaultConfig.versionName b$android.defaultConfig.versionCode"
destinationDir = new File("${project.getProjectDir().parent}/docs", variant.baseName)
source = variant.javaCompile.source
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
description "Generates Javadoc for $variant.name."
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PRIVATE
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://developer.android.com/reference/reference/");
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
} 它在控制台(println)中显示文本,但不生成JavaDocs。只有当我写“gradle generateDebugJavaDoc”时才会这样做。它完美无缺。问题是 - 如何设置它以便每次构建项目时gradle会自动生成JavaDocs?任何帮助将不胜感激!
答案 0 :(得分:1)
类似于project.task("assemble${variant.name.capitalize()}").dependsOn(myTask)