aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorC. Sean Young <csyoung@google.com>2015-01-14 20:03:01 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-14 20:03:02 +0000
commit5c10e9ff27df4182bfa3bf5a99e7a7ba397c8ee9 (patch)
treeab6298b9735a90afeda8a6d23a19d422d73570f5 /base
parent3f9c8a4b99b16cd5dbb65a89f093f5377b1136b6 (diff)
parentd29df68d21ea7177ae09e562d7bc749ad63fe0e3 (diff)
downloadbuildSrc-5c10e9ff27df4182bfa3bf5a99e7a7ba397c8ee9.tar.gz
Merge "Make the Java 1.6 check only occur when running a "build-like" task." into studio-1.1-dev
Diffstat (limited to 'base')
-rw-r--r--base/build.gradle20
1 files changed, 17 insertions, 3 deletions
diff --git a/base/build.gradle b/base/build.gradle
index 676c763..873f735 100644
--- a/base/build.gradle
+++ b/base/build.gradle
@@ -2,9 +2,23 @@ apply plugin: 'clone-artifacts'
// Currently, the minimum requirement to run Android SDK tools is Java 1.6
// So make sure that we are compiling with 1.6
-def jvmVersion = System.getProperty('java.version')
-if (!jvmVersion.startsWith('1.6')) {
- throw new RuntimeException("Tools need to be compiled with Java 1.6, you are using Java $jvmVersion")
+task('checkJavaVersion') << {
+ def jvmVersion = System.getProperty('java.version')
+ if (!jvmVersion.startsWith('1.6')) {
+ throw new RuntimeException("Tools need to be compiled with Java 1.6, you are using Java $jvmVersion")
+ }
+}
+final def checkJavaVersionTask = tasks['checkJavaVersion']
+
+allprojects { subproject ->
+ afterEvaluate {
+ // Only check if we are doing build type tasks. Things like dependency listing
+ // should still work with a "wrong" java version.
+ final def buildTasks = ['build', 'compileJava', 'compileGroovy', 'classes', 'assemble', 'javadoc', 'groovydoc', 'check']
+ // Task.doFirst does not run if the task has no work to do. Need to be more aggressive than that.
+ // Some projects won't have all of these tasks, so need to use findByName.
+ buildTasks.each { subproject.tasks.findByName(it)?.dependsOn(checkJavaVersionTask) }
+ }
}
// artifact cloning destinations