Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate minimum compiler and runtime Java version properties #79108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
import org.gradle.api.provider.ProviderFactory;
import org.gradle.api.services.BuildService;
import org.gradle.api.services.BuildServiceParameters;
import org.gradle.initialization.layout.BuildLayout;
import org.gradle.initialization.layout.BuildLayoutFactory;

import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import javax.inject.Inject;

abstract class VersionPropertiesBuildService implements BuildService<VersionPropertiesBuildService.Params>, AutoCloseable {

Expand All @@ -33,15 +31,24 @@ public VersionPropertiesBuildService(ProviderFactory providerFactory) {
try {
File propertiesInputFile = new File(infoPath, "version.properties");
properties = VersionPropertiesLoader.loadBuildSrcVersion(propertiesInputFile, providerFactory);
properties.computeIfAbsent("minimumJava", s -> resolveMinimumJavaVersion(infoPath));
properties.computeIfAbsent("minimumRuntimeJava", s -> resolveMinimumRuntimeJavaVersion(infoPath));
properties.computeIfAbsent("minimumCompilerJava", s -> resolveMinimumCompilerJavaVersion(infoPath));
} catch (IOException e) {
throw new GradleException("Cannot load VersionPropertiesBuildService", e);
}
}

private JavaVersion resolveMinimumJavaVersion(File infoPath) {
private JavaVersion resolveMinimumRuntimeJavaVersion(File infoPath) {
return resolveJavaVersion(infoPath, "src/main/resources/minimumRuntimeVersion");
}

private JavaVersion resolveMinimumCompilerJavaVersion(File infoPath) {
return resolveJavaVersion(infoPath, "src/main/resources/minimumCompilerVersion");
}

private JavaVersion resolveJavaVersion(File infoPath, String path) {
final JavaVersion minimumJavaVersion;
File minimumJavaInfoSource = new File(infoPath, "src/main/resources/minimumRuntimeVersion");
File minimumJavaInfoSource = new File(infoPath, path);
try {
String versionString = FileUtils.readFileToString(minimumJavaInfoSource);
minimumJavaVersion = JavaVersion.toVersion(versionString);
Expand Down
9 changes: 1 addition & 8 deletions build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
* Side Public License, v 1.
*/


import org.elasticsearch.gradle.internal.conventions.VersionPropertiesLoader
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.gradle.plugins.ide.eclipse.model.ProjectDependency

plugins {
id 'java-gradle-plugin'
id 'groovy-gradle-plugin'
Expand Down Expand Up @@ -169,7 +162,7 @@ gradlePlugin {
* Java version *
*****************************************************************************/

def minCompilerJava = versions.get("minimumJava")
def minCompilerJava = versions.get("minimumCompilerJava")
targetCompatibility = minCompilerJava
sourceCompatibility = minCompilerJava

Expand Down
5 changes: 2 additions & 3 deletions build-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import org.elasticsearch.gradle.internal.conventions.VersionPropertiesLoader

plugins {
id 'java-gradle-plugin'
Expand All @@ -21,8 +20,8 @@ description = "The elasticsearch build tools"

group = "org.elasticsearch.gradle"
version = versions.getProperty("elasticsearch")
targetCompatibility = versions.get("minimumJava")
sourceCompatibility = versions.get("minimumJava")
targetCompatibility = versions.get("minimumRuntimeJava")
sourceCompatibility = versions.get("minimumRuntimeJava")

gradlePlugin {
// We already configure publication and we don't need or want the one that comes
Expand Down
4 changes: 2 additions & 2 deletions build-tools/reaper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins {

group = "org.elasticsearch.gradle"
version = versions.getProperty("elasticsearch")
targetCompatibility = versions.get("minimumJava")
sourceCompatibility = versions.get("minimumJava")
targetCompatibility = versions.get("minimumRuntimeJava")
sourceCompatibility = versions.get("minimumRuntimeJava")

tasks.named("jar").configure {
archiveFileName = "${project.name}.jar"
Expand Down