我正在使用 Dokka 插件为我的kotlin项目生成文档
以下是插件网址 https://github.com/Kotlin/dokka
我已按照说明操作,这是 Project.gradle 的样子
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.15"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是 app / build.gradle 的样子
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.dokka'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.kk.testkotlindoc"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/javadoc"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
当我执行以下命令生成文档时
./ gradlew dokka
它最初在完成该过程后下载了必要的jar文件,它给出了以下错误
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/KK/AndroidStudioProjects/TestkotlinDoc/app/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError-com/android/build/gradle/AppPlugin
不受支持的major.minor版本52.0
但我无法确定问题是什么或我在这里失踪
请帮帮我..
答案 0 :(得分:1)
问题是您在较旧的JDK版本下运行Dokka。 Dokka需要JDK 8.请确保您计算机上的环境变量JDK_HOME指向JDK 8安装。
答案 1 :(得分:1)
您可以在没有Dokka插件的情况下生成Dokka文档。使用GradleMavenPush,它具有task androidDokka(type: Exec, dependsOn: dokkaInitializer)
和task coreDokka(type: Exec, dependsOn: dokkaInitializer)
apply from: 'https://raw.github.com/Vorlonsoft/GradleMavenPush/master/maven-push.gradle'