From e37a7d73a25164b8f855cca61797dd6de958d40c Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 24 Jan 2017 20:40:07 +0100 Subject: [PATCH] Remove leftover build files and simplify ProgressLogger usage These files should have been removed in an earlier commit. This commit also simplifies usage of ProgressLoggerWrapper by using the Groovy delegation instead of using explicit delegation. --- .../compile/groovy/gradle-2.13-loggers.groovy | 26 ------------------- .../compile/groovy/gradle-2.14-loggers.groovy | 26 ------------------- ...erWrapper.groovy => ProgressLogger.groovy} | 8 +++--- ...erWrapper.groovy => ProgressLogger.groovy} | 8 +++--- .../gradle/junit4/TestProgressLogger.groovy | 14 +++++----- .../vagrant/TapLoggerOutputStream.groovy | 12 ++++----- .../vagrant/VagrantLoggerOutputStream.groovy | 12 ++++----- 7 files changed, 25 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 rename buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/{ProgressLoggerWrapper.groovy => ProgressLogger.groovy} (86%) rename buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/{ProgressLoggerWrapper.groovy => ProgressLogger.groovy} (84%) 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 ecf4a5674f84d..0000000000000 --- 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 3edc4b4b0ed24..0000000000000 --- 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/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLoggerWrapper.groovy b/buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLogger.groovy similarity index 86% rename from buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLoggerWrapper.groovy rename to buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLogger.groovy index ac2495403d361..5c02e255a1a8a 100644 --- a/buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLoggerWrapper.groovy +++ b/buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLogger.groovy @@ -18,16 +18,14 @@ */ package org.elasticsearch.gradle -import org.gradle.logging.ProgressLogger - /** * Wraps a ProgressLogger so that code in src/main/groovy does not need to * define imports on Gradle 2.13/2.14+ ProgressLoggers */ -class ProgressLoggerWrapper { - ProgressLogger progressLogger +class ProgressLogger { + @Delegate org.gradle.logging.ProgressLogger progressLogger - ProgressLoggerWrapper(ProgressLogger progressLogger) { + ProgressLogger(org.gradle.logging.ProgressLogger progressLogger) { this.progressLogger = progressLogger } } diff --git a/buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLoggerWrapper.groovy b/buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLogger.groovy similarity index 84% rename from buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLoggerWrapper.groovy rename to buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLogger.groovy index 083506fc3681a..2c9fab78b4378 100644 --- a/buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLoggerWrapper.groovy +++ b/buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLogger.groovy @@ -18,16 +18,14 @@ */ package org.elasticsearch.gradle -import org.gradle.internal.logging.progress.ProgressLogger - /** * Wraps a ProgressLogger so that code in src/main/groovy does not need to * define imports on Gradle 2.13/2.14+ ProgressLoggers */ -class ProgressLoggerWrapper { - ProgressLogger progressLogger +class ProgressLogger { + @Delegate org.gradle.internal.logging.progress.ProgressLogger progressLogger - ProgressLoggerWrapper(ProgressLogger progressLogger) { + ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger progressLogger) { this.progressLogger = progressLogger } } 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 dad41a3fc6900..a9786935c5651 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy @@ -25,7 +25,7 @@ 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.elasticsearch.gradle.ProgressLoggerWrapper +import org.elasticsearch.gradle.ProgressLogger import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.formatDurationInSeconds import static com.carrotsearch.ant.tasks.junit4.events.aggregated.TestStatus.ERROR @@ -51,7 +51,7 @@ import static java.lang.Math.max * quick. */ class TestProgressLogger implements AggregatedEventListener { - ProgressLoggerWrapper progressLoggerWrapper + ProgressLogger progressLogger int totalSuites int totalSlaves @@ -77,16 +77,16 @@ class TestProgressLogger implements AggregatedEventListener { lets us move things around without worying about breaking things. */ TestProgressLogger(Map args) { - progressLoggerWrapper = new ProgressLoggerWrapper(args.factory.newOperation(TestProgressLogger)) - progressLoggerWrapper.progressLogger.setDescription('Randomized test runner') + progressLogger = new ProgressLogger(args.factory.newOperation(TestProgressLogger)) + progressLogger.setDescription('Randomized test runner') } @Subscribe void onStart(AggregatedStartEvent e) throws IOException { totalSuites = e.suiteCount totalSlaves = e.slaveCount - progressLoggerWrapper.progressLogger.started() - progressLoggerWrapper.progressLogger.progress( + progressLogger.started() + progressLogger.progress( "Starting JUnit4 for ${totalSuites} suites on ${totalSlaves} jvms") suitesFormat = "%0${widthForTotal(totalSuites)}d" @@ -178,7 +178,7 @@ class TestProgressLogger implements AggregatedEventListener { log += "J${sprintf(slavesFormat, eventSlave)} " } log += "completed ${eventDescription}" - progressLoggerWrapper.progressLogger.progress(log) + progressLogger.progress(log) } private static int widthForTotal(int total) { 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 4d6104c79c738..85fd433bc771f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy @@ -20,7 +20,7 @@ package org.elasticsearch.gradle.vagrant import com.carrotsearch.gradle.junit4.LoggingOutputStream import groovy.transform.PackageScope -import org.elasticsearch.gradle.ProgressLoggerWrapper +import org.elasticsearch.gradle.ProgressLogger import org.gradle.api.GradleScriptException import org.gradle.api.logging.Logger @@ -37,7 +37,7 @@ import java.util.regex.Matcher * entire TAP stream at once and won't parse it stream-wise. */ public class TapLoggerOutputStream extends LoggingOutputStream { - private final ProgressLoggerWrapper progressLoggerWrapper + private final ProgressLogger progressLogger private boolean isStarted = false private final Logger logger private int testsCompleted = 0 @@ -48,14 +48,14 @@ public class TapLoggerOutputStream extends LoggingOutputStream { TapLoggerOutputStream(Map args) { logger = args.logger - progressLoggerWrapper = new ProgressLoggerWrapper(args.factory.newOperation(VagrantLoggerOutputStream)) - progressLoggerWrapper.progressLogger.setDescription("TAP output for `${args.command}`") + progressLogger = new ProgressLogger(args.factory.newOperation(VagrantLoggerOutputStream)) + progressLogger.setDescription("TAP output for `${args.command}`") } @Override public void flush() { if (isStarted == false) { - progressLoggerWrapper.progressLogger.started() + progressLogger.started() isStarted = true } if (end == start) return @@ -104,7 +104,7 @@ public class TapLoggerOutputStream extends LoggingOutputStream { String counts = sprintf(countsFormat, [testsCompleted, testsFailed, testsSkipped, testCount]) - progressLoggerWrapper.progressLogger.progress("Tests $counts, $status [$suiteName] $testName") + progressLogger.progress("Tests $counts, $status [$suiteName] $testName") if (!success) { logger.warn(line) } 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 fbfc736eb1337..de6c5a36db945 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy @@ -19,7 +19,7 @@ package org.elasticsearch.gradle.vagrant import com.carrotsearch.gradle.junit4.LoggingOutputStream -import org.elasticsearch.gradle.ProgressLoggerWrapper +import org.elasticsearch.gradle.ProgressLogger /** * Adapts an OutputStream being written to by vagrant into a ProcessLogger. It @@ -45,7 +45,7 @@ import org.elasticsearch.gradle.ProgressLoggerWrapper public class VagrantLoggerOutputStream extends LoggingOutputStream { private static final String HEADING_PREFIX = '==> ' - private final ProgressLoggerWrapper progressLoggerWrapper + private final ProgressLogger progressLogger private boolean isStarted = false private String squashedPrefix private String lastLine = '' @@ -53,15 +53,15 @@ public class VagrantLoggerOutputStream extends LoggingOutputStream { private String heading = '' VagrantLoggerOutputStream(Map args) { - progressLoggerWrapper = new ProgressLoggerWrapper(args.factory.newOperation(VagrantLoggerOutputStream)) - progressLoggerWrapper.progressLogger.setDescription("Vagrant output for `$args.command`") + progressLogger = new ProgressLogger(args.factory.newOperation(VagrantLoggerOutputStream)) + progressLogger.setDescription("Vagrant output for `$args.command`") squashedPrefix = args.squashedPrefix } @Override public void flush() { if (isStarted == false) { - progressLoggerWrapper.progressLogger.started() + progressLogger.started() isStarted = true } if (end == start) return @@ -96,6 +96,6 @@ public class VagrantLoggerOutputStream extends LoggingOutputStream { } else { return } - progressLoggerWrapper.progressLogger.progress(line) + progressLogger.progress(line) } }