forked from codyer/ElegantBus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-doc.gradle
72 lines (63 loc) · 1.93 KB
/
config-doc.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* ************************************************************
* 文件:config-doc.gradle 模块:ElegantBus 项目:ElegantBus
* 当前修改时间:2020年06月19日 22:32:17
* 上次修改时间:2020年06月19日 22:30:31
* 作者:Cody.yi https://github.com/codyer
*
* 描述:ElegantBus
* Copyright (c) 2020
* ************************************************************
*/
import org.gradle.internal.jvm.Jvm
//编译groovy代码时采用 UTF-8
tasks.withType(GroovyCompile) {
groovyOptions.encoding = "MacRoman"
}
//编译JAVA文件时采用UTF-8
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// 打包源码jar
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.convention('sources')
archiveClassifier.set('sources')
}
task javadoc(type: Javadoc) {
source += android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
if (Jvm.current().getJavaVersion() == JavaVersion.VERSION_1_8) {
options.addStringOption('Xdoclint:none', '-quiet')
}
failOnError false
}
// 打包文档jar
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.convention('javadoc')
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
/*在javadoc task执行之前先添加第三方的依赖进来,否则会找不到相关的jar包*/
afterEvaluate {
try {
javadoc.source += "$buildDir/generated/aidl_source_output_dir/"
javadoc.classpath += project.android.libraryVariants.toList().first().javaCompileProvider.get().classpath
} catch (e) {
println(e)
}
}
javadoc {
options {
// 语言
locale 'en_US'
encoding 'UTF-8'
charSet 'UTF-8'
links "http://docs.oracle.com/javase/8/docs/api"
}
}