forked from Catrobat/Catroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
168 lines (139 loc) · 4.85 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
import java.util.regex.Pattern
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'android'
//apply plugin: 'findbugs'
apply plugin: 'checkstyle'
//apply plugin: 'pmd'
ext.catroid_version = "0.9"
ext.features_enabled = [
"backpack": false
]
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.+'
compile fileTree(dir: 'catroid/libs', include: '*.jar')
compile fileTree(dir: 'catroid/libs-natives', include: '*.jar')
androidTestCompile fileTree(dir: 'catroidTest/libs', include: '*.jar')
}
def getVersionCode = { ->
def code = project.hasProperty('versionCode') ? versionCode.toInteger() : -1
return code
}
def getVersionName = { ->
def code = getVersionCode
def versionName = "$ext.catroid_version.$code"
println "VersionCode is set to $code"
println "VersionName is set to $versionName"
return versionName
}
def gitDescribe() {
return 'git describe --tags'.execute().text.trim()
}
android {
compileSdkVersion 19
buildToolsVersion "19"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
packageName "org.catrobat.catroid"
testPackageName "org.catrobat.catroid.test"
testInstrumentationRunner "pl.polidea.instrumentation.PolideaInstrumentationTestRunner"
versionCode getVersionCode()
versionName getVersionName()
buildConfigField "String", "GIT_DESCRIBE", "\"${gitDescribe()}\""
}
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()
}
}
}
}
// Doesn't work atm. Maybe if the pmd plugin gets updated.
//task findbugs(type: FindBugs) {
// classes = fileTree('build/classes/debug/')
// source = fileTree(android.sourceSets.main.java.srcDirs)
// classpath = files( project.configurations.compile.asPath )
// effort = 'max'
// reports.xml.enabled = false
// reports.html.enabled = true
//}
task checkstyle(type: Checkstyle) {
configFile file('catroid/checkstyle.xml')
source '.'
include '**/*.java'
exclude 'build/**', 'libraryProjects/**'
classpath = files(project.configurations.compile.asPath)
}
// Doesn't work atm. Maybe if the pmd plugin gets updated.
//task pmd(type: Pmd) {
// ruleSets = ["basic", "braces", "strings"]
// source = fileTree(android.sourceSets.main.java.srcDirs)
//}
task jenkins() << {
// android.buildTypes.each { type ->
// if (type.name == "debug") {
// type.packageNameSuffix = ".jenkinsdebug"
// type.versionNameSuffix = "-jenkins-$type.name"
// }
// }
}
task featuresToBuildconfig() {
for (feature in project.ext.features_enabled) {
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"]
android.defaultConfig.buildConfigField "boolean", "FEATURE_${name.toUpperCase()}_ENABLED", "${value}"
}
}
task testManifestHack() << {
def origManifest = file('catroidTest/AndroidManifest.xml')
def generatedManifest = file("build/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
}