-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
build.gradle
111 lines (97 loc) · 3.46 KB
/
build.gradle
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
import com.automattic.android.measure.reporters.InternalA8cCiReporter
import com.automattic.android.measure.reporters.SlowSlowTasksMetricsReporter
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.automattic.measure.builds)
alias(libs.plugins.kotlinx.kover)
alias(libs.plugins.dependency.analysis)
alias(libs.plugins.androidx.navigation.safeargs).apply(false)
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.android.library).apply(false)
alias(libs.plugins.google.services).apply(false)
alias(libs.plugins.kotlin.allopen).apply(false)
alias(libs.plugins.kotlin.android).apply(false)
alias(libs.plugins.kotlin.compose).apply(false)
alias(libs.plugins.kotlin.jvm).apply(false)
alias(libs.plugins.kotlin.parcelize).apply(false)
alias(libs.plugins.kotlin.serialization).apply(false)
alias(libs.plugins.ksp).apply(false)
alias(libs.plugins.kapt).apply(false)
alias(libs.plugins.room).apply(false)
}
ext {
minSdkVersion = 26
compileSdkVersion = 34
targetSdkVersion = 34
secretProperties = loadSecrets(
logger,
file("${rootDir}/defaults.properties"),
file("${System.getProperty("user.home")}/.configure/wordpress-android/secrets/secrets.properties")
)
}
static def loadSecrets(Logger logger, File defaultsFile, File secretsFile) {
if (secretsFile.exists()) {
return loadPropertiesFromFile(secretsFile)
} else {
logger.warn("Secrets file not found. Using defaults.")
return loadPropertiesFromFile(defaultsFile)
}
}
static def loadPropertiesFromFile(File inputFile) {
def properties = new Properties()
inputFile.withInputStream { stream ->
properties.load(stream)
}
return properties
}
measureBuilds {
enable = secretProperties.get('measureBuildsEnabled')?.toBoolean() ?: false
onBuildMetricsReadyListener { report ->
SlowSlowTasksMetricsReporter.report(report)
InternalA8cCiReporter.reportBlocking(
report,
"wordpress",
secretProperties.get('appsMetricsToken')
)
}
attachGradleScanId = gradle.ext.isCi
}
allprojects {
apply plugin: libs.plugins.checkstyle.get().pluginId
apply plugin: libs.plugins.detekt.get().pluginId
tasks.register("checkstyle", Checkstyle) {
source 'src'
classpath = files()
}
checkstyle {
toolVersion = libs.plugins.checkstyle.get().version
configFile file("${project.rootDir}/config/checkstyle.xml")
}
detekt {
toolVersion = libs.plugins.detekt.get().version
baseline = file("${project.rootDir}/config/detekt/baseline.xml")
config = files("${project.rootDir}/config/detekt/detekt.yml")
autoCorrect = false
buildUponDefaultConfig = true
disableDefaultRuleSets = false
ignoreFailures = false
parallel = true
debug = false
}
tasks.withType(KotlinCompile).all {
kotlinOptions {
jvmTarget = JvmTarget.fromTarget(libs.versions.java.get()).target
allWarningsAsErrors = true
freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn",
"-Xjvm-default=all"
]
}
}
}
dependencies {
detektPlugins(libs.detekt.formatting)
}
apply from: './config/gradle/code_coverage.gradle'