-
Notifications
You must be signed in to change notification settings - Fork 258
/
settings.gradle.kts
90 lines (81 loc) · 2.95 KB
/
settings.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
import java.util.Properties
/*
* Copyright 2022 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.
*/
pluginManagement {
includeBuild("build-logic")
repositories {
google()
mavenCentral()
gradlePluginPortal()
// Uncomment this to use a snapshot version of casa-android.
// maven("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Uncomment this to use a snapshot version of casa-android.
// maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven {
url = uri("https://androidx.dev/snapshots/builds/11809947/artifacts/repository")
}
}
}
rootProject.name = "Platform Samples"
include(":app")
// Define the samples to load
var samples = emptyList<String>()
// If the local.properties define specific samples use those only
val propertiesFile = file("local.properties")
if (propertiesFile.exists()) {
val properties = Properties()
properties.load(propertiesFile.inputStream())
if (properties.containsKey("target.samples")) {
// Specify the sample module name (e.g :samples:privacy:permissions) or comma separated ones
samples = listOf(":samples:base") + properties["target.samples"].toString().split(",")
}
}
// Dynamically include samples under /app-catalog/samples/ folder if no target.samples were defined
if (samples.isEmpty()) {
samples = buildList {
val separator = File.separator
// Find all build.gradle files under samples folder
settingsDir.walk()
.filter { it.name == "build.gradle" || it.name == "build.gradle.kts" }
.filter {
val relativePath = if (it.isAbsolute) {
it.path.substring(settingsDir.path.length)
} else {
it.path
}
relativePath.contains("${separator}samples${separator}")
}
.map { it.parent.substring(rootDir.path.length) }
.forEach {
add(it.replace(separator, ":"))
}
}
}
// include all available samples and store it in :app project extras.
println("Included samples: $samples")
include(*samples.toTypedArray())
gradle.beforeProject {
if (name == "app") {
extra["samples"] = samples
}
}