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 ad269bc1bb20..f7f941baef1c 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 a19a4d22fc2b..e0067dad4d6f 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'] @@ -193,6 +199,11 @@ enum Distro implements DistroBehavior { }, docker{ + @Override + OperatingSystem getOperatingSystem() { + return alpine.getOperatingSystem() + } + @Override boolean isPrivilegedModeSupport() { return true @@ -222,7 +233,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 470f91a3cf34..26eb7dad9239 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 { @@ -54,7 +55,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, @@ -68,6 +69,10 @@ trait DistroBehavior { ] } + OperatingSystem getOperatingSystem() { + OperatingSystem.linux + } + Map getEnvironmentVariables(DistroVersion distroVersion) { return [GO_JAVA_HOME: '/gocd-jre'] }