-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathbuild.gradle
116 lines (102 loc) · 3.74 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
112
113
114
115
116
import com.automattic.android.measure.MeasureBuildsExtension
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.automattic.measure.builds)
alias(libs.plugins.dependency.analysis)
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose).apply(false)
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.google.dagger.hilt) apply false
alias(libs.plugins.androidx.navigation.safeargs) apply false
alias(libs.plugins.google.services) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.room) apply false
}
ext {
secretProperties = loadPropertiesWithFallback(
logger,
file("${rootDir}/defaults.properties"),
file("${System.getProperty("user.home")}/.configure/woocommerce-android/secrets/secrets.properties")
)
developerProperties = loadPropertiesWithFallback(
logger,
file("${rootDir}/developer.properties-example"),
file("${rootDir}/developer.properties")
)
}
measureBuilds {
enable = secretProperties.get('measureBuildsEnabled')?.toBoolean() ?: false
automatticProject = MeasureBuildsExtension.AutomatticProject.WooCommerce
attachGradleScanId = false
authToken = secretProperties.get('appsMetricsToken')
}
static def loadPropertiesWithFallback(Logger logger, File fallbackFile, File primaryFile) {
def defaultProperties = readPropertiesFromFile(fallbackFile)
def primaryProperties
if (primaryFile.exists()) {
primaryProperties = readPropertiesFromFile(primaryFile)
} else {
logger.warn("Primary properties file not found: ${primaryFile}. Using fallback: ${fallbackFile}.")
primaryProperties = new Properties()
}
return defaultProperties + primaryProperties
}
static def readPropertiesFromFile(File file) {
def properties = new Properties()
file.withInputStream { stream ->
properties.load(stream)
}
return properties
}
allprojects {
apply plugin: libs.plugins.detekt.get().pluginId
tasks.withType(KotlinCompile).all {
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = true
freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn",
"-Xjvm-default=all-compatibility",
]
}
}
}
tasks.register("detektAll", Detekt) {
description = "Custom DETEKT build for all modules"
parallel = true
ignoreFailures = false
buildUponDefaultConfig = true
setSource(file(projectDir))
baseline.set(file("$rootDir/config/detekt/baseline.xml"))
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
include("**/*.kt")
exclude("**/resources/**", "**/build/**", "/vendor/**")
reports {
xml.required.set(true)
html.required.set(true)
txt.required.set(false)
}
}
dependencies {
detektPlugins(libs.detekt.formatting)
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
/**
* Copies git-hooks from the `tools/team-props/git-hooks' directory to the `.git/hooks` folder
* at the root of this project.
*/
tasks.register("installGitHooks", Copy) {
println "Copying git-hooks scripts from tools/team-props/git-hooks to .git/hooks"
from new File(rootProject.rootDir, 'tools/team-props/git-hooks')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
apply from: './config/gradle/jacoco.gradle'