Skip to content

Commit

Permalink
Keep BuildParams.ci for now for easy serverless migration
Browse files Browse the repository at this point in the history
  • Loading branch information
breskeby committed Oct 25, 2024
1 parent 32f10b0 commit 4bdf850
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,13 @@
*/
package org.elasticsearch.gradle.internal.info;

import org.elasticsearch.gradle.internal.BwcVersions;
import org.gradle.api.Action;
import org.gradle.api.JavaVersion;
import org.gradle.api.provider.Provider;
import org.gradle.jvm.toolchain.JavaToolchainSpec;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

import static java.util.Objects.requireNonNull;

@Deprecated
public class BuildParams {
private static Provider<File> runtimeJavaHome;
private static Boolean isRuntimeJavaHomeSet;
private static List<JavaHome> javaVersions;
private static JavaVersion minimumCompilerVersion;
private static JavaVersion minimumRuntimeVersion;
private static JavaVersion gradleJavaVersion;
private static Provider<JavaVersion> runtimeJavaVersion;
private static Provider<? extends Action<JavaToolchainSpec>> javaToolChainSpec;
private static Provider<String> runtimeJavaDetails;
private static String gitRevision;
private static String gitOrigin;
private static ZonedDateTime buildDate;
private static String testSeed;
private static Boolean isCi;
private static Integer defaultParallel;
private static Boolean isSnapshotBuild;
private static Provider<BwcVersions> bwcVersions;

/**
* Initialize global build parameters. This method accepts and a initialization function which in turn accepts a
Expand All @@ -56,18 +28,6 @@ public static void init(Consumer<MutableBuildParams> initializer) {
initializer.accept(MutableBuildParams.INSTANCE);
}

public static Boolean getIsRuntimeJavaHomeSet() {
return value(isRuntimeJavaHomeSet);
}

public static JavaVersion getRuntimeJavaVersion() {
return value(runtimeJavaVersion.get());
}

public static BwcVersions getBwcVersions() {
return value(bwcVersions).get();
}

public static Boolean isCi() {
return value(isCi);
}
Expand Down Expand Up @@ -113,78 +73,8 @@ public void reset() {
});
}

public void setRuntimeJavaHome(Provider<File> runtimeJavaHome) {
BuildParams.runtimeJavaHome = runtimeJavaHome.map(javaHome -> {
try {
return javaHome.getCanonicalFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}

public void setIsRuntimeJavaHomeSet(boolean isRuntimeJavaHomeSet) {
BuildParams.isRuntimeJavaHomeSet = isRuntimeJavaHomeSet;
}

public void setJavaVersions(List<JavaHome> javaVersions) {
BuildParams.javaVersions = requireNonNull(javaVersions);
}

public void setMinimumCompilerVersion(JavaVersion minimumCompilerVersion) {
BuildParams.minimumCompilerVersion = requireNonNull(minimumCompilerVersion);
}

public void setMinimumRuntimeVersion(JavaVersion minimumRuntimeVersion) {
BuildParams.minimumRuntimeVersion = requireNonNull(minimumRuntimeVersion);
}

public void setGradleJavaVersion(JavaVersion gradleJavaVersion) {
BuildParams.gradleJavaVersion = requireNonNull(gradleJavaVersion);
}

public void setRuntimeJavaVersion(Provider<JavaVersion> runtimeJavaVersion) {
BuildParams.runtimeJavaVersion = requireNonNull(runtimeJavaVersion);
}

public void setRuntimeJavaDetails(Provider<String> runtimeJavaDetails) {
BuildParams.runtimeJavaDetails = runtimeJavaDetails;
}

public void setGitRevision(String gitRevision) {
BuildParams.gitRevision = requireNonNull(gitRevision);
}

public void setGitOrigin(String gitOrigin) {
BuildParams.gitOrigin = requireNonNull(gitOrigin);
}

public void setBuildDate(ZonedDateTime buildDate) {
BuildParams.buildDate = requireNonNull(buildDate);
}

public void setTestSeed(String testSeed) {
BuildParams.testSeed = requireNonNull(testSeed);
}

public void setIsCi(boolean isCi) {
BuildParams.isCi = isCi;
}

public void setDefaultParallel(int defaultParallel) {
BuildParams.defaultParallel = defaultParallel;
}

public void setIsSnapshotBuild(final boolean isSnapshotBuild) {
BuildParams.isSnapshotBuild = isSnapshotBuild;
}

public void setBwcVersions(Provider<BwcVersions> bwcVersions) {
BuildParams.bwcVersions = requireNonNull(bwcVersions);
}

public void setJavaToolChainSpec(Provider<? extends Action<JavaToolchainSpec>> javaToolChain) {
BuildParams.javaToolChainSpec = javaToolChain;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,38 +152,12 @@ public void apply(Project project) {
spec.getParameters().getBuildParams().set(buildParams);
});

// BuildParams.init(params -> {
// params.reset();
// params.setRuntimeJavaHome(actualRuntimeJavaHome);
// params.setJavaToolChainSpec(resolveToolchainSpecFromEnv());
// params.setRuntimeJavaVersion(
// actualRuntimeJavaHome.map(
// javaHome -> determineJavaVersion(
// "runtime java.home",
// javaHome,
// isRuntimeJavaHomeExplicitlySet
// ? minimumRuntimeVersion
// : JavaVersion.toVersion(VersionProperties.getBundledJdkMajorVersion())
// )
// )
// );
// params.setIsRuntimeJavaHomeSet(isRuntimeJavaHomeExplicitlySet);
// params.setRuntimeJavaDetails(runtimeJdkMetaData.map(m -> formatJavaVendorDetails(m)));
// params.setJavaVersions(getAvailableJavaVersions());
// params.setMinimumCompilerVersion(minimumCompilerVersion);
// params.setMinimumRuntimeVersion(minimumRuntimeVersion);
// params.setGradleJavaVersion(Jvm.current().getJavaVersion());
// params.setGitRevision(gitInfo.getRevision());
// params.setGitOrigin(gitInfo.getOrigin());
// params.setBuildDate(ZonedDateTime.now(ZoneOffset.UTC));
// params.setTestSeed(getTestSeed());
// params.setIsCi(
// System.getenv("JENKINS_URL") != null || System.getenv("BUILDKITE_BUILD_URL") != null || System.getProperty("isCI") != null
// );
// params.setDefaultParallel(ParallelDetector.findDefaultParallel(project));
// params.setIsSnapshotBuild(Util.getBooleanProperty("build.snapshot", true));
// params.setBwcVersions(bwcVersionsProvider);
// });
BuildParams.init(params -> {
params.reset();
params.setIsCi(
System.getenv("JENKINS_URL") != null || System.getenv("BUILDKITE_BUILD_URL") != null || System.getProperty("isCI") != null
);
});

// Enforce the minimum compiler version
assertMinimumCompilerVersion(minimumCompilerVersion);
Expand Down

0 comments on commit 4bdf850

Please sign in to comment.