forked from robolectric/robolectric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
235 lines (194 loc) · 7.61 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
231
232
233
234
235
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
group = "org.robolectric"
version = "3.2-SNAPSHOT"
apply plugin: "java"
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
// Show all warnings except boot classpath
configure(options) {
if (System.properties["lint"] != null && System.properties["lint"] != "false") {
compilerArgs << "-Xlint:all" // Turn on all warnings
}
compilerArgs << "-Xlint:-options" // Turn off "missing" bootclasspath warning
encoding = "utf-8" // Make sure source encoding is UTF-8
incremental = true
}
}
apply plugin: ProvidedPlugin
apply plugin: "signing"
apply plugin: "maven"
task sourcesJar(type: Jar, dependsOn: classes) {
classifier "sources"
from sourceSets.main.allJava
}
javadoc {
classpath += configurations.provided
failOnError = false
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
}
task provideBuildClasspath(type: ProvideBuildClasspathTask)
test {
dependsOn provideBuildClasspath
exclude "**/*\$*" // otherwise gradle runs static inner classes like TestRunnerSequenceTest$SimpleTest
testLogging {
exceptionFormat "full"
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
events = ["failed", "skipped"]
}
minHeapSize = "1024m"
maxHeapSize = "2048m"
jvmArgs "-XX:MaxPermSize=1024m"
}
signing {
required { !version.endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
ext.mavenArtifactName = {
def projNameParts = project.name.split(/\//) as List
if (projNameParts[0] == "robolectric-shadows") {
projNameParts = projNameParts.drop(1)
return projNameParts.join("-")
} else {
return project.name
}
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
uploadArchives {
repositories {
mavenDeployer {
pom.artifactId = mavenArtifactName()
pom.project {
name project.name
description = "An alternative Android testing framework."
url = "http://robolectric.org"
licenses {
license {
name "The MIT License"
url "https://opensource.org/licenses/MIT"
}
}
scm {
url "[email protected]:robolectric/robolectric.git"
connection "scm:git:git://github.com/robolectric/robolectric.git"
developerConnection "scm:git:https://github.com/robolectric/robolectric.git"
}
developers {
developer {
name "Christian Williams"
email "[email protected]"
organization {
name "Google Inc."
}
organizationUrl "http://google.com"
}
developer {
name "Jonathan Gerrish"
email "[email protected]"
organization {
name "Google Inc."
}
organizationUrl "http://google.com"
}
}
}
def url = project.version.endsWith("-SNAPSHOT") ?
"https://oss.sonatype.org/content/repositories/snapshots" :
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
repository(url: url) {
authentication(
userName: System.properties["sonatype-login"],
password: System.properties["sonatype-password"]
)
}
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
}
}
}
def subshadowRE = /robolectric-shadows\/shadows-core\/v(.*)$/
configure(subprojects.findAll { project -> project.name =~ subshadowRE }) {
apply plugin: ShadowsPlugin
def match = project.name =~ subshadowRE
def androidApi = Integer.parseInt(match[0][1])
def robolectricVersion = AndroidSdk.versions[androidApi]
logger.info "[${project.name}] Android API is $androidApi — $robolectricVersion"
task velocity(type: VelocityTask) {
def shadowsCoreProject = project.findProject(":robolectric-shadows/shadows-core")
source = shadowsCoreProject.files("src/main/resources").asFileTree.matching { include "/**/*.vm" }
contextValues = [api: androidApi]
if (androidApi >= 21) {
contextValues.putAll(ptrClass: "long", ptrClassBoxed: "Long")
} else {
contextValues.putAll(ptrClass: "int", ptrClassBoxed: "Integer")
}
outputDir = project.file("${project.buildDir}/generated-shadows")
doLast {
def shadowsCoreProj = project.findProject(":robolectric-shadows/shadows-core")
project.copy {
from shadowsCoreProj.files("src/main/java")
into outputDir
}
project.copy {
from shadowsCoreProj.fileTree("src/main/resources").include("META-INF/**")
into project.file("${project.buildDir}/resources/main")
}
}
}
shadows {
packageName "org.robolectric"
}
generateShadowProvider {
dependsOn velocity
}
configurations {
jni
}
dependencies {
// Project dependencies
compile project(":robolectric-annotations")
compile project(":robolectric-resources")
compile project(":robolectric-utils")
// Compile dependencies
provided "com.intellij:annotations:12.0"
compile "com.almworks.sqlite4java:sqlite4java:0.282"
provided("org.robolectric:android-all:$robolectricVersion") { force = true }
compile "com.ibm.icu:icu4j:53.1"
jni "com.github.axet.litedb:libsqlite:0.282-3:natives-mac-x86_64"
jni "com.github.axet.litedb:libsqlite:0.282-3:natives-linux-x86"
jni "com.github.axet.litedb:libsqlite:0.282-3:natives-linux-x86_64"
jni "com.github.axet.litedb:libsqlite:0.282-3:natives-windows-x86"
jni "com.github.axet.litedb:libsqlite:0.282-3:natives-windows-x86_64"
}
task copyNatives(type: Copy) {
outputs.dir file("${buildDir}/resources/main")
configurations.jni.files.each { File file ->
def nativeJarMatch = file.name =~ /lib.*-natives-(.*)\.jar/
if (nativeJarMatch) {
inputs.file file
def platformName = nativeJarMatch[0][1]
from(zipTree(file)) { rename { f -> "$platformName/$f" } }
}
into project.file("$buildDir/resources/main")
}
}
jar {
dependsOn copyNatives
}
}