-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
83 lines (75 loc) · 2.65 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath(libs.android.gradlePluginClasspath)
classpath(libs.kotlin.gradlePluginClasspath)
classpath(libs.gradleVersions.gradlePluginClasspath)
}
}
plugins {
id("com.autonomousapps.dependency-analysis") version "1.27.0"
}
allprojects {
repositories {
mavenLocal()
google()
mavenCentral()
// maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
// Gradle Dependency Check
apply(plugin = "com.github.ben-manes.versions") // ./gradlew dependencyUpdates -Drevision=release
val excludeVersionContaining = listOf("alpha", "eap") // example: "alpha", "beta"
val ignoreArtifacts = listOf("room-compiler", "room-runtime", "room-testing", "room-ktx") // some artifacts may be OK to check for "alpha"... add these exceptions here
tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
resolutionStrategy {
componentSelection {
all {
if (ignoreArtifacts.contains(candidate.module).not()) {
val rejected = excludeVersionContaining.any { qualifier ->
candidate.version.matches(Regex("(?i).*[.-]$qualifier[.\\d-+]*"))
}
if (rejected) {
reject("Release candidate")
}
}
}
}
}
}
}
// ===== Dependency Analysis =====
// ./gradlew projectHealth./gradlew projectHealth
dependencyAnalysis {
issues {
all {
onAny {
ignoreKtx(true)
severity("fail")
}
onUnusedDependencies {
exclude(
":jdbc",
depGroupAndName(libs.xerial.sqlite), // loaded by reflection in UnitTest
// depGroupAndName(libs.compose.ui.tooling), // Compose Previews
)
}
onUsedTransitiveDependencies { severity("ignore") }
onIncorrectConfiguration { severity("ignore") }
onCompileOnly { severity("ignore") }
onRuntimeOnly { severity("ignore") }
onUnusedAnnotationProcessors { }
}
}
}
fun depGroupAndName(dependency: Provider<MinimalExternalModuleDependency>): String {
return dependency.get().let { "${it.group}:${it.name}" }
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}