forked from mpcjanssen/simpletask-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
164 lines (140 loc) · 5.12 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'com.android.application'
sourceSets {
unitTest {
java.srcDir file('src/test/java')
resources.srcDir file('src/test/resources')
}
}
dependencies {
unitTestCompile files("$project.buildDir/intermediates/classes/cloudless/debug")
unitTestCompile fileTree(dir: 'libskeep', include: '*.jar')
unitTestCompile 'com.darwinsys:hirondelle-date4j:1.5.1'
unitTestCompile 'com.google.guava:guava:17.0'
unitTestCompile 'com.google.android:android:4.+'
unitTestCompile 'junit:junit:4.11'
unitTestCompile 'org.mozilla:rhino:1.7R4'
}
configurations {
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}
task unitTest(type:Test, dependsOn: assemble) {
description = "run unit tests"
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath + files("$project.buildDir/intermediates/classes/cloudless/debug")
}
// Generate some build info. Used for the revision in the application settings and for generating the deployed file names.
task buildInfo {
def revcmd = "git rev-parse --short HEAD"
def revproc = revcmd.execute()
ext.revision = revproc.text.trim()
def datecmd = "git log -1 --date=short --pretty=format:%cd"
def dateproc = datecmd.execute()
ext.date = dateproc.text.trim()
def branchcmd = 'git rev-parse --abbrev-ref HEAD'
def branchproc = branchcmd.execute()
ext.branch = branchproc.text.trim()
}
// Check if all changes are commited to Git. If not throw an exception.
// This is called before deploying apk's. It will ensure that the Git revision numbers in the apk names
// and in the app settings are accurate. If there were uncommited changes, the result would be different from
// a clean checkout.
task checkCleanGit {
def cmd = "git diff-files"
def proc = cmd.execute()
ext.status = proc.text.trim()
doLast {
if (!(ext.status == ""))
throw new GradleException("Git not clean, commit changes before running serve:\n" + ext.status)
}
}
def checkDeployPath() {
if (hasProperty("deployPath"))
return deployPath
else
return null
}
task deploy(type:Copy, dependsOn: [assembleRelease,buildInfo,checkCleanGit]) {
doFirst {
if (checkDeployPath()==null)
throw new GradleException("deployPath not defined, please define it in gradle.properties")
}
from 'build/outputs/apk/'
into checkDeployPath() + '/' + buildInfo.ext.branch + '/' + buildInfo.ext.date + "-" + buildInfo.ext.revision
include '*release.apk'
rename 'simpletask-android-free-release.apk', 'simpletask-free-' + buildInfo.ext.date + "-" + buildInfo.ext.revision + '.apk'
rename 'simpletask-android-cloudless-release.apk', 'simpletask-cloudless-' + buildInfo.ext.date + "-" + buildInfo.ext.revision + '.apk'
}
// Call gradle with -Plint to enable all warnings.
if (hasProperty("lint")) {
tasks.withType(Compile) {
options.compilerArgs << "-Xlint:all"
}
}
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
buildToolsVersion "20.0.0"
compileSdkVersion 20
defaultConfig {
versionName '5.2.11'
versionCode 1539
minSdkVersion 14
targetSdkVersion 20
buildConfigField "String", "GIT_REV", "\"" + buildInfo.ext.revision + "\""
}
productFlavors {
free {
applicationId 'nl.mpcjanssen.todotxtholo'
}
cloudless {
applicationId 'nl.mpcjanssen.simpletask'
}
}
signingConfigs {
release {
keyAlias = "mpcjanssen.nl"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
repositories {
mavenCentral()
}
dependencies {
freeCompile fileTree(dir: 'libs', include: '*.jar')
compile fileTree(dir: 'libskeep', include: '*.jar')
compile 'com.intellij:annotations:+@jar'
compile 'com.android.support:support-v4:20.0.0'
compile 'org.commonjava.googlecode.markdown4j:markdown4j:2.2-cj-1.0'
compile 'com.darwinsys:hirondelle-date4j:1.5.1'
compile 'com.google.guava:guava:17.0'
compile 'org.mozilla:rhino:1.7R4'
}
check.dependsOn unitTest
preBuild.dependsOn buildInfo
// Only sign if we have keystore properties in the gradle.properties in ~/.gradle
if (project.hasProperty('storeFile') &&
project.hasProperty('storePassword') &&
project.hasProperty('keyPassword')) {
android.signingConfigs.release.storeFile = file(storeFile)
android.signingConfigs.release.storePassword = storePassword
android.signingConfigs.release.keyPassword = keyPassword
} else {
android.buildTypes.release.signingConfig = null
}