This repository has been archived by the owner on May 17, 2023. It is now read-only.
forked from sproctor/accompanist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
216 lines (199 loc) · 7.88 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//import com.vanniktech.maven.publish.MavenPublishPluginExtension
//import com.vanniktech.maven.publish.SonatypeHost
//import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
//import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
import java.util.Properties
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
// id("com.diffplug.spotless") version "5.14.0"
kotlin("multiplatform") version "1.8.0" apply false
id("com.android.library") version "7.3.1" apply false
id("com.android.application") version "7.3.1" apply false
id("org.jetbrains.compose") version "1.3.0" apply false
id("maven-publish")
// id("com.vanniktech.maven.publish") version "0.18.0"
// id("org.jetbrains.dokka") version "1.7.20"
id("me.tylerbwong.gradle.metalava") version "0.2.1" apply false
id("com.github.ben-manes.versions") version "0.42.0"
}
//tasks.withType<DokkaMultiModuleTask> {
// outputDirectory.set(rootProject.file("docs/api"))
// failOnWarning.set(true)
//}
allprojects {
repositories {
mavenCentral()
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
afterEvaluate {
publishing {
repositories {
maven {
name = "GithubPackages"
url = uri("https://maven.pkg.github.com/Qawaz/accompanist")
credentials {
username = (System.getenv("GPR_USER"))!!.toString()
password = (System.getenv("GPR_API_KEY"))!!.toString()
}
}
}
}
}
}
subprojects {
apply(plugin = "maven-publish")
// apply(plugin = "com.vanniktech.maven.publish")
// apply(plugin = "org.jetbrains.dokka")
apply(plugin = "me.tylerbwong.gradle.metalava")
//apply(plugin = "com.diffplug.spotless")
//spotless {
//kotlin {
// target("**/*.kt")
// ktlint("0.40.0")
// licenseHeader(rootProject.file("spotless/copyright.txt").absolutePath)
//}
//kotlinGradle {
// target("**/*.gradle.kts")
// ktlint("0.40.0")
// licenseHeader(rootProject.file("spotless/copyright.txt").absolutePath, "(buildscript|apply|import|plugins)")
//}
//}
this.group = "com.qawaz.accompanist"
this.version = property("lib.version") as String
tasks.withType<KotlinCompile> {
kotlinOptions {
// Treat all Kotlin warnings as errors
allWarningsAsErrors = true
}
}
plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}
}
// Read in the signing.properties file if it is exists
// val signingPropsFile = rootProject.file("release/signing.properties")
// if (signingPropsFile.exists()) {
// Properties().apply {
// signingPropsFile.inputStream().use {
// load(it)
// }
// }.forEach { key1, value1 ->
// val key = key1.toString()
// val value = value1.toString()
// if (key == "signing.secretKeyRingFile") {
// // If this is the key ring, treat it as a relative path
// project.ext.set(key, rootProject.file(value).absolutePath)
// } else {
// project.ext.set(key, value)
// }
// }
// }
// tasks.named<DokkaTaskPartial>("dokkaHtmlPartial") {
// dokkaSourceSets.configureEach {
// reportUndocumented.set(true)
// skipEmptyPackages.set(true)
// skipDeprecated.set(true)
// jdkVersion.set(11)
//
// // Add Android SDK packages
// noAndroidSdkLink.set(false)
//
// // Add samples from :sample module
// //samples.from(rootProject.file("sample/src/main/java/"))
//
// // AndroidX + Compose docs
// externalDocumentationLink {
// url.set(URL("https://developer.android.com/reference/"))
// packageListUrl.set(URL("https://developer.android.com/reference/androidx/package-list"))
// }
// externalDocumentationLink {
// url.set(URL("https://developer.android.com/reference/kotlin/"))
// packageListUrl.set(URL("https://developer.android.com/reference/kotlin/androidx/package-list"))
// }
//
// sourceLink {
// localDirectory.set(project.file("src/commonMain/kotlin"))
// // URL showing where the source code can be accessed through the web browser
// remoteUrl.set(URL("https://github.com/Syer10/accompanist/blob/main/${project.name}/src/"))
// // Suffix which is used to append the line number to the URL. Use #L for GitHub
// remoteLineSuffix.set("#L")
// }
// }
// }
plugins.withType<com.android.build.gradle.BasePlugin> {
configure<com.android.build.gradle.BaseExtension> {
compileSdkVersion(33)
defaultConfig {
minSdk = 21
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility(JavaVersion.VERSION_11)
targetCompatibility(JavaVersion.VERSION_11)
}
sourceSets {
named("main") {
val altManifest = file("src/androidMain/AndroidManifest.xml")
if (altManifest.exists()) {
manifest.srcFile(altManifest.path)
}
}
}
}
}
plugins.withType<me.tylerbwong.gradle.metalava.plugin.MetalavaPlugin> {
configure<me.tylerbwong.gradle.metalava.extension.MetalavaExtension> {
filename = "api/current.api"
reportLintsAsErrors = true
}
}
// Must be afterEvaluate or else com.vanniktech.maven.publish will overwrite our
// dokka and version configuration.
afterEvaluate {
/*
val composeSnapshot = libs.versions.composesnapshot.get()
if (composeSnapshot.length() > 1) {
// We"re depending on a Jetpack Compose snapshot, update the library version name
// to indicate it"s from a Compose snapshot
val versionName = project.properties.get("VERSION_NAME")
if (versionName.contains("SNAPSHOT")) = {
version = versionName.replace("-SNAPSHOT", = ".compose-${composeSnapshot}-SNAPSHOT")
}
}*/
if (!version.toString().endsWith("SNAPSHOT")) {
// If we"re not a SNAPSHOT library version, we fail the build if we"re relying on
// any snapshot dependencies
configurations.configureEach {
dependencies.configureEach a@{
if (this is ProjectDependency) return@a
val depVersion = this.version
if (depVersion != null && depVersion.endsWith("SNAPSHOT")) {
throw IllegalArgumentException(
"Using SNAPSHOT dependency with non-SNAPSHOT library version: $this"
)
}
}
}
}
}
}