Skip to content

Commit f6c27a7

Browse files
committed
Switch build-tools to latest target version (#34746)
- we already require Java 11 to build, yet we target the minimum supported version in build-tools ( currently 8 ) - this is because we have some checks that are executed in a new JVM which could be running the minimum version. - For everything else it would be nice to be able to use new features, like the new process API. With this change, we selectively compile the few classes that need an older target version and move everything over to Java 10. Unfortunately the current Gradle version does not support 11 as a target version yet.
1 parent 7e18294 commit f6c27a7

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

buildSrc/build.gradle

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,12 @@ if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
3434
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
3535
}
3636

37-
if (JavaVersion.current() < JavaVersion.VERSION_1_8) {
38-
throw new GradleException('Java 1.8 is required to build elasticsearch gradle tools')
39-
}
40-
4137
if (project == rootProject) {
4238
// change the build dir used during build init, so that doing a clean
4339
// won't wipe out the buildscript jar
4440
buildDir = 'build-bootstrap'
4541
}
4642

47-
// Make sure :buildSrc: doesn't generate classes incompatible with RUNTIME_JAVA_HOME
48-
// We can't use BuildPlugin here, so read from file
49-
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
50-
targetCompatibility = minimumRuntimeVersion
51-
sourceCompatibility = minimumRuntimeVersion
52-
5343
/*****************************************************************************
5444
* Propagating version.properties to the rest of the build *
5545
*****************************************************************************/
@@ -85,6 +75,45 @@ processResources {
8575
from tempPropertiesFile
8676
}
8777

78+
79+
if (JavaVersion.current() < JavaVersion.VERSION_1_10) {
80+
throw new GradleException('At least Java 10 is required to build elasticsearch gradle tools')
81+
}
82+
83+
/*****************************************************************************
84+
* Java version *
85+
*****************************************************************************/
86+
87+
// Gradle 4.10 does not support setting this to 11 yet
88+
targetCompatibility = "10"
89+
sourceCompatibility = "10"
90+
91+
// We have a few classes that need to be compiled for older java versions because these are used to run checks against
92+
// those
93+
sourceSets {
94+
minimumRuntime {
95+
// We only want Java here, but the Groovy doesn't configure javadoc correctly if we don't define this as groovy
96+
groovy {
97+
srcDirs = ['src/main/minimumRuntime']
98+
}
99+
}
100+
}
101+
compileMinimumRuntimeGroovy {
102+
// We can't use BuildPlugin here, so read from file
103+
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
104+
targetCompatibility = minimumRuntimeVersion
105+
sourceCompatibility = minimumRuntimeVersion
106+
}
107+
dependencies {
108+
compile sourceSets.minimumRuntime.output
109+
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
110+
minimumRuntimeCompile localGroovy()
111+
}
112+
jar {
113+
from sourceSets.minimumRuntime.output
114+
}
115+
116+
88117
/*****************************************************************************
89118
* Dependencies used by the entire build *
90119
*****************************************************************************/
@@ -97,10 +126,7 @@ dependencies {
97126
compile localGroovy()
98127
compile "com.carrotsearch.randomizedtesting:junit4-ant:${props.getProperty('randomizedrunner')}"
99128
compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
100-
101-
compile("junit:junit:${props.getProperty('junit')}") {
102-
transitive = false
103-
}
129+
104130
compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
105131
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
106132
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
@@ -159,6 +185,7 @@ if (project != rootProject) {
159185
dependenciesInfo.enabled = false
160186
forbiddenApisMain.enabled = false
161187
forbiddenApisTest.enabled = false
188+
forbiddenApisMinimumRuntime.enabled = false
162189
jarHell.enabled = false
163190
thirdPartyAudit.enabled = false
164191

0 commit comments

Comments
 (0)