-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
47 lines (43 loc) · 1.45 KB
/
build.gradle
File metadata and controls
47 lines (43 loc) · 1.45 KB
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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.novoda:gradle-android-command-plugin:1.4.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
void bumpVersionCodeInFile(File file) {
def text = file.text
def matcher = (text =~ /versionCode ([0-9]+)/)
if (matcher.size() != 1 || !matcher.hasGroup()) {
throw new GradleException("Could not find versionCode in app/build.gradle")
}
def String versionCodeStr = matcher[0][1]
def versionCode = Integer.valueOf(versionCodeStr)
def newVersionCode = versionCode + 1
def newContent = matcher.replaceFirst("versionCode " + newVersionCode)
file.write(newContent)
}
task('bumpVersionCode') << {
def appGradleFile = file('app/build.gradle')
if (appGradleFile.canRead()) {
bumpVersionCodeInFile(appGradleFile)
} else {
throw new GradleException("Could not read app/build.gradle");
}
def wearGradleFile = file('wear/build.gradle')
if (wearGradleFile.canRead()) {
bumpVersionCodeInFile(wearGradleFile)
}
// No exception here since projects are not required to have a wearable app
}