From 8f6c074691dc9e8678d9f579fecd1b16d9b5f82a Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 20 Jan 2017 18:16:45 -0500 Subject: [PATCH] Revert "Make build Gradle 2.14 / 3.x compatible (#22669)" This reverts commit 652cb7dbf70c5f5b3c7ac98f7ca0c367b55a803b. Relates #22727 --- buildSrc/build.gradle | 28 ++++++------------- .../compile/groovy/gradle-2.13-loggers.groovy | 26 ----------------- .../compile/groovy/gradle-2.14-loggers.groovy | 26 ----------------- .../junit4/RandomizedTestingTask.groovy | 1 + .../gradle/junit4/TestProgressLogger.groovy | 2 ++ .../elasticsearch/gradle/BuildPlugin.groovy | 6 ++-- .../vagrant/TapLoggerOutputStream.groovy | 2 ++ .../gradle/vagrant/VagrantCommandTask.groovy | 1 + .../vagrant/VagrantLoggerOutputStream.groovy | 2 ++ plugins/repository-hdfs/build.gradle | 6 ---- 10 files changed, 19 insertions(+), 81 deletions(-) delete mode 100644 buildSrc/src/compile/groovy/gradle-2.13-loggers.groovy delete mode 100644 buildSrc/src/compile/groovy/gradle-2.14-loggers.groovy diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index c2e8a9114c7..0e8c2dc1412 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -23,8 +23,14 @@ apply plugin: 'groovy' group = 'org.elasticsearch.gradle' -if (GradleVersion.current() < GradleVersion.version('2.13')) { - throw new GradleException('Gradle 2.13+ is required to build elasticsearch') +// TODO: remove this when upgrading to a version that supports ProgressLogger +// gradle 2.14 made internal apis unavailable to plugins, and gradle considered +// ProgressLogger to be an internal api. Until this is made available again, +// we can't upgrade without losing our nice progress logging +// NOTE that this check duplicates that in BuildPlugin, but we need to check +// early here before trying to compile the broken classes in buildSrc +if (GradleVersion.current() != GradleVersion.version('2.13')) { + throw new GradleException('Gradle 2.13 is required to build elasticsearch') } if (project == rootProject) { @@ -90,25 +96,9 @@ dependencies { compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE.... compile 'de.thetaphi:forbiddenapis:2.2' compile 'org.apache.rat:apache-rat:0.11' + compile 'ru.vyarus:gradle-animalsniffer-plugin:1.0.1' } -// Gradle version-specific options (allows build to run with Gradle 2.13 as well as 2.14+/3.+) -if (GradleVersion.current() == GradleVersion.version("2.13")) { - // ProgressLogger(-Factory) classes are part of the public Gradle API - // Add default imports for (org.gradle.logging) - compileGroovy.groovyOptions.configurationScript = file('src/compile/groovy/gradle-2.13-loggers.groovy') - dependencies { - compile 'ru.vyarus:gradle-animalsniffer-plugin:1.0.1' // last version compatible with Gradle 2.13 - } -} else { - // Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs - // Use logging dependency and add default imports for "org.gradle.internal.logging.progress" - compileGroovy.groovyOptions.configurationScript = file('src/compile/groovy/gradle-2.14-loggers.groovy') - dependencies { - compileOnly "org.gradle:gradle-logging:${GradleVersion.current().getVersion()}" - compile 'ru.vyarus:gradle-animalsniffer-plugin:1.2.0' // Gradle 2.14 requires a version > 1.0.1 - } -} /***************************************************************************** * Bootstrap repositories * diff --git a/buildSrc/src/compile/groovy/gradle-2.13-loggers.groovy b/buildSrc/src/compile/groovy/gradle-2.13-loggers.groovy deleted file mode 100644 index ecf4a5674f8..00000000000 --- a/buildSrc/src/compile/groovy/gradle-2.13-loggers.groovy +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.codehaus.groovy.control.customizers.ImportCustomizer - -def imports = new ImportCustomizer() -imports.addImports( - 'org.gradle.logging.ProgressLogger', - 'org.gradle.logging.ProgressLoggerFactory') -configuration.addCompilationCustomizers(imports) diff --git a/buildSrc/src/compile/groovy/gradle-2.14-loggers.groovy b/buildSrc/src/compile/groovy/gradle-2.14-loggers.groovy deleted file mode 100644 index 3edc4b4b0ed..00000000000 --- a/buildSrc/src/compile/groovy/gradle-2.14-loggers.groovy +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.codehaus.groovy.control.customizers.ImportCustomizer - -def imports = new ImportCustomizer() -imports.addImports( - 'org.gradle.internal.logging.progress.ProgressLogger', - 'org.gradle.internal.logging.progress.ProgressLoggerFactory') -configuration.addCompilationCustomizers(imports) diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy index 90a9592bbb4..c2e8de9f10b 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy @@ -19,6 +19,7 @@ import org.gradle.api.tasks.Optional import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.util.PatternFilterable import org.gradle.api.tasks.util.PatternSet +import org.gradle.logging.ProgressLoggerFactory import org.gradle.util.ConfigureUtil import javax.inject.Inject diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy index 7f1d57d1eee..14f5d476be3 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy @@ -25,6 +25,8 @@ import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedStartEvent import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedSuiteResultEvent import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedTestResultEvent import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener +import org.gradle.logging.ProgressLogger +import org.gradle.logging.ProgressLoggerFactory import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.formatDurationInSeconds import static com.carrotsearch.ant.tasks.junit4.events.aggregated.TestStatus.ERROR diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index ab1b20580a3..0dd45ebd2ce 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -419,10 +419,8 @@ class BuildPlugin implements Plugin { // hack until gradle supports java 9's new "--release" arg assert minimumJava == JavaVersion.VERSION_1_8 options.compilerArgs << '--release' << '8' - doFirst{ - sourceCompatibility = null - targetCompatibility = null - } + project.sourceCompatibility = null + project.targetCompatibility = null } } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy index 266045619a7..3f980c57a49 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy @@ -22,6 +22,8 @@ import com.carrotsearch.gradle.junit4.LoggingOutputStream import groovy.transform.PackageScope import org.gradle.api.GradleScriptException import org.gradle.api.logging.Logger +import org.gradle.logging.ProgressLogger +import org.gradle.logging.ProgressLoggerFactory import java.util.regex.Matcher diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantCommandTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantCommandTask.groovy index 022ce487da2..ecba08d7d4c 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantCommandTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantCommandTask.groovy @@ -21,6 +21,7 @@ package org.elasticsearch.gradle.vagrant import org.apache.commons.io.output.TeeOutputStream import org.elasticsearch.gradle.LoggedExec import org.gradle.api.tasks.Input +import org.gradle.logging.ProgressLoggerFactory import javax.inject.Inject diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy index 9be63155e17..331a638b5ca 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy @@ -20,6 +20,8 @@ package org.elasticsearch.gradle.vagrant import com.carrotsearch.gradle.junit4.LoggingOutputStream import org.gradle.api.logging.Logger +import org.gradle.logging.ProgressLogger +import org.gradle.logging.ProgressLoggerFactory /** * Adapts an OutputStream being written to by vagrant into a ProcessLogger. It diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 213f2fe0f07..8cfb5043b6c 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -368,9 +368,3 @@ thirdPartyAudit.excludes = [ 'org.apache.log4j.helpers.ISO8601DateFormat', 'org.apache.log4j.spi.ThrowableInformation' ] - -// Gradle 2.13 bundles org.slf4j.impl.StaticLoggerBinder in its core.jar which leaks into the forbidden APIs ant task -// Gradle 2.14+ does not bundle this class anymore so we need to properly exclude it here. -if (GradleVersion.current() > GradleVersion.version("2.13")) { - thirdPartyAudit.excludes += ['org.slf4j.impl.StaticLoggerBinder'] -}