From 0a593109d37d3d5ff149f31abe02544a18cc6723 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 29 Oct 2015 17:12:45 -0700 Subject: [PATCH] Build: Add gradle version check and some build info that is always output --- buildSrc/build.gradle | 10 ++++----- .../elasticsearch/gradle/BuildPlugin.groovy | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index e987a173bae..eadf1f63784 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -46,11 +46,11 @@ props.load(project.file('../gradle.properties').newDataInputStream()) version = props.getProperty('version') processResources { - inputs.file('../gradle.properties') - filter ReplaceTokens, tokens: [ - 'version': props.getProperty('version'), - 'luceneVersion': props.getProperty('luceneVersion') - ] + inputs.file('../gradle.properties') + filter ReplaceTokens, tokens: [ + 'version': props.getProperty('version'), + 'luceneVersion': props.getProperty('luceneVersion') + ] } extraArchive { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 4b550acc9e4..ee666771319 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -19,12 +19,14 @@ package org.elasticsearch.gradle import org.elasticsearch.gradle.precommit.PrecommitTasks +import org.gradle.api.GradleException import org.gradle.api.JavaVersion import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.util.VersionNumber /** * Encapsulates build configuration for elasticsearch projects. @@ -33,6 +35,7 @@ class BuildPlugin implements Plugin { @Override void apply(Project project) { + globalBuildInfo(project) project.pluginManager.apply('java') project.pluginManager.apply('carrotsearch.randomizedtesting') // these plugins add lots of info to our jars @@ -48,6 +51,25 @@ class BuildPlugin implements Plugin { PrecommitTasks.configure(project) } + static void globalBuildInfo(Project project) { + if (project.rootProject.ext.has('buildChecksDone') == false) { + // enforce gradle version + VersionNumber gradleVersion = VersionNumber.parse(project.gradle.gradleVersion) + if (gradleVersion.major < 2 || gradleVersion.major == 2 && gradleVersion.minor < 6) { + throw new GradleException('Gradle 2.6 or above is required to build elasticsearch') + } + + // Build debugging info + println '=======================================' + println 'Elasticsearch Build Hamster says Hello!' + println '=======================================' + println " Gradle Version : ${project.gradle.gradleVersion}" + println " JDK Version : ${System.getProperty('java.runtime.version')} (${System.getProperty('java.vendor')})" + println " OS Info : ${System.getProperty('os.name')} ${System.getProperty('os.version')} (${System.getProperty('os.arch')})" + project.rootProject.ext.buildChecksDone = true + } + } + /** Adds compiler settings to the project */ static void configureCompile(Project project) { project.afterEvaluate {