|
| 1 | +package org.gradle.android |
| 2 | + |
| 3 | +import org.gradle.util.GradleVersion |
| 4 | +import org.gradle.util.VersionNumber |
| 5 | +import spock.lang.Unroll |
| 6 | + |
| 7 | +class TaskAvoidanceTest extends AbstractTest { |
| 8 | + @Unroll |
| 9 | + def "tasks are avoided with #gradleVersion and Android plugin #androidVersion"() { |
| 10 | + assert gradleVersion instanceof GradleVersion |
| 11 | + assert androidVersion instanceof VersionNumber |
| 12 | + |
| 13 | + println "> Using Android plugin $androidVersion" |
| 14 | + println "> Running with $gradleVersion" |
| 15 | + |
| 16 | + SimpleAndroidApp.builder(temporaryFolder.root, cacheDir) |
| 17 | + .withAndroidVersion(androidVersion) |
| 18 | + .withKotlinDisabled() |
| 19 | + .build() |
| 20 | + .writeProject() |
| 21 | + |
| 22 | + def originalSettings = file('build.gradle').text |
| 23 | + file('build.gradle').text = """ |
| 24 | + ${originalSettings} |
| 25 | +
|
| 26 | + allprojects { |
| 27 | + tasks.configureEach { |
| 28 | + println "configuring \$it" |
| 29 | + } |
| 30 | + } |
| 31 | + """ |
| 32 | + |
| 33 | + when: |
| 34 | + def result = withGradleVersion(gradleVersion.version) |
| 35 | + .withProjectDir(temporaryFolder.root) |
| 36 | + .withArguments("help") |
| 37 | + .build() |
| 38 | + |
| 39 | + then: |
| 40 | + result.output.contains("configuring task ':help'") |
| 41 | + !result.output.contains("configuring task ':app:compileDebugJavaWithJavac'") |
| 42 | + !result.output.contains("configuring task ':app:compileDebugAndroidTestJavaWithJavac'") |
| 43 | + !result.output.contains("configuring task ':app:compileDebugUnitTestJavaWithJavac'") |
| 44 | + !result.output.contains("configuring task ':app:compileReleaseJavaWithJavac'") |
| 45 | + !result.output.contains("configuring task ':app:compileReleaseUnitTestJavaWithJavac'") |
| 46 | + !result.output.contains("configuring task ':library:compileDebugJavaWithJavac'") |
| 47 | + !result.output.contains("configuring task ':library:compileDebugAndroidTestJavaWithJavac'") |
| 48 | + !result.output.contains("configuring task ':library:compileDebugUnitTestJavaWithJavac'") |
| 49 | + !result.output.contains("configuring task ':library:compileReleaseJavaWithJavac'") |
| 50 | + !result.output.contains("configuring task ':library:compileReleaseUnitTestJavaWithJavac'") |
| 51 | + |
| 52 | + where: |
| 53 | + [androidVersion, gradleVersion] << Versions.SUPPORTED_VERSIONS_MATRIX.entries().collect { [it.key, it.value] } |
| 54 | + } |
| 55 | +} |
0 commit comments