-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathsettings.gradle
198 lines (175 loc) · 7.26 KB
/
settings.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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
pluginManagement {
repositories {
google()
gradlePluginPortal()
maven {
url = uri("https://a8c-libs.s3.amazonaws.com/android")
content {
includeGroup "com.automattic.android"
includeGroup "com.automattic.android.measure-builds"
}
}
}
}
plugins {
id 'com.gradle.develocity' version '3.19'
}
ext {
USE_REMOTE_BUILD_CACHE_LOCALLY = "use_remote_build_cache_locally"
}
gradle.ext {
isCi = System.getenv('CI')?.toBoolean() ?: false
secretsPath = "${System.getProperty("user.home")}/.configure/woocommerce-android/secrets/secrets.properties"
secretProperties = loadPropertiesWithFallback(
logger,
file("${rootDir}/defaults.properties"),
file(secretsPath)
)
developerProperties = loadPropertiesWithFallback(
logger,
file("${rootDir}/developer.properties-example"),
file("${rootDir}/developer.properties")
)
}
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
}
buildCache {
if (gradle.ext.isCi) {
remote(HttpBuildCache) {
url = "http://10.0.2.214:5071/cache/"
allowUntrustedServer = true
allowInsecureProtocol = true
push = true
credentials {
username = "ci-user"
password = System.getenv('GRADLE_CACHE_NODE_PASSWORD')
}
}
} else if (gradle.ext.developerProperties.get(USE_REMOTE_BUILD_CACHE_LOCALLY).toBoolean() == true) {
checkForRemoteBuildCacheOptimizedExperience()
remote(HttpBuildCache) {
url = gradle.ext.secretProperties.get('gradleCacheNodeUrl')
push = false
credentials {
username = "developer"
password = gradle.ext.secretProperties.get('gradleCacheNodePassword')
}
}
} else {
logger.warn("\nℹ️ Remote build cache is disabled. If you have stable internet connection, consider enabling it via `developer.properties`.")
}
}
def checkForRemoteBuildCacheOptimizedExperience() {
assertSecretsApplied()
checkDeveloperPropertiesMatchDefaults()
assertJava17Amazon()
}
def assertSecretsApplied() {
if (!file(gradle.ext.secretsPath).exists()) {
throw new GradleException("The build requested remote build cache, but secrets file is not found. Please run `bundle exec fastlane run configure_apply` to apply secrets.")
}
}
static boolean propertiesEqualIgnoringKey(Properties p1, Properties p2, String ignoredKey) {
p1.clone().tap { it.remove(ignoredKey) } == p2.clone().tap { it.remove(ignoredKey) }
}
def checkDeveloperPropertiesMatchDefaults() {
Properties defaultDeveloperProperties = readPropertiesFromFile(file("${rootDir}/developer.properties-example"))
if (!propertiesEqualIgnoringKey(defaultDeveloperProperties, gradle.ext.developerProperties, USE_REMOTE_BUILD_CACHE_LOCALLY)) {
def yellow = "\u001B[33m"
def reset = "\u001B[0m"
logger.warn("${yellow}The developer properties file does not match the default developer properties file. This will reduce efficiency of remote build cache.$reset")
}
}
boolean assertJava17Amazon() {
def version = System.getProperty("java.version")
def vendor = System.getProperty("java.vendor")
if (!(version.contains("17") && vendor.toLowerCase().contains("amazon"))) {
logger.error("Java version: $version, vendor: $vendor")
throw new GradleException("Java version is not 17 or vendor is not Amazon Corretto. This significantly reduces efficiency of remote build cache. Please set up the matching JDK.")
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()
maven {
url = 'https://a8c-libs.s3.amazonaws.com/android'
content {
includeGroup "org.wordpress"
includeGroup "org.wordpress.fluxc"
includeGroup "org.wordpress.fluxc.plugins"
includeGroup "org.wordpress.wellsql"
includeGroup "org.wordpress.mediapicker"
includeGroup "com.automattic"
includeGroup "com.automattic.tracks"
includeGroup "com.gravatar"
includeGroup "org.wordpress.aztec"
}
}
maven {
url = 'https://zendesk.jfrog.io/zendesk/repo'
content {
includeGroup "com.zendesk"
includeGroup "com.zendesk.belvedere2"
}
}
maven {
url = "https://a8c-libs.s3.amazonaws.com/android/jcenter-mirror"
content {
includeVersion "com.android.volley", "volley", "1.1.1"
includeVersion "com.google.android", "flexbox", "2.0.1"
includeVersion "com.jraska", "falcon", "2.1.1"
includeVersion "org.wordpress", "wellsql", "1.6.0"
includeVersion "org.wordpress", "wellsql-core", "1.6.0"
}
}
maven {
url = "https://jitpack.io"
content {
includeModule("com.github.wordpress-mobile.WordPress-Aztec-Android", "aztec")
includeModule("com.github.wordpress-mobile.WordPress-Aztec-Android", "glide-loader")
includeModule("com.github.chrisbanes", "PhotoView")
includeModule("com.github.PhilJay", "MPAndroidChart")
}
}
}
}
rootProject.name = 'WCAndroid'
include ':libs:commons', ':libs:cardreader', ':libs:apifaker'
include ':libs:fluxc', ':libs:fluxc-annotations', ':libs:fluxc-processor', ':libs:fluxc-plugin', ':libs:fluxc-tests'
include ':libs:login'
include ':WooCommerce', ':WooCommerce-Wear'
include ':libs:detektrules'
gradle.ext.fluxCBinaryPath = "org.wordpress:fluxc"
gradle.ext.fluxCWooCommercePluginBinaryPath = "org.wordpress.fluxc.plugins:woocommerce"
gradle.ext.loginFlowBinaryPath = "org.wordpress:login"
gradle.ext.mediaPickerBinaryPath = "org.wordpress:mediapicker"
gradle.ext.mediaPickerDomainBinaryPath = "org.wordpress.mediapicker:domain"
gradle.ext.mediaPickerSourceCameraBinaryPath = "org.wordpress.mediapicker:source-camera"
gradle.ext.mediaPickerSourceDeviceBinaryPath = "org.wordpress.mediapicker:source-device"
gradle.ext.mediaPickerSourceGifBinaryPath = "org.wordpress.mediapicker:source-gif"
gradle.ext.mediaPickerSourceWordPressBinaryPath = "org.wordpress.mediapicker:source-wordpress"
gradle.ext {
compileSdkVersion = 35
targetSdkVersion = 34
minSdkVersion = 26
}
apply from: './config/gradle/include_builds.gradle'
apply from: './config/gradle/gradle_build_scan.gradle'