This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.common.gradle
140 lines (122 loc) · 4.44 KB
/
build.common.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
/**
* build.common.gradle
*
* Try to avoid editing this file, as it may be updated from time to time as the FTC SDK
* evolves. Rather, if it is necessary to customize the build process, do those edits in
* the build.gradle file in TeamCode.
*
* This file contains the necessary content of the 'build.gradle' files for robot controller
* applications built using the FTC SDK. Each individual 'build.gradle' in those applications
* can simply contain the one line:
*
* apply from: '../build.common.gradle'
*
* which will pick up this file here. This approach allows makes it easier to integrate
* updates to the FTC SDK into your code.
*/
import java.util.regex.Pattern
apply plugin: 'com.android.application'
// This variable can be accessed from within TeamCode classes by using BuildConfig.VUFORIA_KEY
String vuforiaKey
try {
def vuforiaPropertiesFileStream = new FileInputStream(file('./vuforia.properties').absolutePath)
def vuforiaProperties = new Properties()
vuforiaProperties.load(vuforiaPropertiesFileStream)
vuforiaKey = vuforiaProperties['VUFORIA_KEY']
} catch (FileNotFoundException) {
println "vuforia.properties not found"
} finally {
if (vuforiaKey == null) {
vuforiaKey = '""'
}
}
android {
compileSdkVersion 23
signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile rootProject.file('libs/ftc.debug.keystore')
storePassword 'android'
}
}
buildTypes.each {
it.buildConfigField 'String', 'VUFORIA_KEY', vuforiaKey
}
defaultConfig {
applicationId 'com.qualcomm.ftcrobotcontroller'
minSdkVersion 19
targetSdkVersion 19
/**
* We keep the versionCode and versionName of robot controller applications in sync with
* the master information published in the AndroidManifest.xml file of the FtcRobotController
* module. This helps avoid confusion that might arise from having multiple versions of
* a robot controller app simultaneously installed on a robot controller device.
*
* We accomplish this with the help of a funky little Groovy script that maintains that
* correspondence automatically.
*
* @see <a href="http://developer.android.com/tools/building/configuring-gradle.html">Configure Your Build</a>
* @see <a href="http://developer.android.com/tools/publishing/versioning.html">Versioning Your App</a>
*/
def manifestFile = project(':FtcRobotController').file('src/main/AndroidManifest.xml');
def manifestText = manifestFile.getText()
//
def vCodePattern = Pattern.compile("versionCode=\"(\\d+(\\.\\d+)*)\"")
def matcher = vCodePattern.matcher(manifestText)
matcher.find()
def vCode = Integer.parseInt(matcher.group(1))
//
def vNamePattern = Pattern.compile("versionName=\"(.*)\"")
matcher = vNamePattern.matcher(manifestText);
matcher.find()
def vName = matcher.group(1)
//
versionCode vCode
versionName vName
}
// Advanced user code might just want to use Vuforia directly, so we set up the libs as needed
buildTypes {
release {
// Disable debugging for release versions so it can be uploaded to Google Play.
//debuggable true
ndk {
abiFilters "armeabi-v7a"
}
}
debug {
debuggable true
ndk {
abiFilters "armeabi-v7a"
}
}
}
flavorDimensions 'type'
productFlavors {
openrc { dimension 'type' }
stock { dimension 'type' }
}
// Selecting a release variant will prompt teams to set up a signing key. Now that there's
// a reason to select other variants (the stock feature of OpenRC), it's better to filter out
// the ones that will confuse teams.
variantFilter { variant ->
if (variant.buildType.name == "release") {
setIgnore(true)
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir rootProject.file('libs')
}
}
repositories {
flatDir {
dirs rootProject.file('libs')
}
}
apply from: "$rootProject.projectDir/OpenRC/openrc-tasks.gradle"
apply from: 'build.release.gradle'