-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
141 lines (131 loc) · 5.79 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
141 lines (131 loc) · 5.79 KB
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
/*
* Copyright 2022-2026 Leonard Lemke
*
* 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.
*/
import com.android.build.api.dsl.CommonExtension
import java.util.Properties
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.detekt) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.kover) apply false
alias(libs.plugins.android.junit) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.baselineprofile) apply false
alias(libs.plugins.roborazzi) apply false
alias(libs.plugins.dependency.analysis)
}
spotless {
kotlinGradle {
target(
fileTree(rootDir) {
include("**/*.gradle.kts")
exclude("**/build/**", "**/.gradle/**")
},
)
licenseHeaderFile(rootProject.file("config/spotless/apache-2.0.kt"), "(^(?![\\/ ]\\*).*$)")
ktlint(libs.versions.ktlint.get())
}
}
/**
* Converts a camelCase or mixedCase string to ENV_VAR_STYLE (uppercase with underscores).
* Example: githubAccessToken -> GITHUB_ACCESS_TOKEN
*/
fun String.toEnvVarStyle(): String = replace(Regex("([a-z])([A-Z])"), "$1_$2").uppercase()
/**
* Note: To configure GitHub credentials, you have to generate an access token with at least `read:packages` scope at
* https://github.com/settings/tokens/new and then add it to any of the following:
*
* - Add `ghUsername` and `ghAccessToken` to Global Gradle Properties
* - Set `GH_USERNAME` and `GH_ACCESS_TOKEN` in your environment variables or
* - Create a `github.properties` file in your project folder with the following content:
* ghUsername=<YOUR_GITHUB_USERNAME>
* ghAccessToken=<YOUR_GITHUB_ACCESS_TOKEN>
*/
fun getProperty(key: String): String =
Properties()
.apply {
rootProject
.file("github.properties")
.takeIf { it.exists() }
?.inputStream()
?.use { load(it) }
}.getProperty(key)
?: rootProject.findProperty(key)?.toString()
?: System.getenv(key.toEnvVarStyle())
?: throw GradleException("Property $key not found")
val githubUsername = getProperty("ghUsername")
val githubAccessToken = getProperty("ghAccessToken")
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
maven("https://maven.pkg.github.com/tribalfs/oneui-design") {
credentials {
username = githubUsername
password = githubAccessToken
}
}
maven("https://maven.pkg.github.com/lemkinator/common-utils") {
credentials {
username = githubUsername
password = githubAccessToken
}
}
}
}
subprojects {
plugins.withId("com.android.base") {
project.extensions.findByType(CommonExtension::class.java)?.apply {
compileOptions.apply {
sourceCompatibility = JavaVersion.toVersion(libs.versions.jvmTarget.get())
targetCompatibility = JavaVersion.toVersion(libs.versions.jvmTarget.get())
}
@Suppress("UnstableApiUsage")
testOptions.managedDevices.localDevices {
register("pixel9Api35") {
device = "Pixel 9"
apiLevel = 35
systemImageSource = "aosp"
testedAbi = "x86_64"
}
}
// oneui-design replaces these AOSP AndroidX modules with Samsung forks; exclude them from
// com.android.application modules' non-test configs to prevent shadowing. androidTest is
// exempt — it needs real SESL (via :app's transitive deps) to launch SESL activities that
// call SESL-specific methods. com.android.test modules (e.g. :benchmarks) aren't matched
// and keep genuine AOSP AndroidX.
plugins.withId("com.android.application") {
configurations.matching { !it.name.startsWith("test", ignoreCase = true) }.configureEach {
exclude(group = "androidx.core", module = "core")
exclude(group = "androidx.core", module = "core-ktx")
exclude(group = "androidx.customview", module = "customview")
exclude(group = "androidx.coordinatorlayout", module = "coordinatorlayout")
exclude(group = "androidx.drawerlayout", module = "drawerlayout")
exclude(group = "androidx.viewpager2", module = "viewpager2")
exclude(group = "androidx.viewpager", module = "viewpager")
exclude(group = "androidx.appcompat", module = "appcompat")
exclude(group = "androidx.fragment", module = "fragment")
exclude(group = "androidx.preference", module = "preference")
exclude(group = "androidx.recyclerview", module = "recyclerview")
exclude(group = "androidx.slidingpanelayout", module = "slidingpanelayout")
exclude(group = "androidx.swiperefreshlayout", module = "swiperefreshlayout")
exclude(group = "com.google.android.material", module = "material")
}
}
}
}
}