forked from inaka/galgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
92 lines (80 loc) · 3.07 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
apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'com.github.saikcaskey'
PUBLISH_ARTIFACT_ID = 'saikcaskey-galgo'
PUBLISH_VERSION = '1.0.1'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
def versionPropsFile = file('version.properties')
def versionRevision
def versionMajor
def versionMinor
def versionBuild
/**
* Setting default value for versionBuild which is the last incremented
* value stored in the file
*/
if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
versionRevision = versionProps['VERSION_REVISION'].toInteger()
versionMajor = versionProps['VERSION_MAJOR'].toInteger()
versionMinor = versionProps['VERSION_MINOR'].toInteger()
versionBuild = versionProps['VERSION_BUILD'].toInteger()
} else {
throw new GradleException("Could not read version.properties file! Make sure it's in app/ directory ")
}
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode versionMajor * 100000 + versionMinor * 10000 + versionRevision * 1000 + versionBuild
versionName versionMajor + "." + versionMinor + "." + versionRevision
setProperty("archivesBaseName", "galgo-systemecks-" + versionCode)
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/** Wrapping inside a method avoids auto incrementing on every
* gradle task run. Now it runs only when we build apk
*/
ext.autoIncrementBuildNumber = {
if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
versionBuild = versionProps['VERSION_BUILD'].toInteger() + 1
versionProps['VERSION_BUILD'] = versionBuild.toString()
versionProps.store(versionPropsFile.newWriter(), null)
} else {
throw new GradleException("Could not read version.properties!")
}
}
// Hook to check if the release/debug task is among the tasks to be executed.
//Let's make use of it
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(assembleDebug)) { /* when run debug task */
autoIncrementBuildNumber()
} else if (taskGraph.hasTask(assembleRelease)) { /* when run release task */
autoIncrementBuildNumber()
} else {
System.out.print("operation does not qualify for incrememnting build number")
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'