Skip to content

Commit

Permalink
Use AdoptOpenJDK as the bundled JDK (#46470)
Browse files Browse the repository at this point in the history
This commit teaches the build how to bundle AdoptOpenJDK with our
artifacts, and switches to AdoptOpenJDK as the bundled JDK. We keep the
functionality to also bundle Oracle OpenJDK distributions.
  • Loading branch information
jasontedor authored Sep 17, 2019
1 parent 4670dd7 commit 0562752
Show file tree
Hide file tree
Showing 26 changed files with 989 additions and 117 deletions.
1 change: 1 addition & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ dependencies {
compile localGroovy()

compile 'commons-codec:commons-codec:1.12'
compile 'org.apache.commons:commons-compress:1.19'

compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
Expand Down
1 change: 1 addition & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include 'reaper'
include 'symbolic-link-preserving-tar'
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
public class DistroTestPlugin implements Plugin<Project> {

private static final String SYSTEM_JDK_VERSION = "11.0.2+9";
private static final String SYSTEM_JDK_VENDOR = "openjdk";
private static final String GRADLE_JDK_VERSION = "12.0.1+12@69cfe15208a647278a19ef0990eea691";
private static final String GRADLE_JDK_VENDOR = "openjdk";

// all distributions used by distro tests. this is temporary until tests are per distribution
private static final String DISTRIBUTIONS_CONFIGURATION = "distributions";
Expand Down Expand Up @@ -139,8 +141,10 @@ public void apply(Project project) {
});
}

private static Jdk createJdk(NamedDomainObjectContainer<Jdk> jdksContainer, String name, String version, String platform) {
private static Jdk createJdk(
NamedDomainObjectContainer<Jdk> jdksContainer, String name, String vendor, String version, String platform) {
Jdk jdk = jdksContainer.create(name);
jdk.setVendor(vendor);
jdk.setVersion(version);
jdk.setPlatform(platform);
return jdk;
Expand Down Expand Up @@ -172,11 +176,11 @@ private static List<Object> configureVM(Project project) {
String box = project.getName();

// setup jdks used by the distro tests, and by gradle executing

NamedDomainObjectContainer<Jdk> jdksContainer = JdkDownloadPlugin.getContainer(project);
String platform = box.contains("windows") ? "windows" : "linux";
Jdk systemJdk = createJdk(jdksContainer, "system", SYSTEM_JDK_VERSION, platform);
Jdk gradleJdk = createJdk(jdksContainer, "gradle", GRADLE_JDK_VERSION, platform);
Jdk systemJdk = createJdk(jdksContainer, "system", SYSTEM_JDK_VENDOR, SYSTEM_JDK_VERSION, platform);
Jdk gradleJdk = createJdk(jdksContainer, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, platform);

// setup VM used by these tests
VagrantExtension vagrant = project.getExtensions().getByType(VagrantExtension.class);
Expand Down Expand Up @@ -309,7 +313,7 @@ private static TaskProvider<BatsTestTask> configureBatsTest(Project project, Str
}
});
}

private List<ElasticsearchDistribution> configureDistributions(Project project, Version upgradeVersion) {
NamedDomainObjectContainer<ElasticsearchDistribution> distributions = DistributionDownloadPlugin.getContainer(project);
List<ElasticsearchDistribution> currentDistros = new ArrayList<>();
Expand Down
25 changes: 22 additions & 3 deletions buildSrc/src/main/java/org/elasticsearch/gradle/Jdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@

public class Jdk implements Buildable, Iterable<File> {

static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)(\\.\\d+\\.\\d+)?\\+(\\d+)(@([a-f0-9]{32}))?");
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(Arrays.asList("linux", "windows", "darwin"));
private static final List<String> ALLOWED_VENDORS = List.of("adoptopenjdk", "openjdk");
static final Pattern VERSION_PATTERN =
Pattern.compile("(\\d+)(\\.\\d+\\.\\d+)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?");
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(Arrays.asList("darwin", "linux", "windows"));

private final String name;
private final Configuration configuration;

private final Property<String> vendor;
private final Property<String> version;
private final Property<String> platform;


Jdk(String name, Project project) {
this.name = name;
this.configuration = project.getConfigurations().create("jdk_" + name);
this.vendor = project.getObjects().property(String.class);
this.version = project.getObjects().property(String.class);
this.platform = project.getObjects().property(String.class);
}
Expand All @@ -55,6 +58,17 @@ public String getName() {
return name;
}

public String getVendor() {
return vendor.get();
}

public void setVendor(final String vendor) {
if (ALLOWED_VENDORS.contains(vendor) == false) {
throw new IllegalArgumentException("unknown vendor [" + vendor + "] for jdk [" + name + "], must be one of " + ALLOWED_VENDORS);
}
this.vendor.set(vendor);
}

public String getVersion() {
return version.get();
}
Expand Down Expand Up @@ -105,12 +119,17 @@ void finalizeValues() {
if (platform.isPresent() == false) {
throw new IllegalArgumentException("platform not specified for jdk [" + name + "]");
}
if (vendor.isPresent() == false) {
throw new IllegalArgumentException("vendor not specified for jdk [" + name + "]");
}
version.finalizeValue();
platform.finalizeValue();
vendor.finalizeValue();;
}

@Override
public Iterator<File> iterator() {
return configuration.iterator();
}

}
Loading

0 comments on commit 0562752

Please sign in to comment.