diff --git a/buildSrc/src/main/groovy/com/thoughtworks/go/build/AdoptiumUrlHelper.groovy b/buildSrc/src/main/groovy/com/thoughtworks/go/build/AdoptiumUrlHelper.groovy index 6863d4093001..71837bf90fc5 100644 --- a/buildSrc/src/main/groovy/com/thoughtworks/go/build/AdoptiumUrlHelper.groovy +++ b/buildSrc/src/main/groovy/com/thoughtworks/go/build/AdoptiumUrlHelper.groovy @@ -16,22 +16,13 @@ package com.thoughtworks.go.build -enum OperatingSystem { - windows("zip"), linux("tar.gz"), mac("tar.gz") - - final String extension - - OperatingSystem(String extension) { - this.extension = extension - } -} class AdoptiumUrlHelper { static String downloadURL(OperatingSystem operatingSystem, Integer featureVersion, Integer interimVersion, Integer updateVersion, Integer buildVersion) { String versionComponent = [featureVersion, interimVersion, updateVersion].findAll({ it != null }).join('.') String featureSuffix = updateVersion == null ? '' : 'U' - "https://github.com/adoptium/temurin${featureVersion}-binaries/releases/download/jdk-${versionComponent}%2B${buildVersion}/OpenJDK${featureVersion}${featureSuffix}-jre_x64_${operatingSystem.name()}_hotspot_${versionComponent}_${buildVersion}.${operatingSystem.extension}" + "https://github.com/adoptium/temurin${featureVersion}-binaries/releases/download/jdk-${versionComponent}%2B${buildVersion}/OpenJDK${featureVersion}${featureSuffix}-jre_x64_${operatingSystem.adoptiumAlias()}_hotspot_${versionComponent}_${buildVersion}.${operatingSystem.extension}" } static String sha256sumURL(OperatingSystem operatingSystem, Integer featureVersion, Integer interimVersion, Integer updateVersion, Integer buildVersion) { diff --git a/buildSrc/src/main/groovy/com/thoughtworks/go/build/OperatingSystem.groovy b/buildSrc/src/main/groovy/com/thoughtworks/go/build/OperatingSystem.groovy new file mode 100644 index 000000000000..e2ff4f9a35f4 --- /dev/null +++ b/buildSrc/src/main/groovy/com/thoughtworks/go/build/OperatingSystem.groovy @@ -0,0 +1,31 @@ +/* + * Copyright 2021 ThoughtWorks, Inc. + * + * 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 com.thoughtworks.go.build + +enum OperatingSystem { + windows("zip"), linux("tar.gz"), alpine_linux("tar.gz"), mac("tar.gz") + + final String extension + + OperatingSystem(String extension) { + this.extension = extension + } + + String adoptiumAlias() { + name().replace('_', '-') + } +} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/Distro.groovy b/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/Distro.groovy index 7e0926a274bc..2b137a6208a0 100644 --- a/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/Distro.groovy +++ b/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/Distro.groovy @@ -16,11 +16,17 @@ package com.thoughtworks.go.build.docker +import com.thoughtworks.go.build.OperatingSystem import org.gradle.api.Project enum Distro implements DistroBehavior { alpine{ + @Override + OperatingSystem getOperatingSystem() { + OperatingSystem.linux + } + @Override List getSupportedVersions() { def installSasl_Post_3_9 = ['apk add --no-cache libsasl'] @@ -188,6 +194,11 @@ enum Distro implements DistroBehavior { }, docker{ + @Override + OperatingSystem getOperatingSystem() { + return alpine.getOperatingSystem() + } + @Override boolean isPrivilegedModeSupport() { return true @@ -217,7 +228,6 @@ enum Distro implements DistroBehavior { return alpine.getInstallPrerequisitesCommands(distroVersion) } - @Override List getInstallJavaCommands(Project project) { return alpine.getInstallJavaCommands(project) diff --git a/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/DistroBehavior.groovy b/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/DistroBehavior.groovy index ae8e4de1867e..39b528ef23ed 100644 --- a/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/DistroBehavior.groovy +++ b/buildSrc/src/main/groovy/com/thoughtworks/go/build/docker/DistroBehavior.groovy @@ -17,6 +17,7 @@ package com.thoughtworks.go.build.docker import com.thoughtworks.go.build.AdoptiumUrlHelper +import com.thoughtworks.go.build.OperatingSystem import org.gradle.api.Project trait DistroBehavior { @@ -43,7 +44,7 @@ trait DistroBehavior { List getInstallJavaCommands(Project project) { def downloadUrl = AdoptiumUrlHelper.downloadURL( - com.thoughtworks.go.build.OperatingSystem.linux, + getOperatingSystem(), project.packaging.adoptOpenjdk.featureVersion, project.packaging.adoptOpenjdk.interimVersion, project.packaging.adoptOpenjdk.updateVersion, @@ -57,6 +58,10 @@ trait DistroBehavior { ] } + OperatingSystem getOperatingSystem() { + OperatingSystem.linux + } + Map getEnvironmentVariables(DistroVersion distroVersion) { return [GO_JAVA_HOME: '/gocd-jre'] }