/
build.gradle
134 lines (126 loc) · 4.67 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
apply plugin: 'com.android.application'
if (project.hasProperty('PLAY_STORE_SERVICE_ACCOUNT_CREDENTIALS')) {
apply plugin: 'com.github.triplet.play'
}
// commit number is only relevant to the application project
def gitCommitNo = { ref ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', ref
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
}
android {
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
defaultConfig {
applicationId "org.dmfs.tasks"
minSdkVersion MIN_SDK_VERSION.toInteger()
targetSdkVersion TARGET_SDK_VERSION.toInteger()
// spread version code to allow inserting versions if necessary
versionCode gitCommitNo('refs/remotes/origin/master') * 99 + gitCommitNo('HEAD') + Integer.parseInt(VERSION_OVERRIDE)
versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
if (project.hasProperty("DMFS_RELEASE_KEYSTORE")) {
signingConfigs {
release {
storeFile file(DMFS_RELEASE_KEYSTORE)
storePassword DMFS_RELEASE_KEYSTORE_PASSWORD
keyAlias DMFS_RELEASE_KEY_ALIAS
keyPassword DMFS_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
if (project.hasProperty("DMFS_RELEASE_KEYSTORE")) {
signingConfig signingConfigs.release
}
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
productFlavors {
}
lintOptions {
disable 'MissingTranslation' // TODO
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':opentasks-theme')
implementation project(':opentasks-provider')
implementation deps.support_appcompat
implementation deps.support_design
implementation(deps.xml_magic) {
// xmlpull is part of the runtime, so don't pull it in here
exclude group: 'xmlpull', module: 'xmlpull'
}
implementation deps.android_dashclock
implementation deps.color_picker
implementation(deps.codeka_carrot) {
exclude module: 'iterators' // TODO Remove when iterators have been removed from codeka:carrot
}
implementation(deps.android_carrot) {
exclude module: 'carrot'
exclude module: 'iterators'
exclude module: 'jems'
}
implementation deps.jems
implementation deps.datetime
implementation deps.bolts_color
implementation deps.retention_magic
testImplementation deps.junit
testImplementation deps.robolectric
testImplementation deps.jems_testing
androidTestImplementation deps.support_test_runner
androidTestImplementation deps.support_test_rules
implementation project(path: ':opentaskspal')
}
if (project.hasProperty('PLAY_STORE_SERVICE_ACCOUNT_CREDENTIALS')) {
play {
serviceAccountCredentials = file(PLAY_STORE_SERVICE_ACCOUNT_CREDENTIALS)
// the track is determined automatically by the version number format
switch (version) {
case ~/^(\d+)(\.\d+)*(-\d+-[\w\d]+)?-dirty$/:
// work in progress goes to the internal track
track = "internal"
break
case ~/^(\d+)(\.\d+)*-\d+-[\w\d]+$/:
// untagged commits go to alpha
track = "alpha"
break
case ~/^(\d+)(\.\d+)*$/:
// tagged commits to go beta, from where they get promoted to releases
track = "beta"
break
default:
throw new IllegalArgumentException("Unrecognized version format")
}
}
}
task postVersion {
doLast {
if (project.hasProperty('OPENTASKS_API_KEY')) {
// publish version number on api.opentasks.app
((HttpURLConnection) new URL('https://opentasks-app.appspot.com/v1/app/latest_version/').openConnection()).with({
requestMethod = 'POST'
doOutput = true
setRequestProperty('Content-Type', 'application/x-www-form-urlencoded')
setRequestProperty('Authorization', "Token token=\"${OPENTASKS_API_KEY}\"")
outputStream.withPrintWriter({ printWriter ->
printWriter.write("version_code=${project.android.defaultConfig.versionCode}&version_name=${project.android.defaultConfig.versionName}")
})
content
})
}
}
}