-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
145 lines (124 loc) · 3.97 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
object Constants {
val javaVersion = JavaVersion.VERSION_11
const val group = "com.well"
const val version = "1.0-SNAPSHOT"
}
group = Constants.group
version = Constants.version
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
addSnapshots(::uri, project)
}
apply(from = "dependencies.gradle")
val libs: List<String> = project.libsAt("build")
dependencies {
libs.forEach { classpath(it) }
}
}
repositories {
mavenCentral()
}
plugins {
id("com.gradleup.auto.manifest") version "2.0"
}
autoManifest {
packageName.set(Constants.group)
applyRecursively.set(true)
}
allprojects {
@Suppress("UnstableApiUsage")
repositories {
// still needed for webrtc
@Suppress("JcenterRepositoryObsolete", "DEPRECATION")
jcenter()
google()
mavenCentral()
addSnapshots(::uri, project)
exclusiveContent {
forRepository {
google()
}
filter {
includeGroupByRegex("androidx\\..+")
includeGroupByRegex("com.android.*")
includeGroupByRegex("com.google.android.+")
}
}
}
apply(from = "${rootDir}/dependencies.gradle")
}
apply(from = "${rootDir}/androidPluginsSetup.gradle.kts")
subprojects {
group = Constants.group
version = Constants.version
plugins.withType<org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper> {
tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = Constants.javaVersion.toString()
}
}
}
}
}
apply(from = "${rootDir}/dependencies.gradle")
}
subprojectsConfigurationsResolutionStrategy(ResolutionStrategy.Kotlin, ResolutionStrategy.Coroutines)
// ./gradlew -q -PallDepsNeeded=1 allDeps > deps.txt && open deps.txt
val allDepsNeeded: String? by project
if (allDepsNeeded != null) {
subprojects {
tasks.create<DependencyReportTask>("allDeps") {
}
}
}
// ./gradlew -q -PdiktatNeeded=1 diktatFix --stacktrace
//val diktatNeeded: String? by project
//if (diktatNeeded != null) {
// apply(plugin = "com.github.ben-manes.versions") {
// version = "0.1.5"
// }
// diktat {
// inputs = files("androidApp/**/*.kt")
// }
//}
// ./gradlew -q -PdependencyUpdatesNeeded=1 dependencyUpdates
val dependencyUpdatesNeeded: String? by project
if (dependencyUpdatesNeeded != null) {
apply(plugin = "com.github.ben-manes.versions")
fun isNonStable(version: String): Boolean {
val stableKeyword =
listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.named("dependencyUpdates", com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class.java).configure {
// Example 1: reject all non stable versions
rejectVersionIf {
isNonStable(candidate.version)
}
// Example 2: disallow release candidates as upgradable versions from stable versions
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
// Example 3: using the full syntax
resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}
checkForGradleUpdate = true
outputFormatter = "json"
outputDir = "build/dependencyUpdates"
reportfileName = "report"
}
}