forked from lin187/StarL1.5
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
200 lines (167 loc) · 6.89 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
play_services_version = '10.2.6'
android_build_sdk_version = 27
android_build_tools_version = '28.0.0 rc2'
android_build_target_sdk_version = 27
android_build_min_sdk_version = 24 // Default interface methods are only supported starting with Android N
android_build_target_compatibility = JavaVersion.VERSION_1_8
android_build_source_compatibility = JavaVersion.VERSION_1_8
/**
* StarL currently requires a path to the system's Android SDK installation. It will first
* attempt to find this path by checking the 'sdk.dir' property in the local.properties file,
* which is generated by the IDE. If this fails, StarL will attempt to read the ANDROID_HOME
* environment variable.
* android_classpath is the path to the required android.jar file, '' on failure.
*/
android_classpath = { ->
android_home = ''
try {
prop = new Properties()
prop.load(project.rootProject.file('local.properties').newDataInputStream())
android_home = prop.getProperty('sdk.dir')
} catch (Exception e) {
logger.warn('sdk.dir property in local.properties not found, using env variable instead. '
+ e)
android_home = System.getenv('ANDROID_HOME')
}
android_classpath = ''
if (android_home != null) {
android_classpath = "${android_home}/platforms/android-${android_build_sdk_version}/android.jar"
} else {
logger.warn('neither local.properties sdk.dir nor ANDROID_HOME environment variable are set.')
}
return android_classpath
}.call()
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
static def computeVersionCode(int versionMajor, int versionMinor, int versionPatch, int versionBuild = 0){
return versionMajor * 100000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
}
static def generateVersionName(String versionPrefix, int versionMajor, int versionMinor, int versionPatch, String versionSuffix = ""){
def versionName = "${versionPrefix}${versionMajor}.${versionMinor}.${versionPatch}"
if(versionSuffix != null && !versionSuffix.isEmpty() && versionSuffix != "release"){
versionName += "-${versionSuffix}"
}
return versionName
}
static def generateVersionNameSuffix(int versionBuild, String releaseType, boolean includeHash = false){
def versionNameSuffix = "${releaseType}.${versionBuild}"
if(includeHash){
versionNameSuffix += " (${getGitShortHash()})"
}
return versionNameSuffix
}
/**
* @return The most recent git tag to be used as version name for the app.
*/
static def getGitVersion() {
def cmd = "git describe --tag"
try {
def proc = cmd.execute()
return proc.text.trim()
} catch (IOException e) {
//Unable to find 'git'
return "please update version name manually"
}
}
static def getGitShortHash() {
def cmd = "git rev-parse --short HEAD"
try{
def proc = cmd.execute()
return proc.text.trim()
} catch(IOException e){
//Unable to find git
return ""
}
}
def getMavenUsername(){
return hasProperty('COM_O3DR_MAVEN_USERNAME') ? COM_O3DR_MAVEN_USERNAME : ''
}
def getMavenApiKey(){
return hasProperty('COM_O3DR_MAVEN_APIKEY') ? COM_O3DR_MAVEN_APIKEY : ''
}
def getMavenRepo(){
return hasProperty('COM_O3DR_MAVEN_REPO') ? COM_O3DR_MAVEN_REPO : ''
}
def getMavenRepoUrl(){
return hasProperty('COM_O3DR_MAVEN_REPO_URL') ? COM_O3DR_MAVEN_REPO_URL : 'https://dl.bintray.com/3d-robotics/maven'
}
/**
* Improve build server performance by allowing disabling of pre-dexing
* (see http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.)
*/
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}
allprojects {
tasks.withType(JavaCompile) {
// applied on all projects
sourceCompatibility = android_build_source_compatibility
targetCompatibility = android_build_target_compatibility
// Certain parts of StarL need access to the Java 1.7 runtime library.
options.compilerArgs << "-bootclasspath" << "rt-1.7.jar"
/**
* Add additional javac compiler arguments here:
* ----------------------------------
*/
//options.compilerArgs << "-verbose" // log each class loaded and source file compiled
//options.compilerArgs << "-g" // generate all debugging information
//options.compilerArgs << "-g:none" // generate no debugging information
/**
* The following enable (or disable with -Xlint:-<name>) nonstandard warnings:
*/
//options.compilerArgs << "-Xlint" // enable recommended warnings
//options.compilerArgs << "-Xlint:all" // enable all warnings
//options.compilerArgs << "-Xlint:cast"
//options.compilerArgs << "-Xlint:classfile"
//options.compilerArgs << "-Xlint:deprecation"
//options.compilerArgs << "-Xlint:dep-ann"
//options.compilerArgs << "-Xlint:divzero"
//options.compilerArgs << "-Xlint:empty"
//options.compilerArgs << "-Xlint:fallthrough"
//options.compilerArgs << "-Xlint:finally"
//options.compilerArgs << "-Xlint:options"
//options.compilerArgs << "-Xlint:overrides"
//options.compilerArgs << "-Xlint:path"
//options.compilerArgs << "-Xlint:processing"
//options.compilerArgs << "-Xlint:rawtypes"
//options.compilerArgs << "-Xlint:serial"
//options.compilerArgs << "-Xlint:static"
//options.compilerArgs << "-Xlint:try"
//options.compilerArgs << "-Xlint:unchecked"
//options.compilerArgs << "-Xlint:varargs"
//options.compilerArgs << "-Xmaxerrors" << "<number>"
//options.compilerArgs << "-Xmaxwarns" << "<number>"
//options.compilerArgs << "-Xstdout" << "<filename>"
}
repositories {
google()
jcenter()
maven {
url getMavenRepoUrl()
credentials {
username getMavenUsername()
password getMavenApiKey()
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}