Skip to content

Commit abdaeb9

Browse files
committed
配置dokka。
1 parent 903c157 commit abdaeb9

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
/build
1212
/captures
1313
.externalNativeBuild
14+
/.svn

androidutilskt/build.gradle

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'maven'
5+
apply plugin: 'com.github.dcendents.android-maven'
6+
apply plugin: 'org.jetbrains.dokka'
7+
8+
group='com.github.lindroy'
59

610
android {
711
compileSdkVersion 28
@@ -33,3 +37,66 @@ dependencies {
3337
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3438
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3539
}
40+
41+
task sourcesJar(type: Jar) {
42+
from android.sourceSets.main.java.srcDirs
43+
classifier = 'sources'
44+
}
45+
46+
task javadoc(type: Javadoc) {
47+
source = android.sourceSets.main.java.srcDirs
48+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
49+
}
50+
51+
/*task javadocJar(type: Jar, dependsOn: javadoc) {
52+
classifier = 'javadoc'
53+
from javadoc.destinationDir
54+
}*/
55+
//同时添加三个方法 for kotlin
56+
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
57+
outputFormat = "javadoc"
58+
outputDirectory = "$buildDir/dokkaJavadoc"
59+
}
60+
61+
task generateJavadoc(type: Jar, dependsOn: dokka) {
62+
group = 'jar'
63+
classifier = 'javadoc'
64+
from javadoc.destinationDir
65+
}
66+
task generateSourcesJar(type: Jar) {
67+
group = 'jar'
68+
from android.sourceSets.main.java.srcDirs
69+
classifier = 'sources'
70+
}
71+
72+
task copyDoc(type: Copy) {
73+
from "${buildDir}/docs/"
74+
into "docs"
75+
}
76+
//for kotlin
77+
artifacts {
78+
archives generateJavadoc //javadocJar
79+
archives generateSourcesJar //sourcesJar
80+
}
81+
82+
//解决kotlin javadoc.options抱错
83+
dokka {
84+
// outputFormat = 'html'
85+
// outputDirectory = "${buildDir}/javadoc"
86+
87+
linkMapping {
88+
dir = "src/main/kotlin"
89+
url = "https://github.com/lindroy/AndroidUtilsKt"
90+
suffix = "#L"
91+
}
92+
}
93+
94+
javadoc {
95+
options {
96+
encoding "UTF-8"
97+
charSet 'UTF-8'
98+
author true
99+
version true
100+
links "http://docs.oracle.com/javase/7/docs/api"
101+
}
102+
}

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ buildscript {
1010
dependencies {
1111
classpath 'com.android.tools.build:gradle:3.3.1'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13+
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
14+
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.9.18'
1315
// NOTE: Do not place your application dependencies here; they belong
1416
// in the individual module build.gradle files
1517
}

0 commit comments

Comments
 (0)