Skip to content

Commit 209ff20

Browse files
committed
Build: remove progress logger hack for gradle 2.13 (#23679)
We are now on minimum gradle 3.3, so we no longer need the groovy/gradle hacks used to support both 2.13 and 2.14+.
1 parent 64f1b92 commit 209ff20

File tree

10 files changed

+34
-164
lines changed

10 files changed

+34
-164
lines changed

buildSrc/build.gradle

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,12 @@ dependencies {
9696
compile 'org.apache.rat:apache-rat:0.11'
9797
}
9898

99-
// Gradle version-specific options (allows build to run with Gradle 2.13 as well as 2.14+/3.+)
100-
if (GradleVersion.current() == GradleVersion.version("2.13")) {
101-
// ProgressLogger(-Factory) classes are part of the public Gradle API
102-
sourceSets.main.groovy.srcDir 'src/main/gradle-2.13-groovy'
99+
// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs
100+
// Use logging dependency instead
103101

104-
dependencies {
105-
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.0.1' // last version compatible with Gradle 2.13
106-
}
107-
} else {
108-
// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs
109-
// Use logging dependency instead
110-
sourceSets.main.groovy.srcDir 'src/main/gradle-2.14-groovy'
111-
112-
dependencies {
113-
compileOnly "org.gradle:gradle-logging:${GradleVersion.current().getVersion()}"
114-
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.2.0' // Gradle 2.14 requires a version > 1.0.1
115-
}
102+
dependencies {
103+
compileOnly "org.gradle:gradle-logging:${GradleVersion.current().getVersion()}"
104+
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.2.0' // Gradle 2.14 requires a version > 1.0.1
116105
}
117106

118107
/*****************************************************************************

buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLogger.groovy

Lines changed: 0 additions & 31 deletions
This file was deleted.

buildSrc/src/main/gradle-2.13-groovy/org/elasticsearch/gradle/ProgressLoggerFactoryInjection.groovy

Lines changed: 0 additions & 35 deletions
This file was deleted.

buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLogger.groovy

Lines changed: 0 additions & 31 deletions
This file was deleted.

buildSrc/src/main/gradle-2.14-groovy/org/elasticsearch/gradle/ProgressLoggerFactoryInjection.groovy

Lines changed: 0 additions & 35 deletions
This file was deleted.

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import org.apache.tools.ant.BuildException
88
import org.apache.tools.ant.DefaultLogger
99
import org.apache.tools.ant.RuntimeConfigurable
1010
import org.apache.tools.ant.UnknownElement
11-
import org.elasticsearch.gradle.ProgressLoggerFactoryInjection
1211
import org.gradle.api.DefaultTask
1312
import org.gradle.api.file.FileCollection
1413
import org.gradle.api.file.FileTreeElement
@@ -20,9 +19,12 @@ import org.gradle.api.tasks.Optional
2019
import org.gradle.api.tasks.TaskAction
2120
import org.gradle.api.tasks.util.PatternFilterable
2221
import org.gradle.api.tasks.util.PatternSet
22+
import org.gradle.internal.logging.progress.ProgressLoggerFactory
2323
import org.gradle.util.ConfigureUtil
2424

25-
class RandomizedTestingTask extends DefaultTask implements ProgressLoggerFactoryInjection {
25+
import javax.inject.Inject
26+
27+
class RandomizedTestingTask extends DefaultTask {
2628

2729
// TODO: change to "executable" to match gradle test params?
2830
@Optional
@@ -92,6 +94,11 @@ class RandomizedTestingTask extends DefaultTask implements ProgressLoggerFactory
9294
listenersConfig.listeners.add(new TestReportLogger(logger: logger, config: testLoggingConfig))
9395
}
9496

97+
@Inject
98+
ProgressLoggerFactory getProgressLoggerFactory() {
99+
throw new UnsupportedOperationException()
100+
}
101+
95102
void jvmArgs(Iterable<String> arguments) {
96103
jvmArgs.addAll(arguments)
97104
}

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedStartEvent
2525
import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedSuiteResultEvent
2626
import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedTestResultEvent
2727
import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener
28-
import org.elasticsearch.gradle.ProgressLogger
28+
import org.gradle.internal.logging.progress.ProgressLogger
29+
import org.gradle.internal.logging.progress.ProgressLoggerFactory
2930

3031
import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.formatDurationInSeconds
3132
import static com.carrotsearch.ant.tasks.junit4.events.aggregated.TestStatus.ERROR
@@ -51,6 +52,8 @@ import static java.lang.Math.max
5152
* quick.
5253
*/
5354
class TestProgressLogger implements AggregatedEventListener {
55+
/** Factory to build a progress logger when testing starts */
56+
ProgressLoggerFactory factory
5457
ProgressLogger progressLogger
5558
int totalSuites
5659
int totalSlaves
@@ -74,17 +77,14 @@ class TestProgressLogger implements AggregatedEventListener {
7477
/** Have we finished a whole suite yet? */
7578
volatile boolean suiteFinished = false
7679
/* Note that we probably overuse volatile here but it isn't hurting us and
77-
lets us move things around without worying about breaking things. */
78-
79-
TestProgressLogger(Map args) {
80-
progressLogger = new ProgressLogger(args.factory.newOperation(TestProgressLogger))
81-
progressLogger.setDescription('Randomized test runner')
82-
}
80+
lets us move things around without worrying about breaking things. */
8381

8482
@Subscribe
8583
void onStart(AggregatedStartEvent e) throws IOException {
8684
totalSuites = e.suiteCount
8785
totalSlaves = e.slaveCount
86+
progressLogger = factory.newOperation(TestProgressLogger)
87+
progressLogger.setDescription('Randomized test runner')
8888
progressLogger.started()
8989
progressLogger.progress(
9090
"Starting JUnit4 for ${totalSuites} suites on ${totalSlaves} jvms")

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/TapLoggerOutputStream.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
package org.elasticsearch.gradle.vagrant
2020

2121
import com.carrotsearch.gradle.junit4.LoggingOutputStream
22-
import groovy.transform.PackageScope
23-
import org.elasticsearch.gradle.ProgressLogger
2422
import org.gradle.api.GradleScriptException
2523
import org.gradle.api.logging.Logger
24+
import org.gradle.internal.logging.progress.ProgressLogger
2625

2726
import java.util.regex.Matcher
2827

@@ -48,7 +47,7 @@ public class TapLoggerOutputStream extends LoggingOutputStream {
4847

4948
TapLoggerOutputStream(Map args) {
5049
logger = args.logger
51-
progressLogger = new ProgressLogger(args.factory.newOperation(VagrantLoggerOutputStream))
50+
progressLogger = args.factory.newOperation(VagrantLoggerOutputStream)
5251
progressLogger.setDescription("TAP output for `${args.command}`")
5352
}
5453

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantCommandTask.groovy

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
package org.elasticsearch.gradle.vagrant
2020

2121
import org.apache.commons.io.output.TeeOutputStream
22-
import org.elasticsearch.gradle.ProgressLoggerFactoryInjection
2322
import org.elasticsearch.gradle.LoggedExec
2423
import org.gradle.api.tasks.Input
24+
import org.gradle.internal.logging.progress.ProgressLoggerFactory
25+
26+
import javax.inject.Inject
2527

2628
/**
2729
* Runs a vagrant command. Pretty much like Exec task but with a nicer output
2830
* formatter and defaults to `vagrant` as first part of commandLine.
2931
*/
30-
public class VagrantCommandTask extends LoggedExec implements ProgressLoggerFactoryInjection {
32+
public class VagrantCommandTask extends LoggedExec {
3133

3234
@Input
3335
String boxName
@@ -47,6 +49,11 @@ public class VagrantCommandTask extends LoggedExec implements ProgressLoggerFact
4749
}
4850
}
4951

52+
@Inject
53+
ProgressLoggerFactory getProgressLoggerFactory() {
54+
throw new UnsupportedOperationException()
55+
}
56+
5057
protected OutputStream createLoggerOutputStream() {
5158
return new VagrantLoggerOutputStream(
5259
command: commandLine.join(' '),

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantLoggerOutputStream.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.elasticsearch.gradle.vagrant
2020

2121
import com.carrotsearch.gradle.junit4.LoggingOutputStream
22-
import org.elasticsearch.gradle.ProgressLogger
22+
import org.gradle.internal.logging.progress.ProgressLogger
2323

2424
/**
2525
* Adapts an OutputStream being written to by vagrant into a ProcessLogger. It
@@ -53,7 +53,7 @@ public class VagrantLoggerOutputStream extends LoggingOutputStream {
5353
private String heading = ''
5454

5555
VagrantLoggerOutputStream(Map args) {
56-
progressLogger = new ProgressLogger(args.factory.newOperation(VagrantLoggerOutputStream))
56+
progressLogger = args.factory.newOperation(VagrantLoggerOutputStream)
5757
progressLogger.setDescription("Vagrant output for `$args.command`")
5858
squashedPrefix = args.squashedPrefix
5959
}

0 commit comments

Comments
 (0)