-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
160 lines (139 loc) · 6.52 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
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
///////////////////////////////////////////////////////////////////////////////
// Setup necessary imports
///////////////////////////////////////////////////////////////////////////////
import groovy.json.JsonSlurper
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Setup Gradle
///////////////////////////////////////////////////////////////////////////////
buildscript {
// Setup necessary repositories to get third party dependencies
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.google.com' }
maven { url = 'https://repo1.maven.org/maven2/' }
maven { url = 'https://plugins.gradle.org/m2/'}
maven { url = 'https://jitpack.io' }
}
// This block encapsulates custom properties and makes them available to all
// modules in the project.
ext {
systemTestType = System.getProperty('testType', 'debug')
final def customAbiFilters = System.getProperty('abiFilters', '["x86","x86_64"]')
systemAbiFilters = new JsonSlurper().parseText(customAbiFilters) as String[]
// The default minimum Android API version possible is 14 due to compatibility with Appcompat dependency.
androidApiVersion = System.getProperty('androidApiVersion', '14')
final def androidApiVersionArray = androidApiVersion.split("\\.").collect()
androidApiVersionValue = androidApiVersionArray[0] as Float
if (androidApiVersionValue >= 21) {
androidX_appcompat_version = '1.7.0'
ndk_version = '27.2.12479018'
}
if (androidApiVersionValue >= 19) {
androidX_test_junit_version = '1.2.1'
androidX_test_runner_version = '1.6.1'
androidX_test_espresso_version = '3.6.1'
androidX_tracing_version = '1.2.0'
if (project.properties["ndk_version"] == null) {
ndk_version = '25.2.9519653'
}
}
if (androidApiVersionValue >= 16) {
gradle_version = '8.8.0'
} else {
gradle_version = '8.2.2'
}
if (project.properties["androidX_test_espresso_version"] == null) {
androidX_test_espresso_version = '3.5.1'
}
if (project.properties["androidX_test_junit_version"] == null) {
androidX_test_junit_version = '1.1.5'
}
if (project.properties["androidX_test_runner_version"] == null) {
androidX_test_runner_version = '1.5.2'
}
if (project.properties["androidX_appcompat_version"] == null) {
androidX_appcompat_version = '1.6.1'
}
if (project.properties["ndk_version"] == null) {
ndk_version = '23.2.8568313'
}
if (project.properties["androidX_tracing_version"] == null) {
androidX_tracing_version = '1.1.0'
}
final def gradleVersionArray = gradle_version.split("\\.").collect()
gradleVersionValue = gradleVersionArray[0] + '.' + gradleVersionArray[1] as Float
// Test dependencies
jacoco_version = '0.8.12'
// Unit tests dependencies
powermock_version = '2.0.9'
}
dependencies {
final def currentOS = System.getProperty("os.name")
println("OS: " + currentOS)
// Compatibility matrix: https://developer.android.com/build/releases/gradle-plugin#android_gradle_plugin_and_android_studio_compatibility
classpath "com.android.tools.build:gradle:${gradle_version}"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:6.0.1.5171'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.51.0'
/* To confirm JaCoCo version run: $ sh gradlew buildEnvironment */
/* Resolves issue of incorrect version use in one of jacoco/android plugin inner tasks */
classpath "org.jacoco:org.jacoco.core:${jacoco_version}"
classpath "org.jacoco:org.jacoco.report:${jacoco_version}"
classpath "org.jacoco:org.jacoco.agent:${jacoco_version}"
// Required for sonarqube-gradle-plugin:v6
classpath 'org.bouncycastle:bcutil-jdk18on:1.80'
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Setup necessary repositories to get third party dependencies
///////////////////////////////////////////////////////////////////////////////
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.google.com' }
maven { url = 'https://mvnrepository.com' }
maven { url = 'https://dl.google.com/dl/android/maven2/' }
maven { url = 'https://plugins.gradle.org/m2/'}
maven { url = 'https://jitpack.io' }
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Allow to use different versions of Gradle depending on the Android API version
///////////////////////////////////////////////////////////////////////////////
tasks.named('wrapper', Wrapper) {it ->
println('Setting Gradle wrapper version')
it.distributionType = Wrapper.DistributionType.BIN
if (androidApiVersionValue >= 16) {
it.gradleVersion = '8.12'
} else {
it.gradleVersion = '8.7'
}
var urlPrefix = 'https://services.gradle.org/distributions/'
it.distributionUrl = urlPrefix + 'gradle-' + it.gradleVersion + '-' + it.distributionType.name().toLowerCase() + '.zip'
println('Gradle wrapper version: ' + it.gradleVersion)
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.google.com' }
maven { url = 'https://mvnrepository.com' }
maven { url = 'https://dl.google.com/dl/android/maven2/' }
maven { url = 'https://plugins.gradle.org/m2/'}
maven { url = 'https://jitpack.io' }
}