forked from mullvad/mullvadvpn-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
144 lines (125 loc) · 5.44 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
144 lines (125 loc) · 5.44 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
142
143
144
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import dev.detekt.gradle.Detekt
import dev.detekt.gradle.DetektCreateBaselineTask
import utilities.PreBuildTask
import utilities.appVersionProvider
import utilities.isNonStableVersion
import utilities.isReleaseBuild
plugins {
alias(libs.plugins.mullvad.utilities)
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.ktfmt) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.play.publisher) apply false
alias(libs.plugins.kotlin.ksp) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.protobuf.core) apply false
alias(libs.plugins.rust.android) apply false
alias(libs.plugins.detekt) apply true
alias(libs.plugins.dependency.versions) apply true
alias(libs.plugins.baselineprofile) apply false
}
buildscript {
dependencies {
//noinspection UseTomlInstead
// Dependency class paths are required for Gradle metadata verification to work properly,
// see:
// https://github.com/gradle/gradle/issues/19228
if (gradle.startParameter.writeDependencyVerifications.isNotEmpty()) {
println("Writing dependency verification file, adding platform specific classpaths")
val aapt = libs.android.gradle.aapt.get()
val aaptVersion =
"${libs.versions.android.gradle.plugin.get()}-${libs.versions.android.gradle.aapt.get()}"
classpath("$aapt:$aaptVersion:linux")
classpath("$aapt:$aaptVersion:osx")
classpath("$aapt:$aaptVersion:windows")
// Protoc plugin
val protoc = libs.plugins.protobuf.protoc.get().toString()
classpath("$protoc:linux-aarch_64@exe")
classpath("$protoc:linux-ppcle_64@exe")
classpath("$protoc:linux-s390_64@exe")
classpath("$protoc:linux-x86_32@exe")
classpath("$protoc:linux-x86_64@exe")
classpath("$protoc:osx-aarch_64@exe")
classpath("$protoc:osx-x86_64@exe")
classpath("$protoc:windows-x86_32@exe")
classpath("$protoc:windows-x86_64@exe")
// ProtoC gen grpc java plugin
val protocJava = libs.plugins.grpc.protoc.gen.grpc.java.get().toString()
classpath("$protocJava:linux-aarch_64@exe")
classpath("$protocJava:linux-ppcle_64@exe")
classpath("$protocJava:linux-s390_64@exe")
classpath("$protocJava:linux-x86_32@exe")
classpath("$protocJava:linux-x86_64@exe")
classpath("$protocJava:osx-aarch_64@exe")
classpath("$protocJava:osx-x86_64@exe")
classpath("$protocJava:windows-x86_32@exe")
classpath("$protocJava:windows-x86_64@exe")
// Kotlin Native Prebuilt
val prebuilt = libs.kotlin.native.prebuilt.get().toString()
classpath("$prebuilt:windows-x86_64@zip")
classpath("$prebuilt:linux-x86_64@tar.gz")
classpath("$prebuilt:macos-aarch64@tar.gz")
classpath("$prebuilt:macos-x86_64@tar.gz")
}
}
}
detekt {
val baselineFile = file("$rootDir/config/detekt-baseline.xml")
val configFile = files("$rootDir/config/detekt.yml")
val projectSource = file(projectDir)
buildUponDefaultConfig = true
allRules = false
config.setFrom(configFile)
source.setFrom(projectSource)
parallel = true
ignoreFailures = false
autoCorrect = true
baseline = baselineFile
dependencies { detektPlugins(project(":test:detekt")) }
}
val detektExcludedPaths =
listOf("**/build/**", "**/mullvad_daemon/management_interface/**", ".gradle/**")
tasks.withType<Detekt>().configureEach {
dependsOn(":test:detekt:assemble")
// Ignore generated files from the build directory, e.g files created by ksp.
exclude(detektExcludedPaths)
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
// Ignore generated files from the build directory, e.g files created by ksp.
exclude(detektExcludedPaths)
}
allprojects {
apply(plugin = rootProject.libs.plugins.ktfmt.get().pluginId)
// Should be the same as ktfmt config in buildSrc/build.gradle.kts
configure<com.ncorti.ktfmt.gradle.KtfmtExtension> {
kotlinLangStyle()
maxWidth.set(100)
removeUnusedImports.set(true)
}
}
tasks.withType<DependencyUpdatesTask> {
gradleReleaseChannel = "current"
rejectVersionIf { candidate.version.isNonStableVersion() }
}
tasks.register("clean", Delete::class) { delete(rootProject.layout.buildDirectory) }
// The preflight configuration is done at the project root level to ensure
// it runs before any other build tasks. This is a known limitation:
// https://github.com/gradle/gradle/issues/29064
//
// The substringAfterLast split is used in order to catch both the plain
// and fully qualified task names ("fdroidRelease" and ":app:fdroidRelease").
val preflightSkipDirtyCheck =
gradle.startParameter.taskNames.any { it.substringAfterLast(':') == "fdroidRelease" }
val releasePreflight =
tasks.register<PreBuildTask>("releasePreflight") {
this.skipDirtyCheck.set(preflightSkipDirtyCheck)
this.versionName.set(appVersionProvider.map { it.name })
}
if (isReleaseBuild()) {
allprojects {
tasks.configureEach { if (name != "releasePreflight") dependsOn(releasePreflight) }
}
}