时间:2021-08-19 09:48:45 | 栏目:Android代码 | 点击:次
首先才项目的build.gradle 加入classpath ‘org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.16' (0.9.16是当前版本)
dependencies { classpath 'org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.15' }
然后再module的build.gradle中加入apply plugin: ‘org.jetbrains.dokka-android' (必须保证在com.android.application的下面或者就放在最下面)
apply plugin: 'org.jetbrains.dokka-android' task generateSourcesJar(type: Jar) { group = 'jar' from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs options.encoding = "UTF-8" classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { outputFormat = "javadoc" outputDirectory = javadoc.destinationDir } task generateJavadoc(type: Jar, dependsOn: dokkaJavadoc) { group = 'jar' classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives generateJavadoc archives generateSourcesJar }
同步更新一下,然后打开Termina
分别执行
gradlew generateSourcesJar
gradlew generateJavadoc
成功后,在module下的build目录libs下就能看到两个jar包
打开app-javadoc.jar即可看到生成的文档