Skip to content

Commit 02c2268

Browse files
committed
Merge remote-tracking branch 'elastic/master' into ccr
* elastic/master: Number of utilities for writing gradle integration tests (#32282) Determine the minimum gradle version based on the wrapper (#32226) Enable FIPS JVM in CI (#32330) Fix JarHell on X-Pack protocol
2 parents d2d7841 + 6aea829 commit 02c2268

File tree

7 files changed

+69
-19
lines changed

7 files changed

+69
-19
lines changed

.ci/matrix-runtime-javas.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
ES_RUNTIME_JAVA:
99
- java8
10+
- java8fips
1011
- java10
1112
- java11

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,17 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
21-
import org.apache.tools.ant.taskdefs.condition.Os
22-
import org.apache.tools.ant.filters.ReplaceTokens
2320
import org.elasticsearch.gradle.BuildPlugin
2421
import org.elasticsearch.gradle.LoggedExec
2522
import org.elasticsearch.gradle.Version
2623
import org.elasticsearch.gradle.VersionCollection
2724
import org.elasticsearch.gradle.VersionProperties
2825
import org.gradle.plugins.ide.eclipse.model.SourceFolder
29-
30-
import org.gradle.api.tasks.wrapper.Wrapper
31-
import org.gradle.api.tasks.wrapper.Wrapper.DistributionType
3226
import org.gradle.util.GradleVersion
3327
import org.gradle.util.DistributionLocator
28+
import org.apache.tools.ant.taskdefs.condition.Os
29+
import org.apache.tools.ant.filters.ReplaceTokens
3430

3531
import java.nio.file.Files
3632
import java.nio.file.Path
@@ -562,7 +558,7 @@ task run(type: Run) {
562558
}
563559

564560
wrapper {
565-
distributionType = DistributionType.ALL
561+
distributionType = 'ALL'
566562
doLast {
567563
final DistributionLocator locator = new DistributionLocator()
568564
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
@@ -571,6 +567,10 @@ wrapper {
571567
final String sha256Sum = new String(sha256Uri.toURL().bytes)
572568
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
573569
println "Added checksum to wrapper properties"
570+
// Update build-tools to reflect the Gradle upgrade
571+
// TODO: we can remove this once we have tests to make sure older versions work.
572+
project(':build-tools').file('src/main/resources/minimumGradleVersion').text = gradleVersion
573+
println "Updated minimum Gradle Version"
574574
}
575575
}
576576

buildSrc/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ plugins {
2525

2626
group = 'org.elasticsearch.gradle'
2727

28-
if (GradleVersion.current() < GradleVersion.version('4.9')) {
29-
throw new GradleException('Gradle 4.9+ is required to build elasticsearch')
28+
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
29+
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
30+
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
3031
}
3132

3233
if (JavaVersion.current() < JavaVersion.VERSION_1_8) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.elasticsearch.gradle
2020

2121
import com.carrotsearch.gradle.junit4.RandomizedTestingTask
2222
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
23+
import org.apache.commons.io.IOUtils
2324
import org.apache.tools.ant.taskdefs.condition.Os
2425
import org.eclipse.jgit.lib.Constants
2526
import org.eclipse.jgit.lib.RepositoryBuilder
@@ -53,6 +54,7 @@ import org.gradle.internal.jvm.Jvm
5354
import org.gradle.process.ExecResult
5455
import org.gradle.util.GradleVersion
5556

57+
import java.nio.charset.StandardCharsets
5658
import java.time.ZoneOffset
5759
import java.time.ZonedDateTime
5860
/**
@@ -67,8 +69,13 @@ class BuildPlugin implements Plugin<Project> {
6769
+ 'elasticearch.standalone-rest-test, and elasticsearch.build '
6870
+ 'are mutually exclusive')
6971
}
70-
if (GradleVersion.current() < GradleVersion.version('4.9')) {
71-
throw new GradleException('Gradle 4.9+ is required to use elasticsearch.build plugin')
72+
final String minimumGradleVersion
73+
InputStream is = getClass().getResourceAsStream("/minimumGradleVersion")
74+
try { minimumGradleVersion = IOUtils.toString(is, StandardCharsets.UTF_8.toString()) } finally { is.close() }
75+
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion.trim())) {
76+
throw new GradleException(
77+
"Gradle ${minimumGradleVersion}+ is required to use elasticsearch.build plugin"
78+
)
7279
}
7380
project.pluginManager.apply('java')
7481
project.pluginManager.apply('carrotsearch.randomized-testing')
@@ -153,14 +160,6 @@ class BuildPlugin implements Plugin<Project> {
153160
}
154161
println " Random Testing Seed : ${project.testSeed}"
155162

156-
// enforce Gradle version
157-
final GradleVersion currentGradleVersion = GradleVersion.current();
158-
159-
final GradleVersion minGradle = GradleVersion.version('4.3')
160-
if (currentGradleVersion < minGradle) {
161-
throw new GradleException("${minGradle} or above is required to build Elasticsearch")
162-
}
163-
164163
// enforce Java version
165164
if (compilerJavaVersionEnum < minimumCompilerVersion) {
166165
final String message =
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.9

buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package org.elasticsearch.gradle.test;
22

3+
import org.gradle.testkit.runner.GradleRunner;
4+
35
import java.io.File;
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
import java.util.stream.Stream;
49

510
public abstract class GradleIntegrationTestCase extends GradleUnitTestCase {
611

@@ -13,4 +18,47 @@ protected File getProjectDir(String name) {
1318
return new File(root, name);
1419
}
1520

21+
protected GradleRunner getGradleRunner(String sampleProject) {
22+
return GradleRunner.create()
23+
.withProjectDir(getProjectDir(sampleProject))
24+
.withPluginClasspath();
25+
}
26+
27+
protected File getBuildDir(String name) {
28+
return new File(getProjectDir(name), "build");
29+
}
30+
31+
protected void assertOutputContains(String output, String... lines) {
32+
for (String line : lines) {
33+
assertOutputContains(output, line);
34+
}
35+
List<Integer> index = Stream.of(lines).map(line -> output.indexOf(line)).collect(Collectors.toList());
36+
if (index.equals(index.stream().sorted().collect(Collectors.toList())) == false) {
37+
fail("Expected the following lines to appear in this order:\n" +
38+
Stream.of(lines).map(line -> " - `" + line + "`").collect(Collectors.joining("\n")) +
39+
"\nBut they did not. Output is:\n\n```" + output + "\n```\n"
40+
);
41+
}
42+
}
43+
44+
protected void assertOutputContains(String output, String line) {
45+
assertTrue(
46+
"Expected the following line in output:\n\n" + line + "\n\nOutput is:\n" + output,
47+
output.contains(line)
48+
);
49+
}
50+
51+
protected void assertOutputDoesNotContain(String output, String line) {
52+
assertFalse(
53+
"Expected the following line not to be in output:\n\n" + line + "\n\nOutput is:\n" + output,
54+
output.contains(line)
55+
);
56+
}
57+
58+
protected void assertOutputDoesNotContain(String output, String... lines) {
59+
for (String line : lines) {
60+
assertOutputDoesNotContain(line);
61+
}
62+
}
63+
1664
}

gradle/wrapper/gradle-wrapper.jar

-4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)