Skip to content

Commit 179eb1a

Browse files
alpar-tkcm
authored andcommitted
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 9c6ca44 commit 179eb1a

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
@@ -31,22 +31,12 @@ if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
3131
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
3232
}
3333

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

44-
// Make sure :buildSrc: doesn't generate classes incompatible with RUNTIME_JAVA_HOME
45-
// We can't use BuildPlugin here, so read from file
46-
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
47-
targetCompatibility = minimumRuntimeVersion
48-
sourceCompatibility = minimumRuntimeVersion
49-
5040
/*****************************************************************************
5141
* Propagating version.properties to the rest of the build *
5242
*****************************************************************************/
@@ -82,6 +72,45 @@ processResources {
8272
from tempPropertiesFile
8373
}
8474

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

0 commit comments

Comments
 (0)