| apply plugin: 'groovy' |
| apply plugin: 'jacoco' |
| |
| repositories { |
| maven { url = uri(rootProject.cloneArtifacts.repository) } |
| } |
| |
| dependencies { |
| compile gradleApi() |
| compile localGroovy() |
| compile project(':base:builder-model') |
| compile project(':base:builder') |
| compile project(':base:sdk-common') |
| compile "com.google.truth:truth:0.24" |
| testCompile "org.jacoco:org.jacoco.agent:0.7.4.201502262128" |
| } |
| |
| def testEnvironment = [ |
| PROJECT_BUILD_DIR: project.buildDir, |
| CUSTOM_REPO: rootProject.file("../out/repo"), |
| CUSTOM_GRADLE: System.env.CUSTOM_GRADLE ?: rootProject.ext.buildVersion, |
| ANDROID_HOME: System.env.ANDROID_HOME, |
| ANDROID_NDK_HOME: System.env.ANDROID_NDK_HOME, |
| CUSTOM_BUILDTOOLS: System.env.CUSTOM_BUILDTOOLS, |
| CUSTOM_JACK: System.env.CUSTOM_JACK, |
| ].findAll { it.value != null } |
| |
| // These tasks will not depend on publishLocal, so they will run integration |
| // tests against whatever version of the plugin is in ../../../out/repo. This |
| // allows us to run integration tests with different versions of Java, without |
| // rebuilding the plugin. |
| task testPrebuilts(type: Test) |
| task connectedIntegrationTestPrebuilts(type: Test) |
| |
| configure([test, testPrebuilts]) { |
| description = |
| "Runs the project integration tests. This requires an SDK either from the Android " + |
| "source tree, under out/..., or an env var ANDROID_HOME." |
| systemProperties['jar.path'] = jar.archivePath |
| environment = testEnvironment |
| |
| forkEvery = 1 |
| maxParallelForks = Runtime.runtime.availableProcessors() / 2 |
| |
| useJUnit { |
| excludeCategories "com.android.build.gradle.integration.common.category.DeviceTests" |
| } |
| } |
| |
| task connectedIntegrationTest(type: Test) |
| |
| configure([connectedIntegrationTest, connectedIntegrationTestPrebuilts]) { |
| testClassesDir = sourceSets.test.output.classesDir |
| classpath = sourceSets.test.runtimeClasspath |
| |
| description = |
| "Runs the project integration tests with device tests. This requires an SDK either " + |
| "from the Android source tree, under out/..., or an env var ANDROID_HOME " + |
| "and a device." |
| group = "verification" |
| systemProperties['jar.path'] = jar.archivePath |
| environment = testEnvironment |
| useJUnit { |
| includeCategories "com.android.build.gradle.integration.common.category.DeviceTests" |
| } |
| } |
| |
| task performanceTest(type: Test) { |
| include "com/android/build/gradle/integration/performance/**" |
| |
| testClassesDir = sourceSets.test.output.classesDir |
| classpath = sourceSets.test.runtimeClasspath |
| |
| description = |
| "Runs the project performance tests. This requires an SDK either " + |
| "from the Android source tree, under out/..., or an env var ANDROID_HOME." |
| group = "verification" |
| systemProperties['jar.path'] = jar.archivePath |
| environment = testEnvironment |
| |
| reports { |
| junitXml.destination "${project.buildDir}/perf-results" |
| } |
| } |
| |
| test.dependsOn ':publishLocal' |
| connectedIntegrationTest.dependsOn ':publishLocal' |
| performanceTest.dependsOn ':publishLocal' |
| check.dependsOn performanceTest |
| |
| jacocoTestReport { |
| sourceSets project(':base:gradle').sourceSets.main |
| sourceSets project(':base:builder').sourceSets.main |
| sourceSets project(':base:builder-model').sourceSets.main |
| } |
| |
| // Due to memory constraints, apply jacoco only when jacocoTestReport is invoked. Make sure to |
| // rerun tests when generating report jacoco. |
| gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph -> |
| if (taskGraph.hasTask(jacocoTestReport)) { |
| test.environment("ATTACH_JACOCO_AGENT", "yes") |
| } |
| } |