-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
85 lines (66 loc) · 2.14 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
import java.text.SimpleDateFormat
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
def apkFolder = 'app/build/outputs/apk/rpi3/release'
def apkFilename = 'app-rpi3-release.apk'
def animationFolder = 'bundle/animations'
def animationFilename = 'bootanimation.zip'
task checkArtifacts(dependsOn: ':app:assembleRpi3Release') {
doLast {
def apkPath = "$apkFolder/$apkFilename"
if (!file(apkPath).exists()) {
throw new GradleException("App artifact missing, build must have failed ($apkPath)")
}
def animationPath = "$animationFolder/$animationFilename"
if (!file(animationPath).exists()) {
throw new GradleException("Animation asset missing, expected on $animationPath")
}
}
}
task bundle(type: Zip, dependsOn: ['checkArtifacts']) {
from apkFolder
include apkFilename
from animationFolder
include animationFilename
def time = buildTime()
def folder = 'build/outputs/bundle'
archiveName "bundle-rpi3-${time}.zip"
destinationDir(file(folder))
doLast {
println "File generated on ${folder}/${archiveName}"
}
}
def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd-HHmm")
return df.format(new Date())
}
task printHome () {
// helps check if android studio picked up the right folders
println gradle.gradleHomeDir
println gradle.gradleUserHomeDir
}