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.
This commit is contained in:
Yannick Welsch 2017-01-24 20:40:07 +01:00
parent 5103b76610
commit e37a7d73a2
7 changed files with 25 additions and 81 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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) {

View File

@ -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)
}

View File

@ -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)
}
}