Skip to content

Commit

Permalink
Resolve Temurin JDK archives using adoptium API
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Oct 24, 2023
1 parent db9f1b9 commit 756fd78
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,32 @@
*/
package io.trino.tests.product.launcher.env.jdk;

import com.google.inject.Inject;
import io.trino.testing.containers.TestContainers;
import io.trino.tests.product.launcher.env.EnvironmentOptions;

public class Temurin21RcJdkProvider
public abstract class AdoptiumApiResolvingJdkProvider
extends TarDownloadingJdkProvider
{
// build 35 is considered the first release candidate per https://mail.openjdk.org/pipermail/jdk-dev/2023-August/008059.html
private static final String VERSION = "21-35-ea-beta";

@Inject
public Temurin21RcJdkProvider(EnvironmentOptions environmentOptions)
public AdoptiumApiResolvingJdkProvider(EnvironmentOptions environmentOptions)
{
super(environmentOptions);
}

protected abstract String getReleaseName();

@Override
protected String getDownloadUri(TestContainers.DockerArchitecture architecture)
public String getDescription()
{
return switch (architecture) {
case AMD64 -> "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-%s/OpenJDK21U-jdk_x64_linux_hotspot_ea_21-0-35.tar.gz".formatted(VERSION.replaceFirst("-", "%2B"));
case ARM64 -> "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-%s/OpenJDK21U-jdk_aarch64_linux_hotspot_ea_21-0-35.tar.gz".formatted(VERSION.replaceFirst("-", "%2B"));
default -> throw new IllegalArgumentException("Architecture %s is not supported for Temurin 21-ea-beta distribution".formatted(architecture));
};
return "Temurin " + getReleaseName();
}

@Override
public String getDescription()
protected String getDownloadUri(TestContainers.DockerArchitecture architecture)
{
return "Temurin " + VERSION;
return switch (architecture) {
case AMD64 -> "https://api.adoptium.net/v3/binary/version/%s/linux/%s/jdk/hotspot/normal/eclipse?project=jdk".formatted(getReleaseName(), "x64");
case ARM64 -> "https://api.adoptium.net/v3/binary/version/%s/linux/%s/jdk/hotspot/normal/eclipse?project=jdk".formatted(getReleaseName(), "aarch64");
default -> throw new UnsupportedOperationException("Fetching Temurin JDK for arch " + architecture + " is not supported");
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,20 @@
package io.trino.tests.product.launcher.env.jdk;

import com.google.inject.Inject;
import io.trino.testing.containers.TestContainers;
import io.trino.tests.product.launcher.env.EnvironmentOptions;

public class Temurin19JdkProvider
extends TarDownloadingJdkProvider
extends AdoptiumApiResolvingJdkProvider
{
private static final String VERSION = "19.0.2-7";

@Inject
public Temurin19JdkProvider(EnvironmentOptions environmentOptions)
{
super(environmentOptions);
}

@Override
protected String getDownloadUri(TestContainers.DockerArchitecture architecture)
{
return switch (architecture) {
case AMD64 -> "https://github.com/adoptium/temurin19-binaries/releases/download/jdk-%s/OpenJDK19U-jdk_x64_linux_hotspot_19.0.2_7.tar.gz".formatted(VERSION.replace("-", "%2B"));
case ARM64 -> "https://github.com/adoptium/temurin19-binaries/releases/download/jdk-%s/OpenJDK19U-jdk_aarch64_linux_hotspot_19.0.2_7.tar.gz".formatted(VERSION.replace("-", "%2B"));
default -> throw new IllegalArgumentException("Architecture %s is not supported for Temurin 19 distribution".formatted(architecture));
};
}

@Override
public String getDescription()
protected String getReleaseName()
{
return "Temurin " + VERSION;
return "jdk-19.0.2+7";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,20 @@
package io.trino.tests.product.launcher.env.jdk;

import com.google.inject.Inject;
import io.trino.testing.containers.TestContainers.DockerArchitecture;
import io.trino.tests.product.launcher.env.EnvironmentOptions;

public class Temurin20JdkProvider
extends TarDownloadingJdkProvider
extends AdoptiumApiResolvingJdkProvider
{
private static final String VERSION = "20.0.1-9";

@Inject
public Temurin20JdkProvider(EnvironmentOptions environmentOptions)
{
super(environmentOptions);
}

@Override
protected String getDownloadUri(DockerArchitecture architecture)
{
return switch (architecture) {
case AMD64 -> "https://github.com/adoptium/temurin20-binaries/releases/download/jdk-%s/OpenJDK20U-jdk_x64_linux_hotspot_20.0.1_9.tar.gz".formatted(VERSION.replace("-", "%2B"));
case ARM64 -> "https://github.com/adoptium/temurin20-binaries/releases/download/jdk-%s/OpenJDK20U-jdk_aarch64_linux_hotspot_20.0.1_9.tar.gz".formatted(VERSION.replace("-", "%2B"));
default -> throw new IllegalArgumentException("Architecture %s is not supported for Temurin 20 distribution".formatted(architecture));
};
}

@Override
public String getDescription()
protected String getReleaseName()
{
return "Temurin " + VERSION;
return "jdk-20.0.2+9";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.tests.product.launcher.env.jdk;

import com.google.inject.Inject;
import io.trino.tests.product.launcher.env.EnvironmentOptions;

public class Temurin21JdkProvider
extends AdoptiumApiResolvingJdkProvider
{
@Inject
public Temurin21JdkProvider(EnvironmentOptions environmentOptions)
{
super(environmentOptions);
}

@Override
protected String getReleaseName()
{
return "jdk-21.0.1+12";
}
}

0 comments on commit 756fd78

Please sign in to comment.