-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle
196 lines (170 loc) · 6.37 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
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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import ca.rmen.lfrc.FrenchRevolutionaryCalendar
import java.text.SimpleDateFormat
ext.globalProjectName = 'bikey'
buildscript {
// Versions used across modules
ext.versions = [:]
ext.versions.with {
androidGradlePlugin = '2.4.0-alpha6'
gradleVersionsPlugin = '0.14.0'
fabricPlugin = '1.22.1'
dexCountPlugin = '0.6.4'
acpgPlugin = '1.13.1'
libFrc = '1.5.2'
compileSdk = 24
targetSdk = 22
buildTools = '25.0.2'
supportLibrary = '25.3.1'
playServices = '10.2.1'
espresso = '2.2.2'
junit = '4.12'
robolectric = '3.3.2'
fest = '2.0M10'
multidex = '1.0.1'
rxJava = '2.0.8'
rxAndroid = '2.0.1'
wearCrashReport = '0.6'
crashlytics = '2.6.7'
androidWearable = '2.0.1'
}
repositories {
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "com.android.tools.build:gradle:$versions.androidGradlePlugin"
classpath "com.github.ben-manes:gradle-versions-plugin:$versions.gradleVersionsPlugin"
classpath "ca.rmen:lib-french-revolutionary-calendar:$versions.libFrc"
classpath "io.fabric.tools:gradle:$versions.fabricPlugin"
classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:$versions.dexCountPlugin"
classpath "org.jraf:acpg-gradle-plugin:$versions.acpgPlugin"
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
// Force using our version of the support libraries, even for those we don't depend on directly (transitive dependencies)
configurations.all {
resolutionStrategy {
force "com.android.support:appcompat-v7:$versions.supportLibrary",
"com.android.support:cardview-v7:$versions.supportLibrary",
"com.android.support:customtabs:$versions.supportLibrary",
"com.android.support:support-v4:$versions.supportLibrary",
"com.android.support:support-annotations:$versions.supportLibrary",
"com.android.support:percent:$versions.supportLibrary",
"com.android.support:recyclerview-v7:$versions.supportLibrary"
}
}
// Show a report in the log when running tests
tasks.withType(Test) {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task wrapper(type: Wrapper) {
gradleVersion = '3.5'
distributionType = Wrapper.DistributionType.ALL
}
// Add a 'release' task that increments the build number
def releaseTask = tasks.create(name: 'release', group: 'build')
releaseTask.doLast {
buildNumberProperties.buildNumber = (buildNumber + 1).toString()
buildNumberProperties.store(buildNumberFile.newWriter(), null)
}
// Make the 'release' task depend on the 'assembleRelease' task of every subprojects
subprojects {
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease') {
releaseTask.dependsOn task
}
}
}
// Run './gradlew dependencyUpdates' to see new versions of dependencies
apply plugin: 'com.github.ben-manes.versions'
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { selection ->
boolean rejected = ['alpha', 'beta', 'rc', '20050927'].any { qualifier ->
selection.candidate.version ==~ /.*-${qualifier}.*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
// Returns the name of the current git branch
def gitBranch() {
new ProcessBuilder('git', "--git-dir=${rootDir}/.git", "--work-tree=${rootDir}", 'rev-parse', '--abbrev-ref', 'HEAD').start().text.trim()
}
// Returns the SHA1 of the current git commit
def gitSha1() {
new ProcessBuilder('git', "--git-dir=${rootDir}/.git", "--work-tree=${rootDir}", 'rev-parse', '--short', 'HEAD').start().text.trim()
}
// Returns the current date/time formatted in UTC
static def buildDate() {
def dateFormat = new SimpleDateFormat('yyyy-MM-dd\'T\'HH:mm\'Z\'')
dateFormat.setTimeZone(TimeZone.getTimeZone('UTC'))
return dateFormat.format(new Date())
}
// This only for amusement purposes
static def getFrenchDate() {
def frenchDate = new FrenchRevolutionaryCalendar(Locale.FRENCH, FrenchRevolutionaryCalendar.CalculationMethod.ROMME).getDate(GregorianCalendar.getInstance())
"Le ${frenchDate.weekdayName} ${frenchDate.dayOfMonth} ${frenchDate.monthName} de l'an ${frenchDate.year}. (${frenchDate.objectTypeName} du jour : ${frenchDate.dayOfYear})"
}
// Returns a file on the project's root - creates it from a sample if it doesn't exist
def getAndCreateIfNotExists(String fileName) {
def res = file(fileName)
if (!res.exists()) {
logger.warn("$fileName file does not exist: creating it now - please check its values")
copy {
from "${fileName}.SAMPLE"
into project.projectDir
rename { fileName }
}
}
return res
}
// Build properties
ext.buildProperties = new Properties()
def buildPropertiesFile = getAndCreateIfNotExists('build.properties')
buildProperties.load(new FileInputStream(buildPropertiesFile))
// Build number
ext.buildNumberProperties = new Properties()
ext.buildNumberFile = getAndCreateIfNotExists('build.number')
buildNumberProperties.load(new FileInputStream(buildNumberFile))
ext.buildNumber = buildNumberProperties.buildNumber.toInteger()
// Build info
ext.gitBranch = gitBranch()
ext.gitSha1 = gitSha1()
ext.buildDate = buildDate()
// Splash screen
println """\n
====================================\u001B[95m
_____ ___ ____
__ / / _ \\/ _ | / __/___ _______ _
/ // / , _/ __ |/ _/_/ _ \\/ __/ _ `/
\\___/_/¦_/_/ |_/_/ (_)___/_/ \\_, /
/___/
\u001B[0m
Building ${globalProjectName}.
${getFrenchDate()}
rootDir: ${rootDir}
buildDate: ${buildDate}
versionCode: ${buildNumberProperties.buildNumber}
versionName: ${buildProperties.versionName}
gitBranch: ${gitBranch}
gitSha1: ${gitSha1}
====================================
"""