-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
140 lines (118 loc) · 3.9 KB
/
build.gradle.kts
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import com.android.build.gradle.BaseExtension
import java.net.URL
// apply plugin: 'com.android.library'
// apply plugin: 'com.github.dcendents.android-maven'
// group='com.github.Joyoe'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("maven-publish")
id("java")
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.3")
classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
val dlPackageList by tasks.registering {
outputs.upToDateWhen { false }
doLast {
/* Merge framework packages with AndroidX packages into the same list
* so links to Android classes can work properly in Javadoc */
rootProject.buildDir.mkdirs()
File(rootProject.buildDir, "package-list").outputStream().use { out ->
URL("https://developer.android.com/reference/package-list")
.openStream().use { src -> src.copyTo(out) }
URL("https://developer.android.com/reference/androidx/package-list")
.openStream().use { src -> src.copyTo(out) }
}
}
}
val javadoc = tasks.replace("javadoc", Javadoc::class).apply {
dependsOn(dlPackageList)
isFailOnError = false
title = "libsu API"
exclude("**/internal/**")
(options as StandardJavadocDocletOptions).apply {
links = listOf("https://docs.oracle.com/javase/8/docs/api/")
linksOffline = listOf(JavadocOfflineLink(
"https://developer.android.com/reference/", rootProject.buildDir.path))
isNoDeprecated = true
}
setDestinationDir(File(rootProject.buildDir, "javadoc"))
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn(javadoc)
archiveClassifier.set("javadoc")
from(javadoc.destinationDir)
}
/* Force JitPack to build javadocJar and publish */
tasks.register("install") {
dependsOn(tasks["publishToMavenLocal"])
}
publishing {
publications {
create<MavenPublication>("maven") {
artifact(javadocJar.get())
groupId = "com.github.joyoe"
artifactId = "docs"
}
}
}
val Project.android get() = extensions.getByName<BaseExtension>("android")
subprojects {
buildscript {
repositories {
google()
jcenter()
}
}
repositories {
google()
jcenter()
}
configurations.create("javadocDeps")
afterEvaluate {
android.apply {
compileSdkVersion(30)
buildToolsVersion = "30.0.3"
defaultConfig {
if (minSdkVersion == null)
minSdkVersion(14)
targetSdkVersion(30)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
if (plugins.hasPlugin("com.android.library")) {
android.apply {
buildFeatures.apply {
buildConfig = false
}
}
}
if (plugins.hasPlugin("com.github.dcendents.android-maven")) {
val sources = android.sourceSets.getByName("main").java.getSourceFiles()
(rootProject.tasks["javadoc"] as Javadoc).apply {
source += sources
classpath += project.files(android.bootClasspath)
classpath += configurations.getByName("javadocDeps")
}
val sourcesJar = tasks.register("sourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(sources)
}
artifacts {
add("archives", sourcesJar)
}
}
}
}