Permalink
Switch branches/tags
Find file Copy path
81 lines (69 sloc) 2.62 KB
project.ext.sdkVersion = 27
project.ext.minSdkVersion = 15
project.ext.buildTools = '27.0.2'
// Don't cache SNAPSHOT (changing) dependencies.
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
static String getAppId (path) {
String build = new File(path).text
def matcher = build =~ 'applicationId.*'
def appId = matcher.size() > 0 ? matcher[0].trim() - 'applicationId' - ~/\s/ : ''
String myappId = appId.replaceAll('"', '')
myappId = myappId.replaceAll('\'', '')
return myappId
}
allprojects {
def currentVersion = file("${rootDir}/../version.txt").text.trim()
def props = new Properties()
props.load(new FileInputStream("${rootDir}/../realm.properties"))
props.each { key, val ->
project.ext.set(key, val)
}
buildscript {
repositories {
google()
mavenLocal()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha06'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath "io.realm:realm-gradle-plugin:${currentVersion}"
}
}
group = 'io.realm'
version = currentVersion
repositories {
mavenLocal()
jcenter()
google()
}
if (!project.name.startsWith("realm-examples")
&& !project.name.startsWith("library")
&& !project.name.startsWith("moduleExample")) { // exclude root and library project
["Debug", "Release"].each {
task "monkey${it}"(dependsOn: "install${it}") {
doLast {
def numberOfEvents = 2000
def appId = getAppId("${project.projectDir}/build.gradle")
def process = "adb shell monkey -p ${appId} --pct-syskeys 0 ${numberOfEvents}".execute([], project.rootDir)
def sout = new StringBuilder(), serr = new StringBuilder()
process.consumeProcessOutput(sout, serr)
process.waitFor()
if (process.exitValue() != 0
|| serr?.toString()?.trim()?.size() > 0
|| !sout?.toString()?.trim()?.contains("Events injected: ${numberOfEvents}")) {
// fail Gradle build
throw new GradleException("monkey failed for AppID: ${appId} \nStd out: ${sout}\nStd err: ${serr}")
}
}
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = project.gradleVersion
distributionType = 'all'
}