-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
231 lines (203 loc) · 8.35 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import java.util.regex.Pattern
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
}
}
repositories {
mavenCentral()
}
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
//apply plugin: 'findbugs'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply from: 'gradle/adb_tasks.gradle'
apply from: 'gradle/code_quality_tasks.gradle'
apply from: 'gradle/intellij_config_tasks.gradle'
check.dependsOn 'checkstyle'
check.dependsOn 'pmd'
ext {
projectVersion = "0.9"
featuresEnabled = [
"lego_nxt" : true,
"led_brick" : false,
"vibration_brick" : false,
"backpack" : false,
"parrot_ar_drone" : false,
"apk_generator" : false,
"computer_vision_enhancement" : true,
"formula_editor_lists" : false,
"physics_engine_collision_filtering": false,
"time_capsule" : false,
"userbricks" : false
]
}
configurations {
compile.exclude group: 'xpp3' //compile problem with xstream
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.guava:guava:17.0'
compile 'com.squareup.okhttp:okhttp:2.1.0-RC1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0-RC1'
compile 'com.github.kevinsawicki:http-request:5.6'
compile fileTree(include: '*.jar', dir: 'catroid/libs')
compile fileTree(include: '*.jar', dir: 'catroid/libs-natives')
androidTestCompile fileTree(include: '*.jar', dir: 'catroidTest/libs')
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
pmd 'net.sourceforge.pmd:pmd:5.1.1'
}
def getBuildNumberParameter = { ->
def code = project.hasProperty('versionCode') ? versionCode.toInteger() : -1
return code
}
def generateVersionName(version, buildNumber) {
def versionName
if (buildNumber == -1) {
versionName = getGitDescribe() + " " + getCurrentGitBranch()
} else {
versionName = version + "." + buildNumber
}
return versionName
}
def getGitDescribe() {
try {
return 'git describe --tags'.execute().text.trim()
} catch (IOException exception) {
throw new UnsupportedOperationException("Could not find git! Maybe it is not in \$PATH variable?", exception)
}
}
def getCurrentGitBranch() {
try {
return 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
} catch (IOException exception) {
throw new UnsupportedOperationException("Could not find git! Maybe it is not in \$PATH variable?", exception)
}
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
applicationId 'org.catrobat.catroid'
testApplicationId "org.catrobat.catroid.test"
testInstrumentationRunner 'pl.polidea.instrumentation.PolideaInstrumentationTestRunner'
versionCode 21
println "VersionCode is " + versionCode
versionName "0.9.14"
println "VersionName is " + versionName
buildConfigField "String", "GIT_DESCRIBE", "\"${versionName}\""
buildConfigField "String", "GIT_CURRENT_BRANCH", "\"${getCurrentGitBranch()}\""
}
sourceSets {
main {
manifest.srcFile 'catroid/AndroidManifest.xml'
java.srcDirs = ['catroid/src']
resources.srcDirs = ['catroid/src']
aidl.srcDirs = ['catroid/src']
renderscript.srcDirs = ['catroid/src']
res.srcDirs = ['catroid/res']
assets.srcDirs = ['catroid/assets']
}
androidTest {
java.srcDirs = ['catroidTest/src']
resources.srcDirs = ['catroidTest/src']
aidl.srcDirs = ['catroidTest/src']
renderscript.srcDirs = ['catroidTest/src']
res.srcDirs = ['catroidTest/res']
assets.srcDirs = ['catroidTest/assets']
if (file('testexclusions.txt').exists()) {
java.exclude file('testexclusions.txt').readLines()
}
}
}
lintOptions {
// define ignores like a specific res-folder in our lint.xml file
lintConfig file('config/lint.xml')
// all general ignores should be added in this place
// CommitPrefEdits should be reviewed, if using apply instead of commit is working with our tests
// OldTargetApi should be reviewed - consider updating target API to 20
// RtlSymmetry/RtlHardcoded should be reviewed
// GradleDynamicVersion ignored - e.g. according to sdkmanager:gradle-plugin it should be imported this way
// IconMissingDensityFolder - currently no xxxhdpi icons available
// TODO ticket for HandlerLeak
// TODO don't know if WrongRegion warning is a false-positive one
ignore 'ContentDescription', 'InvalidPackage', 'ValidFragment', 'GradleDependency',
'ClickableViewAccessibility', 'UnusedAttribute', 'CommitPrefEdits', 'OldTargetApi',
'RtlSymmetry', 'GradleDynamicVersion', 'RtlHardcoded', 'HandlerLeak', 'IconMissingDensityFolder',
'WrongRegion', 'RelativeOverlap'
textReport true
xmlReport true
htmlReport false
xmlOutput file("build/reports/lint.xml")
}
}
if (project.hasProperty('jenkins')) {
project.android.dexOptions.preDexLibraries = false
// android.buildTypes.each { type ->
// if (type.name == "debug") {
// type.packageNameSuffix = ".jenkinsdebug"
// type.versionNameSuffix = "-jenkins-$type.name"
// }
// }
} else {
//not a jenkins build, remove animation scale permission
android.applicationVariants.all { variant ->
println "Removing the SET_ANIMATION_SCALE permission for $variant.name"
variant.outputs.each { output ->
output.processManifest.doLast {
def generatedContent = manifestOutputFile.getText()
generatedContent = generatedContent.replace('<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />', '')
if (generatedContent.contains('SET_ANIMATION_SCALE')) {
throw new RuntimeException("Error in removing animation scale permission!")
}
manifestOutputFile.write(generatedContent)
}
}
}
}
task featuresToBuildconfig << {
println "Activated Features:"
for (feature in featuresEnabled) {
def name = feature.key
def value = feature.value
if (project.hasProperty("allFeatures_enabled"))
value = project["allFeatures_enabled"]
if (project.hasProperty("${name}_enabled"))
value = project["${name}_enabled"]
if (!(value.toString().equals("true") || value.toString().equals("false")))
throw new IllegalArgumentException("Wrong Argument! Usage:\ne.g. -PallFeatures_enabled=true -Pparrot_ar_drone_enabled=false")
if (value.toString().equals("true")) {
println "- " + name
}
android.defaultConfig.buildConfigField "boolean", "FEATURE_${name.toUpperCase()}_ENABLED", "${value}"
}
println ""
}
task testManifestHack << {
def origManifest = file('catroidTest/AndroidManifest.xml')
def generatedManifest = file("build/intermediates/manifests/test/debug/AndroidManifest.xml")
def origContent = origManifest.getText()
def generatedContent = generatedManifest.getText()
def pattern = Pattern.compile("<application.*?>.*?</application>", Pattern.DOTALL)
def matcher = pattern.matcher(origContent)
matcher.find()
origContent = matcher.group()
generatedContent = pattern.matcher(generatedContent).replaceAll(origContent)
generatedManifest.write(generatedContent)
}
gradle.projectsEvaluated {
generateDebugTestBuildConfig.dependsOn testManifestHack
}
preBuild.dependsOn featuresToBuildconfig
def signing_config_file = file(System.getProperty("user.home") + "/.catrobat/catroid_signing_config.gradle")
if (signing_config_file.exists()) {
apply from: signing_config_file.absolutePath
}