From f61702c00623daf52a9a7a6cc592c748845cab10 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Mon, 7 Mar 2022 23:29:39 +0100 Subject: [PATCH 01/84] Add Homebrew support (#1042) * Add Homebrew formula template * Add brew packager * Remove selfupdate functionality when installed via Homebrew * Configure JRELEASER_HOMEBREW_GITHUB_TOKEN * Order configuration alphabetically --- .github/workflows/release.yml | 1 + gradle/release.gradle | 5 +- .../sdkman-cli/brew/README.md.tpl | 29 ++++++ .../sdkman-cli/brew/formula.rb.tpl | 35 +++++++ src/main/bash/sdkman-help.sh | 6 +- src/main/bash/sdkman-main.sh | 10 +- .../sdkman/env/SdkmanBashEnvBuilder.groovy | 3 +- .../groovy/sdkman/specs/SelfupdateSpec.groovy | 91 +++++++++++++++++++ 8 files changed, 173 insertions(+), 7 deletions(-) create mode 100644 src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl create mode 100644 src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl create mode 100644 src/test/groovy/sdkman/specs/SelfupdateSpec.groovy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 285c92244..d10656121 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,7 @@ jobs: JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} + JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} services: mongodb: image: mongo:3.2 diff --git a/gradle/release.gradle b/gradle/release.gradle index 7d20c6a3d..641870020 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -35,9 +35,12 @@ jreleaser { artifact { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" } + brew { + active = 'ALWAYS' + } } } - + announce { twitter { active = 'RELEASE' diff --git a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl new file mode 100644 index 000000000..8c000a8b9 --- /dev/null +++ b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl @@ -0,0 +1,29 @@ +# SDKMAN! Homebrew Tap + +A Homebrew tap containing the Formula for the SDKMAN! CLI. + +## Installation + +```sh +$ brew tap sdkman/tap +$ brew install sdkman +``` + +After successful installation add the following lines to the end of your `.bash_profile` + +```sh +export SDKMAN_DIR=$(brew --prefix sdkman)/libexec +[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh" +``` + +Open a new terminal and type + +```sh +sdk version +``` + +The output should look similar to this + +```sh +SDKMAN {{version}} +``` \ No newline at end of file diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl new file mode 100644 index 000000000..d42d839e0 --- /dev/null +++ b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl @@ -0,0 +1,35 @@ +class {{brewFormulaName}} < Formula + desc "{{projectDescription}}" + homepage "{{projectWebsite}}" + url "{{distributionUrl}}" + version "{{projectVersion}}" + sha256 "{{distributionChecksumSha256}}" + license "{{projectLicense}}" + + def install + libexec.install Dir["*"] + + %w[tmp ext etc var archives candidates].each { |dir| mkdir libexec/dir } + + system "curl", "-s", "https://api.sdkman.io/2/candidates/all", "-o", libexec/"var/candidates" + + (libexec/"etc/config").write <<~EOS + sdkman_auto_answer=false + sdkman_auto_complete=true + sdkman_auto_env=false + sdkman_auto_update=false + sdkman_beta_channel=false + sdkman_colour_enable=true + sdkman_curl_connect_timeout=7 + sdkman_curl_max_time=10 + sdkman_debug_mode=false + sdkman_insecure_ssl=false + sdkman_rosetta2_compatible=false + sdkman_selfupdate_feature=false + EOS + end + + test do + assert_match {{projectVersion}}, shell_output("export SDKMAN_DIR=#{libexec} && source #{libexec}/bin/sdkman-init.sh && sdk version") + end +end diff --git a/src/main/bash/sdkman-help.sh b/src/main/bash/sdkman-help.sh index 88eebfc6e..6fe593bac 100644 --- a/src/main/bash/sdkman-help.sh +++ b/src/main/bash/sdkman-help.sh @@ -36,7 +36,11 @@ function __sdk_help() { __sdkman_echo_no_colour " broadcast or b" __sdkman_echo_no_colour " help" __sdkman_echo_no_colour " offline [enable|disable]" - __sdkman_echo_no_colour " selfupdate [force]" + + if [[ "$sdkman_selfupdate_feature" == "true" ]]; then + __sdkman_echo_no_colour " selfupdate [force]" + fi + __sdkman_echo_no_colour " update" __sdkman_echo_no_colour " flush [archives|tmp|broadcast|metadata|version]" __sdkman_echo_no_colour "" diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index d134231e2..ee51b0d87 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -103,9 +103,11 @@ function sdk() { # Check if it is a valid command CMD_FOUND="" - CMD_TARGET="${SDKMAN_DIR}/src/sdkman-${COMMAND}.sh" - if [[ -f "$CMD_TARGET" ]]; then - CMD_FOUND="$CMD_TARGET" + if [[ "$COMMAND" != "selfupdate" || "$sdkman_selfupdate_feature" == "true" ]]; then + CMD_TARGET="${SDKMAN_DIR}/src/sdkman-${COMMAND}.sh" + if [[ -f "$CMD_TARGET" ]]; then + CMD_FOUND="$CMD_TARGET" + fi fi # Check if it is a sourced function @@ -165,7 +167,7 @@ function sdk() { fi # Attempt upgrade after all is done - if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_enable" == true ]]; then + if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_feature" == "true" && "$sdkman_auto_update" == "true" ]]; then __sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION" fi return $final_rc diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index e24b22be2..ee6d0e6ed 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -30,7 +30,8 @@ class SdkmanBashEnvBuilder { Map config = [ sdkman_auto_answer : 'false', - sdkman_beta_channel: 'false' + sdkman_beta_channel: 'false', + sdkman_selfupdate_feature: 'true' ] File sdkmanDir, sdkmanBinDir, sdkmanVarDir, sdkmanSrcDir, sdkmanEtcDir, sdkmanExtDir, sdkmanArchivesDir, diff --git a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy new file mode 100644 index 000000000..2ac64e547 --- /dev/null +++ b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy @@ -0,0 +1,91 @@ +package sdkman.specs + +import sdkman.support.SdkmanEnvSpecification + +import java.time.Instant + +import static java.time.temporal.ChronoUnit.DAYS + +class SelfupdateSpec extends SdkmanEnvSpecification { + static final String CANDIDATES_API = "http://localhost:8080/2" + static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final String VERSION_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" + + def setup() { + curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(VERSION_ENDPOINT, "echo 5.0.0") + } + + def "should list selfupdate as a valid command when the selfupdate feature is toggled on"() { + given: + bash = sdkmanBashEnvBuilder + .withConfiguration("sdkman_selfupdate_feature", selfUpdateFeature) + .build() + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk help") + + then: + verifyOutput(bash.output) + + where: + selfUpdateFeature | verifyOutput + "false" | { !it.contains("selfupdate") } + "true" | { it.contains("selfupdate") } + } + + def "should source sdkman-selfupdate.sh when the selfupdate feature is toggled on"() { + given: + bash = sdkmanBashEnvBuilder + .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) + .build() + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk selfupdate") + + then: + verifyOutput(bash.output) + + where: + selfupdateFeature | verifyOutput + "false" | { it.contains("Invalid command: selfupdate") } + "true" | { it.contains("No update available at this time.") } + } + + def "should perform an autoupdate when the selfupdate feature is toggled on and autoupdate is enabled"() { + given: + new File("$sdkmanDotDirectory/var/delay_upgrade").with { + parentFile.mkdirs() + createNewFile() + lastModified = Instant.now().minus(2, DAYS).toEpochMilli() + } + + bash = sdkmanBashEnvBuilder + .withSdkmanVersion("4.0.0") + .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) + .withConfiguration("sdkman_auto_update", autoUpdateEnabled) + .withConfiguration("sdkman_auto_answer", "true") + .build() + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk version") + + then: + verifyOutput(bash.output) + + where: + selfupdateFeature | autoUpdateEnabled | verifyOutput + "true" | "true" | { it.contains("ATTENTION: A new version of SDKMAN is available...") } + "true" | "false" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } + "false" | "true" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } + } +} From fd2ed04a4e827e7cc501dadbdc99641cd9b71873 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 9 Mar 2022 20:49:30 +0000 Subject: [PATCH 02/84] Fix selfupdate bug. --- src/main/bash/sdkman-selfupdate.sh | 9 +++++---- src/test/groovy/sdkman/steps/stub_steps.groovy | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index f262a5a6f..93d90d3a7 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -24,12 +24,13 @@ function __sdk_selfupdate() { echo "This command is not available while offline." elif [[ "$SDKMAN_REMOTE_VERSION" == "$SDKMAN_VERSION" && "$force_selfupdate" != "force" ]]; then echo "No update available at this time." + elif [[ "$sdkman_beta_channel" == "true" ]]; then + export sdkman_debug_mode + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta" | bash else export sdkman_debug_mode - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate" | bash + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable" | bash fi - - unset SDKMAN_FORCE_SELFUPDATE } function __sdkman_auto_update() { @@ -57,7 +58,7 @@ function __sdkman_auto_update() { fi if [[ "$upgrade" == "Y" || "$upgrade" == "y" ]]; then - __sdk_selfupdate + __sdk_selfupdate "force" unset upgrade else __sdkman_echo_no_colour "Not upgrading today..." diff --git a/src/test/groovy/sdkman/steps/stub_steps.groovy b/src/test/groovy/sdkman/steps/stub_steps.groovy index f2508574b..a27ea8d10 100644 --- a/src/test/groovy/sdkman/steps/stub_steps.groovy +++ b/src/test/groovy/sdkman/steps/stub_steps.groovy @@ -17,7 +17,8 @@ And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String } And(~'^an available selfupdate$') { -> - primeEndpointWithString("/selfupdate", 'echo "Successfully upgraded SDKMAN."') + primeEndpointWithString("/selfupdate/stable", 'echo "Successfully upgraded SDKMAN."') + primeEndpointWithString("/selfupdate/beta", 'echo "Successfully upgraded SDKMAN."') } And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version -> From 57ccc4ef102b69f7f1b2452cb23af4351e94becb Mon Sep 17 00:00:00 2001 From: helpermethod Date: Fri, 11 Mar 2022 15:28:45 +0100 Subject: [PATCH 03/84] Disable Homebrew packager --- gradle/release.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/release.gradle b/gradle/release.gradle index 641870020..a97d9dcda 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -36,7 +36,7 @@ jreleaser { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" } brew { - active = 'ALWAYS' + active = 'NEVER' } } } From bd2558a64141630795e00d04493972ff183e3bb9 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Mon, 14 Mar 2022 13:27:17 +0100 Subject: [PATCH 04/84] Enable Homebrew packager (#1067) --- gradle/release.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/release.gradle b/gradle/release.gradle index a97d9dcda..641870020 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -36,7 +36,7 @@ jreleaser { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" } brew { - active = 'NEVER' + active = 'ALWAYS' } } } From 9881a42e3fd1af4ee6d9536626e2897f0560d8c3 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Mon, 14 Mar 2022 22:09:30 +0100 Subject: [PATCH 05/84] Add platform to appease Homebrew packager (#1070) * Add platform to appease Homebrew packager * Add explanatory comment --- gradle/release.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gradle/release.gradle b/gradle/release.gradle index 641870020..034a428fe 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -34,6 +34,9 @@ jreleaser { distributionType = 'BINARY' artifact { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" + // the platform has only been added because the Homebrew packager requires it + // the resulting ZIP file is actually platform-independent + platform = "osx-x86_64" } brew { active = 'ALWAYS' From 17d70f06fb7ba1ee41c016752be0389c91860196 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Thu, 17 Mar 2022 20:39:35 +0100 Subject: [PATCH 06/84] Run jreleaserFullRelease to create files required by Homebrew (#1071) --- .github/workflows/release.yml | 2 +- gradle/release.gradle | 4 ++-- src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d10656121..162249354 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: - name: Build artifacts run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} clean assemble - name: Release - run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} jreleaserRelease + run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} jreleaserFullRelease --exclude-announcer=twitter - name: Update MongoDB env: MONGO_URL: ${{ secrets.MONGO_URL }} diff --git a/gradle/release.gradle b/gradle/release.gradle index 034a428fe..44e44248c 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -34,8 +34,8 @@ jreleaser { distributionType = 'BINARY' artifact { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" - // the platform has only been added because the Homebrew packager requires it - // the resulting ZIP file is actually platform-independent + // binary artifacts are platform-dependent and require a platform identifier + // see https://github.com/jreleaser/jreleaser/issues/794 for more details platform = "osx-x86_64" } brew { diff --git a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl index 8c000a8b9..4c1f003b9 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl @@ -25,5 +25,5 @@ sdk version The output should look similar to this ```sh -SDKMAN {{version}} -``` \ No newline at end of file +SDKMAN {{projectVersion}} +``` From 1e59a342f045b2174b397eab3f834ea8a642a4f4 Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Tue, 25 Jan 2022 11:23:17 +0100 Subject: [PATCH 07/84] Consider unsupported platforms as exotic Only fall back on Linuxx64 on platforms not mentioned in https://github.com/torvalds/linux/blob/5bfc75d92efd494db37f5c4c173d3639d4772966/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py#L56 (excluding the i*86 platforms) --- src/main/bash/sdkman-init.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index 89ad27e84..bf52caf28 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -63,6 +63,9 @@ function infer_platform() { aarch64) echo "LinuxARM64" ;; + alpha | i64 | ppc | ppc64le | ppc64el | s390 | s390x) + echo "exotic" + ;; *) echo "LinuxX64" ;; From 282e11fe3a1b50822479a002178f80b8ac79232e Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Tue, 15 Mar 2022 13:02:00 +0100 Subject: [PATCH 08/84] Update test and init --- src/main/bash/sdkman-init.sh | 5 +---- src/test/groovy/sdkman/specs/PlatformSpec.groovy | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index bf52caf28..1212eacfa 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -63,11 +63,8 @@ function infer_platform() { aarch64) echo "LinuxARM64" ;; - alpha | i64 | ppc | ppc64le | ppc64el | s390 | s390x) - echo "exotic" - ;; *) - echo "LinuxX64" + echo "Exotic" ;; esac ;; diff --git a/src/test/groovy/sdkman/specs/PlatformSpec.groovy b/src/test/groovy/sdkman/specs/PlatformSpec.groovy index a736a2939..2cca50e53 100644 --- a/src/test/groovy/sdkman/specs/PlatformSpec.groovy +++ b/src/test/groovy/sdkman/specs/PlatformSpec.groovy @@ -26,12 +26,13 @@ class PlatformSpec extends SdkmanEnvSpecification { "Linux" | "armv7l" | "linuxarm32hf" "Linux" | "armv8l" | "linuxarm32hf" "Linux" | "aarch64" | "linuxarm64" - "Linux" | "" | "linuxx64" + "Linux" | "" | "exotic" "Darwin" | "x86_64" | "darwinx64" "Darwin" | "arm64" | "darwinarm64" "Darwin" | "" | "darwinx64" "MSYS64" | "i686" | "msys64" "MSYS64" | "" | "msys64" + "Linux" | "ppc64le" | "exotic" } def "should enable rosetta 2 compatibility mode with environment variable"() { From 87b8176ebfd18d58cbde758fc944f983d3163fba Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Tue, 15 Mar 2022 15:41:35 +0100 Subject: [PATCH 09/84] Fix test --- src/test/groovy/sdkman/specs/PlatformSpec.groovy | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/sdkman/specs/PlatformSpec.groovy b/src/test/groovy/sdkman/specs/PlatformSpec.groovy index 2cca50e53..448b3449c 100644 --- a/src/test/groovy/sdkman/specs/PlatformSpec.groovy +++ b/src/test/groovy/sdkman/specs/PlatformSpec.groovy @@ -26,13 +26,19 @@ class PlatformSpec extends SdkmanEnvSpecification { "Linux" | "armv7l" | "linuxarm32hf" "Linux" | "armv8l" | "linuxarm32hf" "Linux" | "aarch64" | "linuxarm64" + "Linux" | "alpha" | "exotic" + "Linux" | "i64" | "exotic" + "Linux" | "ppc" | "exotic" + "Linux" | "ppc64le" | "exotic" + "Linux" | "ppc64el" | "exotic" + "Linux" | "s390" | "exotic" + "Linux" | "s390x" | "exotic" "Linux" | "" | "exotic" "Darwin" | "x86_64" | "darwinx64" "Darwin" | "arm64" | "darwinarm64" "Darwin" | "" | "darwinx64" "MSYS64" | "i686" | "msys64" "MSYS64" | "" | "msys64" - "Linux" | "ppc64le" | "exotic" } def "should enable rosetta 2 compatibility mode with environment variable"() { From 19eeef809da82f0eb8df0cb57026c6b0e155d908 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 20 Mar 2022 17:18:24 +0000 Subject: [PATCH 10/84] Code tweak in install source. --- src/main/bash/sdkman-install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 447464aa0..311d720aa 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -115,7 +115,6 @@ function __sdkman_install_local_version() { function __sdkman_download() { local candidate version archives_folder - local headers_file tmp_headers_file candidate="$1" version="$2" @@ -129,8 +128,8 @@ function __sdkman_download() { local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" local base_name="${candidate}-${version}" local zip_archive_target="${SDKMAN_DIR}/archives/${base_name}.zip" - tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" - headers_file="${metadata_folder}/${base_name}.headers" + local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" + local headers_file="${metadata_folder}/${base_name}.headers" # pre-installation hook: implements function __sdkman_pre_installation_hook local pre_installation_hook="${SDKMAN_DIR}/tmp/hook_pre_${candidate}_${version}.sh" From 08e7402a7dfeed0b0584b347f30327b3a62c6cd4 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 20 Mar 2022 17:19:01 +0000 Subject: [PATCH 11/84] Check zip integrity before checksum. --- src/main/bash/sdkman-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 311d720aa..4d0dd8b32 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -171,8 +171,8 @@ function __sdkman_download() { echo "" __sdkman_echo_no_colour "Found a previously downloaded ${candidate} ${version} archive. Not downloading it again..." fi - __sdkman_checksum_zip "${archives_folder}/${candidate}-${version}.zip" "${headers_file}" || return 1 __sdkman_validate_zip "${archives_folder}/${candidate}-${version}.zip" || return 1 + __sdkman_checksum_zip "${archives_folder}/${candidate}-${version}.zip" "${headers_file}" || return 1 echo "" } From 06fd0436a6b9ac79ba2b28125637cfde2b3c9a3b Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 20 Mar 2022 17:20:51 +0000 Subject: [PATCH 12/84] Fix broken tests to do with platform inference. --- .../groovy/sdkman/support/UnixUtils.groovy | 22 +++++++++++++------ .../features/java_installation.feature | 22 +++++++++---------- .../pre_and_post_installation_hooks.feature | 22 +++++++++---------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/test/groovy/sdkman/support/UnixUtils.groovy b/src/test/groovy/sdkman/support/UnixUtils.groovy index 84da33a7b..ad8d2736a 100644 --- a/src/test/groovy/sdkman/support/UnixUtils.groovy +++ b/src/test/groovy/sdkman/support/UnixUtils.groovy @@ -3,17 +3,25 @@ package sdkman.support class UnixUtils { private static platforms = [ - "Linux": [ - "amd64": "LinuxX64" - ], + "Linux" : [ + "x86_64": "LinuxX64" + ], "Mac OS X": [ - "x86_64": "DarwinX64", + "x86_64": "DarwinX64", ] ] - + + static execute(String command) { + command.execute().text.trim() + } + + static osName() { execute("uname -s") } + + static osArch() { execute("uname -m") } + static inferPlatform( - osName = System.getProperty("os.name"), - architecture = System.getProperty("os.arch")) { + String osName = osName(), + String architecture = osArch()) { (platforms[osName][architecture] ?: osName).toLowerCase() } } diff --git a/src/test/resources/features/java_installation.feature b/src/test/resources/features/java_installation.feature index 16e406e07..42a0dac61 100644 --- a/src/test/resources/features/java_installation.feature +++ b/src/test/resources/features/java_installation.feature @@ -12,36 +12,36 @@ Feature: Java Multi Platform Binary Distribution And an initialised environment Scenario: Platform is supported and a specific version of compatible binary is installed - Given an "amd64" machine with "Linux" installed + Given an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "amd64" - And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "amd64" + And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64" + And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "x86_64" When I enter "sdk install java 8.0.111" And I see "Done installing!" And the candidate "java" version "8.0.111" is installed Scenario: Platform is supported and a default version of compatible binary is installed - Given an "amd64" machine with "Linux" installed + Given an "x86_64" machine with "Linux" installed And the system is bootstrapped And the default "java" version is "8.0.111" - And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "amd64" - And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "amd64" + And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64" + And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "x86_64" When I enter "sdk install java" And I see "Done installing!" And the candidate "java" version "8.0.111" is installed Scenario: Platform is supported but download fails - Given an "amd64" machine with "Linux" installed + Given an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "java" version "8.0.101" is available for download on "Linux" with architecture "amd64" - And the appropriate multi-platform hooks are available for "java" version "8.0.101" on "Linux" with architecture "amd64" + And the candidate "java" version "8.0.101" is available for download on "Linux" with architecture "x86_64" + And the appropriate multi-platform hooks are available for "java" version "8.0.101" on "Linux" with architecture "x86_64" When I enter "sdk install java 8.0.101" And I see "Download has failed, aborting!" And the candidate "java" version "8.0.101" is not installed And I see "Cannot install java 8.0.101 at this time..." Scenario: Platform is not supported for specific version and user is notified - And an "amd64" machine with "Linux" installed + And an "x86_64" machine with "Linux" installed And the system is bootstrapped And the candidate "java" version "8.0.111" is not available for download on "Linux" When I enter "sdk install java 8.0.111" @@ -54,7 +54,7 @@ Feature: Java Multi Platform Binary Distribution And the candidate "java" version "8.0.111" is not installed Scenario: Platform is not supported for default version and user is notified - And an "amd64" machine with "Linux" installed + And an "x86_64" machine with "Linux" installed And the system is bootstrapped And the default "java" version is "8.0.111" And the candidate "java" version "8.0.111" is not available for download on "Linux" diff --git a/src/test/resources/features/pre_and_post_installation_hooks.feature b/src/test/resources/features/pre_and_post_installation_hooks.feature index d6667db53..949036686 100644 --- a/src/test/resources/features/pre_and_post_installation_hooks.feature +++ b/src/test/resources/features/pre_and_post_installation_hooks.feature @@ -7,31 +7,31 @@ Feature: Hooks And an initialised environment Scenario: Pre- and Post-installation Hooks return successfully - And an "amd64" machine with "Linux" installed + And an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "amd64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns successfully - And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns successfully + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully + And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully When I enter "sdk install grails 2.1.0" Then I see "Pre-installation hook success" And I see "Post-installation hook success" And the exit code is 0 Scenario: Pre-installation Hook returns a non-zero code - And an "amd64" machine with "Linux" installed + And an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "amd64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns a failure + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure When I enter "sdk install grails 2.1.0" Then I see "Pre-installation hook failure" And the exit code is 1 Scenario: Post-install Hook returns a non-zero code - And an "amd64" machine with "Linux" installed + And an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "amd64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns successfully - And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns a failure + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully + And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure When I enter "sdk install grails 2.1.0" Then I see "Post-installation hook failure" And the exit code is 1 From 3ab1da7cc960f6684589c93eb6ad9ec815cdb807 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 21 Mar 2022 09:38:15 +0000 Subject: [PATCH 13/84] Upgrade JReleaser to 0.10.0. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 65cc50721..31b106329 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id('groovy') - id('org.jreleaser').version('0.8.0').apply(false) + id('org.jreleaser').version('0.10.0').apply(false) } String userHome = System.getProperty('user.home') From 3125e13500b18da62b2065afe347326d65b2a651 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Fri, 25 Mar 2022 14:27:00 +0100 Subject: [PATCH 14/84] Upgrade JReleaser to 1.0.0-M3 (#1076) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 31b106329..7f4c08b2e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id('groovy') - id('org.jreleaser').version('0.10.0').apply(false) + id('org.jreleaser').version('1.0.0-M3').apply(false) } String userHome = System.getProperty('user.home') From 31d276507336ea3ea4e41f59a2ef38345d32c1fb Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Sat, 26 Mar 2022 10:06:43 +0100 Subject: [PATCH 15/84] Replace template tag with version (#1079) --- src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl index d42d839e0..089fff7b2 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl @@ -30,6 +30,6 @@ class {{brewFormulaName}} < Formula end test do - assert_match {{projectVersion}}, shell_output("export SDKMAN_DIR=#{libexec} && source #{libexec}/bin/sdkman-init.sh && sdk version") + assert_match version, shell_output("export SDKMAN_DIR=#{libexec} && source #{libexec}/bin/sdkman-init.sh && sdk version") end end From b7781e5b6c77e23a3c6c26a3bfd71dac1d49310c Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Thu, 31 Mar 2022 09:31:57 +0200 Subject: [PATCH 16/84] Add dependabot.yml (#1078) --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..253bcb76b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily From d8e3bf80a00d1c11b5be2cc8d99ae0df53be6a8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 07:32:25 +0000 Subject: [PATCH 17/84] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/beta.yml | 2 +- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 3bc91572e..5a8fe4980 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -15,7 +15,7 @@ jobs: ports: - 27017:27017 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-java@v2 with: distribution: 'temurin' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b275393ab..267726dc6 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - uses: actions/setup-java@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 162249354..d4156896e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: ports: - 27017:27017 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: actions/setup-java@v2 From 92277bfb1699f45ff0c370e828392d3fc52b1c4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 07:32:28 +0000 Subject: [PATCH 18/84] Bump kentaro-m/auto-assign-action from 1.1.2 to 1.2.1 Bumps [kentaro-m/auto-assign-action](https://github.com/kentaro-m/auto-assign-action) from 1.1.2 to 1.2.1. - [Release notes](https://github.com/kentaro-m/auto-assign-action/releases) - [Commits](https://github.com/kentaro-m/auto-assign-action/compare/v1.1.2...v1.2.1) --- updated-dependencies: - dependency-name: kentaro-m/auto-assign-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 267726dc6..6db6c6ab8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,6 +14,6 @@ jobs: java-version: '11' - name: Run with Gradle run: ./gradlew clean test --info - - uses: kentaro-m/auto-assign-action@v1.1.2 + - uses: kentaro-m/auto-assign-action@v1.2.1 with: configuration-path: ".github/auto_assign.yml" From 94ccfd0957371691aa23b4ddf25576e0a7428361 Mon Sep 17 00:00:00 2001 From: helpermethod Date: Thu, 31 Mar 2022 12:35:05 +0200 Subject: [PATCH 19/84] Do not trigger beta releases on changes to the workflows --- .github/workflows/beta.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 5a8fe4980..4a2fe2b31 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -3,6 +3,8 @@ on: push: branches: - master + paths-ignore: + - .github/workflows/* jobs: pre-release: From 535e3c9b920db64d9a3e91ddfdfae72479cc81d1 Mon Sep 17 00:00:00 2001 From: Hector Geraldino Date: Sun, 3 Apr 2022 09:28:05 -0400 Subject: [PATCH 20/84] Remove local caching of candidates (#1077) --- contrib/completion/bash/sdk | 2 +- .../sdkman-cli/brew/formula.rb.tpl | 2 +- src/main/bash/sdkman-flush.sh | 4 - src/main/bash/sdkman-help.sh | 2 +- src/main/bash/sdkman-install.sh | 93 +++++++++---------- .../sdkman/env/SdkmanBashEnvBuilder.groovy | 3 +- src/test/groovy/sdkman/steps/env.groovy | 1 - .../groovy/sdkman/steps/flush_steps.groovy | 13 --- .../sdkman/steps/initialisation_steps.groovy | 2 +- .../features/checksum_verification.feature | 36 ------- src/test/resources/features/flush.feature | 10 +- .../features/install_candidate.feature | 11 --- 12 files changed, 48 insertions(+), 131 deletions(-) diff --git a/contrib/completion/bash/sdk b/contrib/completion/bash/sdk index 17fc6e3ae..a8765d51b 100644 --- a/contrib/completion/bash/sdk +++ b/contrib/completion/bash/sdk @@ -45,7 +45,7 @@ __sdkman_complete_command() { candidates=("force") ;; flush) - candidates=("archives" "temp" "broadcast" "version") + candidates=("temp" "broadcast" "version") ;; esac diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl index 089fff7b2..6904af617 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl @@ -9,7 +9,7 @@ class {{brewFormulaName}} < Formula def install libexec.install Dir["*"] - %w[tmp ext etc var archives candidates].each { |dir| mkdir libexec/dir } + %w[tmp ext etc var candidates].each { |dir| mkdir libexec/dir } system "curl", "-s", "https://api.sdkman.io/2/candidates/all", "-o", libexec/"var/candidates" diff --git a/src/main/bash/sdkman-flush.sh b/src/main/bash/sdkman-flush.sh index ee41ca217..10893fd0a 100644 --- a/src/main/bash/sdkman-flush.sh +++ b/src/main/bash/sdkman-flush.sh @@ -29,9 +29,6 @@ function __sdk_flush() { __sdkman_echo_green "Version file has been flushed." fi ;; - archives) - __sdkman_cleanup_folder "archives" - ;; temp) __sdkman_cleanup_folder "tmp" ;; @@ -42,7 +39,6 @@ function __sdk_flush() { __sdkman_cleanup_folder "var/metadata" ;; *) - __sdkman_cleanup_folder "archives" __sdkman_cleanup_folder "tmp" __sdkman_cleanup_folder "var/metadata" ;; diff --git a/src/main/bash/sdkman-help.sh b/src/main/bash/sdkman-help.sh index 6fe593bac..e5ee2a030 100644 --- a/src/main/bash/sdkman-help.sh +++ b/src/main/bash/sdkman-help.sh @@ -42,7 +42,7 @@ function __sdk_help() { fi __sdkman_echo_no_colour " update" - __sdkman_echo_no_colour " flush [archives|tmp|broadcast|metadata|version]" + __sdkman_echo_no_colour " flush [tmp|broadcast|metadata|version]" __sdkman_echo_no_colour "" __sdkman_echo_no_colour " candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc." __sdkman_echo_no_colour " use list command for comprehensive list of candidates" diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 4d0dd8b32..1f8582871 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -70,7 +70,7 @@ function __sdkman_install_candidate_version() { mkdir -p "${SDKMAN_CANDIDATES_DIR}/${candidate}" rm -rf "${SDKMAN_DIR}/tmp/out" - unzip -oq "${SDKMAN_DIR}/archives/${candidate}-${version}.zip" -d "${SDKMAN_DIR}/tmp/out" + unzip -oq "${SDKMAN_DIR}/tmp/${candidate}-${version}.zip" -d "${SDKMAN_DIR}/tmp/out" mv -f "$SDKMAN_DIR"/tmp/out/* "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}" __sdkman_echo_green "Done installing!" echo "" @@ -114,65 +114,56 @@ function __sdkman_install_local_version() { } function __sdkman_download() { - local candidate version archives_folder + local candidate version candidate="$1" version="$2" - archives_folder="${SDKMAN_DIR}/archives" metadata_folder="${SDKMAN_DIR}/var/metadata" mkdir -p ${metadata_folder} - if [ ! -f "${archives_folder}/${candidate}-${version}.zip" ]; then - local platform_parameter="$(echo $SDKMAN_PLATFORM | tr '[:upper:]' '[:lower:]')" - local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" - local base_name="${candidate}-${version}" - local zip_archive_target="${SDKMAN_DIR}/archives/${base_name}.zip" - local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" - local headers_file="${metadata_folder}/${base_name}.headers" - - # pre-installation hook: implements function __sdkman_pre_installation_hook - local pre_installation_hook="${SDKMAN_DIR}/tmp/hook_pre_${candidate}_${version}.sh" - __sdkman_echo_debug "Get pre-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" >| "$pre_installation_hook" - __sdkman_echo_debug "Copy remote pre-installation hook: $pre_installation_hook" - source "$pre_installation_hook" - __sdkman_pre_installation_hook || return 1 - __sdkman_echo_debug "Completed pre-installation hook..." - - export local binary_input="${SDKMAN_DIR}/tmp/${base_name}.bin" - export local zip_output="${SDKMAN_DIR}/tmp/$base_name.zip" + local platform_parameter="$(echo $SDKMAN_PLATFORM | tr '[:upper:]' '[:lower:]')" + local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" + local base_name="${candidate}-${version}" + local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" + local headers_file="${metadata_folder}/${base_name}.headers" + + # pre-installation hook: implements function __sdkman_pre_installation_hook + local pre_installation_hook="${SDKMAN_DIR}/tmp/hook_pre_${candidate}_${version}.sh" + __sdkman_echo_debug "Get pre-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" >| "$pre_installation_hook" + __sdkman_echo_debug "Copy remote pre-installation hook: $pre_installation_hook" + source "$pre_installation_hook" + __sdkman_pre_installation_hook || return 1 + __sdkman_echo_debug "Completed pre-installation hook..." + + export local binary_input="${SDKMAN_DIR}/tmp/${base_name}.bin" + export local zip_output="${SDKMAN_DIR}/tmp/${base_name}.zip" - echo "" - __sdkman_echo_no_colour "Downloading: ${candidate} ${version}" - echo "" - __sdkman_echo_no_colour "In progress..." - echo "" + echo "" + __sdkman_echo_no_colour "Downloading: ${candidate} ${version}" + echo "" + __sdkman_echo_no_colour "In progress..." + echo "" - # download binary - __sdkman_secure_curl_download "${download_url}" --output "${binary_input}" --dump-header "${tmp_headers_file}" - grep '^X-Sdkman' "${tmp_headers_file}" > "${headers_file}" - __sdkman_echo_debug "Downloaded binary to: ${binary_input} (HTTP headers written to: ${headers_file})" - - # post-installation hook: implements function __sdkman_post_installation_hook - # responsible for taking `binary_input` and producing `zip_output` - local post_installation_hook="${SDKMAN_DIR}/tmp/hook_post_${candidate}_${version}.sh" - __sdkman_echo_debug "Get post-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" >| "$post_installation_hook" - __sdkman_echo_debug "Copy remote post-installation hook: ${post_installation_hook}" - source "$post_installation_hook" - __sdkman_post_installation_hook || return 1 - __sdkman_echo_debug "Processed binary as: $zip_output" - __sdkman_echo_debug "Completed post-installation hook..." - - mv -f "$zip_output" "$zip_archive_target" - __sdkman_echo_debug "Moved to archive folder: $zip_archive_target" - else - echo "" - __sdkman_echo_no_colour "Found a previously downloaded ${candidate} ${version} archive. Not downloading it again..." - fi - __sdkman_validate_zip "${archives_folder}/${candidate}-${version}.zip" || return 1 - __sdkman_checksum_zip "${archives_folder}/${candidate}-${version}.zip" "${headers_file}" || return 1 + # download binary + __sdkman_secure_curl_download "${download_url}" --output "${binary_input}" --dump-header "${tmp_headers_file}" + grep '^X-Sdkman' "${tmp_headers_file}" > "${headers_file}" + __sdkman_echo_debug "Downloaded binary to: ${binary_input} (HTTP headers written to: ${headers_file})" + + # post-installation hook: implements function __sdkman_post_installation_hook + # responsible for taking `binary_input` and producing `zip_output` + local post_installation_hook="${SDKMAN_DIR}/tmp/hook_post_${candidate}_${version}.sh" + __sdkman_echo_debug "Get post-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" >| "$post_installation_hook" + __sdkman_echo_debug "Copy remote post-installation hook: ${post_installation_hook}" + source "$post_installation_hook" + __sdkman_post_installation_hook || return 1 + __sdkman_echo_debug "Processed binary as: $zip_output" + __sdkman_echo_debug "Completed post-installation hook..." + + __sdkman_validate_zip "${zip_output}" || return 1 + __sdkman_checksum_zip "${zip_output}" "${headers_file}" || return 1 echo "" } diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index ee6d0e6ed..ebc769bd2 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -34,7 +34,7 @@ class SdkmanBashEnvBuilder { sdkman_selfupdate_feature: 'true' ] - File sdkmanDir, sdkmanBinDir, sdkmanVarDir, sdkmanSrcDir, sdkmanEtcDir, sdkmanExtDir, sdkmanArchivesDir, + File sdkmanDir, sdkmanBinDir, sdkmanVarDir, sdkmanSrcDir, sdkmanEtcDir, sdkmanExtDir, sdkmanTmpDir, sdkmanCandidatesDir, sdkmanMetadataDir, sdkmanContribDir static SdkmanBashEnvBuilder create(File baseFolder) { @@ -112,7 +112,6 @@ class SdkmanBashEnvBuilder { sdkmanSrcDir = prepareDirectory(sdkmanDir, "src") sdkmanEtcDir = prepareDirectory(sdkmanDir, "etc") sdkmanExtDir = prepareDirectory(sdkmanDir, "ext") - sdkmanArchivesDir = prepareDirectory(sdkmanDir, "archives") sdkmanTmpDir = prepareDirectory(sdkmanDir, "tmp") sdkmanCandidatesDir = prepareDirectory(sdkmanDir, "candidates") sdkmanMetadataDir = prepareDirectory(sdkmanVarDir, "metadata") diff --git a/src/test/groovy/sdkman/steps/env.groovy b/src/test/groovy/sdkman/steps/env.groovy index 3de259937..ce1eb81a2 100644 --- a/src/test/groovy/sdkman/steps/env.groovy +++ b/src/test/groovy/sdkman/steps/env.groovy @@ -34,7 +34,6 @@ varDir = "${sdkmanDirEnv}/var" as File metadataDir = "${varDir}/metadata" as File etcDir = "${sdkmanDirEnv}/etc" as File extDir = "${sdkmanDirEnv}/ext" as File -archiveDir = "${sdkmanDirEnv}/archives" as File tmpDir = "${sdkmanDir}/tmp" as File broadcastFile = new File(varDir, "broadcast") diff --git a/src/test/groovy/sdkman/steps/flush_steps.groovy b/src/test/groovy/sdkman/steps/flush_steps.groovy index 4cdc3547c..928cabb52 100644 --- a/src/test/groovy/sdkman/steps/flush_steps.groovy +++ b/src/test/groovy/sdkman/steps/flush_steps.groovy @@ -1,8 +1,5 @@ package sdkman.steps -import java.nio.file.Files -import java.nio.file.Paths - import static cucumber.api.groovy.EN.And And(~'^the candidate "([^"]*)" is known locally$') { String candidate -> @@ -13,16 +10,6 @@ And(~'^no candidates are know locally$') { -> assert !candidatesFile.exists() } -And(~'^the archive "([^"]*)" has been cached$') { String archive -> - Files.copy( - Paths.get("src/test/resources/__files", archive), - Paths.get(archiveDir.getAbsolutePath(), archive)) -} - -And(~'^no archives are cached$') { -> - assert !archiveDir.listFiles() -} - And(~'^the file "([^"]*)" in temporary storage$') { String fileName -> new File(tmpDir, fileName).createNewFile() } diff --git a/src/test/groovy/sdkman/steps/initialisation_steps.groovy b/src/test/groovy/sdkman/steps/initialisation_steps.groovy index f676638ee..d789ae497 100644 --- a/src/test/groovy/sdkman/steps/initialisation_steps.groovy +++ b/src/test/groovy/sdkman/steps/initialisation_steps.groovy @@ -30,7 +30,7 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is corrupt$') { Str } And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { String candidate, String version -> - def archive = new File("${sdkmanDir}/archives/${candidate}-${version}.zip") + def archive = new File("${sdkmanDir}/tmp/${candidate}-${version}.zip") assert !archive.exists() } diff --git a/src/test/resources/features/checksum_verification.feature b/src/test/resources/features/checksum_verification.feature index bd6759616..a9c27ade8 100644 --- a/src/test/resources/features/checksum_verification.feature +++ b/src/test/resources/features/checksum_verification.feature @@ -32,42 +32,6 @@ Feature: Verify checksums And the response headers file is created for candidate "grails" and version "1.3.9" And the exit code is 0 - Scenario: Install an already downloaded Candidate with a valid MD5 checksum and no local headers file - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I see "Skipping checksum for cached artifact" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - - Scenario: Install an already downloaded Candidate with a valid MD5 checksum - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - And a headers file "grails-1.3.9.headers" in metadata directory with checksum "1e87a7d982a2f41da96fdec289908552" using algorithm "MD5" - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - - Scenario: Install an already downloaded Candidate with a valid SHA1 checksum - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - And a headers file "grails-1.3.9.headers" in metadata directory with checksum "c68e386a6deec9fc4c1e18df21f92739ba2ab36e" using algorithm "SHA1" - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - Scenario: Do not fail if an unknown algorithm is used Given the system is bootstrapped And the candidate "grails" version "1.3.9" is available for download with checksum "abc-checksum-00000" using algorithm "ABC" diff --git a/src/test/resources/features/flush.feature b/src/test/resources/features/flush.feature index 10aa355dc..34e64908e 100644 --- a/src/test/resources/features/flush.feature +++ b/src/test/resources/features/flush.feature @@ -5,12 +5,10 @@ Feature: Flush And an initialised environment And the system is bootstrapped - Scenario: Clear out the cached archives, the temporary storage and metadata - Given the archive "grails-1.3.9.zip" has been cached + Scenario: Clear out the temporary storage and metadata And the file "res-1.2.0.zip" in temporary storage And a headers file "grails-1.3.9.headers" in metadata directory with checksum "c68e386a6deec9fc4c1e18df21f92739ba2ab36e" using algorithm "SHA1" When I enter "sdk flush" - Then no archives are cached And no "res-1.2.0.zip" file is present in temporary storage And no metadata is cached And I see "1 archive(s) flushed" @@ -33,12 +31,6 @@ Feature: Flush Then no version file can be found And I see "Version file has been flushed." - Scenario: Clear out the cached Archives - Given the archive "grails-1.3.9.zip" has been cached - When I enter "sdk flush archives" - Then no archives are cached - And I see "1 archive(s) flushed" - Scenario: Clear out the temporary storage Given the file "res-1.2.0.zip" in temporary storage When I enter "sdk flush temp" diff --git a/src/test/resources/features/install_candidate.feature b/src/test/resources/features/install_candidate.feature index d41a0be2b..2b855edd4 100644 --- a/src/test/resources/features/install_candidate.feature +++ b/src/test/resources/features/install_candidate.feature @@ -82,17 +82,6 @@ Feature: Install Candidate And the candidate "grails" version "1.3.9" should be the default And the exit code is 0 - Scenario: Install an already downloaded Candidate - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - # revisit to redownload automatically Scenario: Abort installation on download of a corrupt Candidate archive From c8fec735dfca740d28017f1001263150a1b45df0 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Thu, 7 Apr 2022 12:56:55 +0200 Subject: [PATCH 21/84] Improve Homebrew README (#1084) --- src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl index 4c1f003b9..ed9be6aae 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl @@ -6,13 +6,13 @@ A Homebrew tap containing the Formula for the SDKMAN! CLI. ```sh $ brew tap sdkman/tap -$ brew install sdkman +$ brew install sdkman-cli ``` After successful installation add the following lines to the end of your `.bash_profile` ```sh -export SDKMAN_DIR=$(brew --prefix sdkman)/libexec +export SDKMAN_DIR=$(brew --prefix sdkman-cli)/libexec [[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh" ``` From c7f88ad49a16d3537517b1eb91774a938ea82c39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:15:30 +0200 Subject: [PATCH 22/84] Bump actions/setup-java from 2 to 3 (#1085) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2 to 3. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/beta.yml | 2 +- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 4a2fe2b31..5fea740e2 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -18,7 +18,7 @@ jobs: - 27017:27017 steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6db6c6ab8..fcb407e51 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4156896e..00011f695 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11' From 469f83b2b8f5f46abc3b5d0a9dc65842a2b8234d Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 18 Apr 2022 13:51:15 +0100 Subject: [PATCH 23/84] Pass platform identifier to selfupdate beta script. --- src/main/bash/sdkman-selfupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 93d90d3a7..81223496b 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -26,7 +26,7 @@ function __sdk_selfupdate() { echo "No update available at this time." elif [[ "$sdkman_beta_channel" == "true" ]]; then export sdkman_debug_mode - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta" | bash + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta/${SDKMAN_PLATFORM}" | bash else export sdkman_debug_mode __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable" | bash From 0906561e02b968d40b09a7462187a53019a82692 Mon Sep 17 00:00:00 2001 From: Mariusz Wyszomierski Date: Thu, 21 Apr 2022 09:11:25 +0200 Subject: [PATCH 24/84] #1087 Fix sdkman_auto_env when PROMPT_COMMAND ends with space (#1088) Trim PROMPT_COMMAND Without this fix there may be a message with double semicolon: bash: PROMPT_COMMAND: line 0: `history -a; history -n; ;sdkman_auto_env' --- src/main/bash/sdkman-init.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index 1212eacfa..dcbaa0880 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -225,8 +225,9 @@ if [[ "$sdkman_auto_env" == "true" ]]; then export SDKMAN_OLD_PWD="$PWD" } - - [[ -z "$PROMPT_COMMAND" ]] && PROMPT_COMMAND="sdkman_auto_env" || PROMPT_COMMAND="${PROMPT_COMMAND%\;};sdkman_auto_env" + + trimmed_prompt_command="${PROMPT_COMMAND%"${PROMPT_COMMAND##*[![:space:]]}"}" + [[ -z "$trimmed_prompt_command" ]] && PROMPT_COMMAND="sdkman_auto_env" || PROMPT_COMMAND="${trimmed_prompt_command%\;};sdkman_auto_env" fi sdkman_auto_env From 9f86a554692e41406e880d7db122df71006afa09 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Wed, 27 Apr 2022 16:11:17 +0200 Subject: [PATCH 25/84] Bump JReleaser from 1.0.0-M3 to 1.0.0 (#1091) --- build.gradle | 2 +- gradle/release.gradle | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 7f4c08b2e..6e1054c59 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id('groovy') - id('org.jreleaser').version('1.0.0-M3').apply(false) + id('org.jreleaser').version('1.0.0').apply(false) } String userHome = System.getProperty('user.home') diff --git a/gradle/release.gradle b/gradle/release.gradle index 44e44248c..deb622560 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -34,9 +34,7 @@ jreleaser { distributionType = 'BINARY' artifact { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" - // binary artifacts are platform-dependent and require a platform identifier - // see https://github.com/jreleaser/jreleaser/issues/794 for more details - platform = "osx-x86_64" + extraProperties.put("universal", "true") } brew { active = 'ALWAYS' From ccf67703f6f6dc88a5d57ffce8d99c4929a4f6b2 Mon Sep 17 00:00:00 2001 From: Marc Wrobel Date: Sat, 23 Jul 2022 16:28:39 +0200 Subject: [PATCH 26/84] Fix typos in CONTRIBUTING.md (#1107) --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dadcf056..26e790f53 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,12 +7,12 @@ We keep a distinction between Bugs/Issues, New Features and Support Requests. We - User Issues can be raised in our [User Issues channel](https://sdkman.slack.com/app_redirect?channel=user-issues). - New Features or Enhancements can be discussed in our [CLI Development channel](https://sdkman.slack.com/app_redirect?channel=cli-development). -The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required informations. +The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required information. -**Unfortunately we might simply close any Github Issues that have not followed the requested template.** +**Unfortunately we might simply close any GitHub Issues that have not followed the requested template.** ### Pull Requests -Pull Requests are _always_ very welcome, but require a valid GitHub Issue as decribed above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the Github Issue number by replacing `#XXX` with the appropriate issue reference. +Pull Requests are _always_ very welcome, but require a valid GitHub Issue as described above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the GitHub Issue number by replacing `#XXX` with the appropriate issue reference. -Each PR should also be accompanied by a passing test(s) proving it's validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue. +Each PR should also be accompanied by a passing test(s) proving its validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue. From 8adeaf9312fe3492e18cbe84e392295d0c58bcc3 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 6 Aug 2022 16:39:14 +0100 Subject: [PATCH 27/84] Pass platform identifier to selfupdate stable script. --- src/main/bash/sdkman-selfupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 81223496b..7e2b7753c 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -29,7 +29,7 @@ function __sdk_selfupdate() { __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta/${SDKMAN_PLATFORM}" | bash else export sdkman_debug_mode - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable" | bash + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable/${SDKMAN_PLATFORM}" | bash fi } From f26c25056ed7f75d13c0818ec20a5402057fb26b Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 6 Aug 2022 16:50:10 +0100 Subject: [PATCH 28/84] Accommodate platform in selfupdate stub. --- src/test/groovy/sdkman/steps/stub_steps.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/sdkman/steps/stub_steps.groovy b/src/test/groovy/sdkman/steps/stub_steps.groovy index a27ea8d10..b56e80c98 100644 --- a/src/test/groovy/sdkman/steps/stub_steps.groovy +++ b/src/test/groovy/sdkman/steps/stub_steps.groovy @@ -17,8 +17,8 @@ And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String } And(~'^an available selfupdate$') { -> - primeEndpointWithString("/selfupdate/stable", 'echo "Successfully upgraded SDKMAN."') - primeEndpointWithString("/selfupdate/beta", 'echo "Successfully upgraded SDKMAN."') + primeEndpointWithString("/selfupdate/stable/${UnixUtils.inferPlatform()}", 'echo "Successfully upgraded SDKMAN."') + primeEndpointWithString("/selfupdate/beta/${UnixUtils.inferPlatform()}", 'echo "Successfully upgraded SDKMAN."') } And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version -> From 826ee2c6341e3696674918567316fec60502f94d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:05:29 +0200 Subject: [PATCH 29/84] Bump kentaro-m/auto-assign-action from 1.2.1 to 1.2.3 (#1118) Bumps [kentaro-m/auto-assign-action](https://github.com/kentaro-m/auto-assign-action) from 1.2.1 to 1.2.3. - [Release notes](https://github.com/kentaro-m/auto-assign-action/releases) - [Commits](https://github.com/kentaro-m/auto-assign-action/compare/v1.2.1...v1.2.3) --- updated-dependencies: - dependency-name: kentaro-m/auto-assign-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fcb407e51..d2379b76a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,6 +14,6 @@ jobs: java-version: '11' - name: Run with Gradle run: ./gradlew clean test --info - - uses: kentaro-m/auto-assign-action@v1.2.1 + - uses: kentaro-m/auto-assign-action@v1.2.3 with: configuration-path: ".github/auto_assign.yml" From 324e9207b682b05b7742accaa9e5f661a4bea519 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 12:27:49 +0200 Subject: [PATCH 30/84] Bump kentaro-m/auto-assign-action from 1.2.3 to 1.2.4 (#1135) Bumps [kentaro-m/auto-assign-action](https://github.com/kentaro-m/auto-assign-action) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/kentaro-m/auto-assign-action/releases) - [Commits](https://github.com/kentaro-m/auto-assign-action/compare/v1.2.3...v1.2.4) --- updated-dependencies: - dependency-name: kentaro-m/auto-assign-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d2379b76a..889234483 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,6 +14,6 @@ jobs: java-version: '11' - name: Run with Gradle run: ./gradlew clean test --info - - uses: kentaro-m/auto-assign-action@v1.2.3 + - uses: kentaro-m/auto-assign-action@v1.2.4 with: configuration-path: ".github/auto_assign.yml" From 65b95fb8e18dbdfbc71ae4600d8fa2efb22bed40 Mon Sep 17 00:00:00 2001 From: Hector Geraldino Date: Mon, 19 Dec 2022 17:37:35 -0500 Subject: [PATCH 31/84] Fix test failures in OSX/Intel when inferring the platform (#1141) --- src/test/groovy/sdkman/support/UnixUtils.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/sdkman/support/UnixUtils.groovy b/src/test/groovy/sdkman/support/UnixUtils.groovy index ad8d2736a..e4d434bd6 100644 --- a/src/test/groovy/sdkman/support/UnixUtils.groovy +++ b/src/test/groovy/sdkman/support/UnixUtils.groovy @@ -6,8 +6,9 @@ class UnixUtils { "Linux" : [ "x86_64": "LinuxX64" ], - "Mac OS X": [ + "Darwin": [ "x86_64": "DarwinX64", + "arm64": "DarwinX64", ] ] From c37a9fd7ff427ec59b2d8d3d3de4164d150fbb73 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Thu, 29 Dec 2022 17:32:31 +0000 Subject: [PATCH 32/84] Remove home command hack --- src/main/bash/sdkman-main.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index ee51b0d87..17ad5785c 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -60,11 +60,6 @@ function sdk() { ;; esac - if [[ "$COMMAND" == "home" ]]; then - __sdk_home "$QUALIFIER" "$3" - return $? - fi - # Left here for legacy purposes, issue #912 on Github if [[ "$COMMAND" == "completion" ]]; then return 0 From bb119b8e598de90ee9102047d334f67ce20a4d6a Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Thu, 29 Dec 2022 17:33:33 +0000 Subject: [PATCH 33/84] Remove legacy completion command workaround --- src/main/bash/sdkman-main.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index 17ad5785c..5bc3765bb 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -60,11 +60,6 @@ function sdk() { ;; esac - # Left here for legacy purposes, issue #912 on Github - if [[ "$COMMAND" == "completion" ]]; then - return 0 - fi - # # Various sanity checks and default settings # From e4fc02024a86b4337a37f33b7274117de4105742 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Tue, 7 Feb 2023 16:19:38 -0500 Subject: [PATCH 34/84] Display native help, falling back to legacy help --- src/main/bash/sdkman-main.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index 5bc3765bb..70f629585 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -16,6 +16,14 @@ # limitations under the License. # +function ___sdkman_help() { + if [[ -f "$SDKMAN_DIR/libexec/help" ]]; then + "$SDKMAN_DIR/libexec/help" + else + __sdk_help + fi +} + function sdk() { COMMAND="$1" @@ -87,7 +95,7 @@ function sdk() { # no command provided if [[ -z "$COMMAND" ]]; then - __sdk_help + ___sdkman_help return 1 fi @@ -111,7 +119,7 @@ function sdk() { echo "" __sdkman_echo_red "Invalid command: $COMMAND" echo "" - __sdk_help + ___sdkman_help fi # Check whether the candidate exists From b5ed8477a89250c169e9acf199b091411b207417 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Tue, 7 Feb 2023 17:06:56 -0500 Subject: [PATCH 35/84] Give precedence to native home command * falls back to scripted legacy command * propagate up to 10 params to native command --- src/main/bash/sdkman-main.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index 70f629585..b08dee746 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -123,8 +123,7 @@ function sdk() { fi # Check whether the candidate exists - local sdkman_valid_candidate=$(echo ${SDKMAN_CANDIDATES[@]} | grep -w "$QUALIFIER") - if [[ -n "$QUALIFIER" && "$COMMAND" != "help" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && "$COMMAND" != "env" && "$COMMAND" != "completion" && "$COMMAND" != "edit" && -z "$sdkman_valid_candidate" ]]; then + if [[ -n "$QUALIFIER" && "$COMMAND" != "help" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && "$COMMAND" != "env" && "$COMMAND" != "completion" && "$COMMAND" != "edit" && "$COMMAND" != "home" && -z $(echo ${SDKMAN_CANDIDATES[@]} | grep -w "$QUALIFIER") ]]; then echo "" __sdkman_echo_red "Stop! $QUALIFIER is not a valid candidate." return 1 @@ -153,8 +152,20 @@ function sdk() { "$native_command" "$QUALIFIER" elif [ -z "$4" ]; then "$native_command" "$QUALIFIER" "$3" - else + elif [ -z "$5" ]; then "$native_command" "$QUALIFIER" "$3" "$4" + elif [ -z "$6" ]; then + "$native_command" "$QUALIFIER" "$3" "$4" "$5" + elif [ -z "$7" ]; then + "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" + elif [ -z "$8" ]; then + "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" + elif [ -z "$9" ]; then + "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" "$8" + elif [ -z "$10" ]; then + "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + else + ___sdkman_help fi final_rc=$? From 3215879fdcd012721e16f049831c4ac51a6ea716 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 11 Feb 2023 10:21:24 -0500 Subject: [PATCH 36/84] Simplify native command invocation --- src/main/bash/sdkman-main.sh | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index b08dee746..ba2b917a2 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -141,39 +141,17 @@ function sdk() { # Native commands found under libexec local native_command="${SDKMAN_DIR}/libexec/${COMMAND}" - # Internal commands use underscores rather than hyphens - local converted_command_name=$(echo "$COMMAND" | tr '-' '_') - if [ -f "$native_command" ]; then - # Available as native command - if [ -z "$QUALIFIER" ]; then - "$native_command" - elif [ -z "$3" ]; then - "$native_command" "$QUALIFIER" - elif [ -z "$4" ]; then - "$native_command" "$QUALIFIER" "$3" - elif [ -z "$5" ]; then - "$native_command" "$QUALIFIER" "$3" "$4" - elif [ -z "$6" ]; then - "$native_command" "$QUALIFIER" "$3" "$4" "$5" - elif [ -z "$7" ]; then - "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" - elif [ -z "$8" ]; then - "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" - elif [ -z "$9" ]; then - "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" "$8" - elif [ -z "$10" ]; then - "$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" "$8" "$9" - else - ___sdkman_help - fi - final_rc=$? + "$native_command" "${@:2}" elif [ -n "$CMD_FOUND" ]; then + # Internal commands use underscores rather than hyphens + local converted_command_name=$(echo "$COMMAND" | tr '-' '_') + # Available as a shell function __sdk_"$converted_command_name" "$QUALIFIER" "$3" "$4" - final_rc=$? fi + final_rc=$? # Attempt upgrade after all is done if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_feature" == "true" && "$sdkman_auto_update" == "true" ]]; then From 47fd6c42d806498e443157b68bf956bbc100f8cd Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 11 Feb 2023 21:20:25 -0500 Subject: [PATCH 37/84] Run Mongo release from Docker --- bin/release-binary.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/release-binary.sh b/bin/release-binary.sh index 647459945..eca3cb2c7 100755 --- a/bin/release-binary.sh +++ b/bin/release-binary.sh @@ -25,4 +25,9 @@ fi echo "Release: $FIELD as $VERSION" -mongo "${MONGO_URL}" --username="${MONGO_USERNAME}" --password="${MONGO_PASSWORD}" -eval "db.application.updateOne({}, {\$set: { \"$FIELD\": \"$VERSION\"}});" +docker run mongo:3.2 mongo "${MONGO_URL}" \ + --username="${MONGO_USERNAME}" \ + --password="${MONGO_PASSWORD}" \ + --quiet \ + --eval "db.application.updateOne({}, {\$set: { \"$FIELD\": \"$VERSION\"}});" + From 00538c253ce1f8f1a69d8f83370cb7320cc0df5f Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Fri, 17 Feb 2023 03:40:04 +0000 Subject: [PATCH 38/84] Remove broadcast command. --- contrib/completion/bash/sdk | 4 +-- src/main/bash/sdkman-availability.sh | 20 +++-------- src/main/bash/sdkman-broadcast.sh | 25 ------------- src/main/bash/sdkman-flush.sh | 13 ------- src/main/bash/sdkman-help.sh | 3 +- src/main/bash/sdkman-main.sh | 5 +-- .../sdkman/env/SdkmanBashEnvBuilder.groovy | 11 ------ .../groovy/sdkman/specs/CompletionSpec.groovy | 6 ++-- .../groovy/sdkman/specs/EnvCommandSpec.groovy | 4 +-- .../sdkman/steps/broadcast_steps.groovy | 29 --------------- src/test/groovy/sdkman/steps/env.groovy | 1 - .../sdkman/steps/initialisation_steps.groovy | 5 --- src/test/resources/features/broadcast.feature | 36 ------------------- .../features/checksum_verification.feature | 3 +- src/test/resources/features/flush.feature | 11 ------ src/test/resources/features/mnemonics.feature | 7 ---- .../resources/features/offline_mode.feature | 10 ------ .../features/service_unavailable.feature | 8 ----- 18 files changed, 13 insertions(+), 188 deletions(-) delete mode 100644 src/main/bash/sdkman-broadcast.sh delete mode 100644 src/test/groovy/sdkman/steps/broadcast_steps.groovy delete mode 100644 src/test/resources/features/broadcast.feature diff --git a/contrib/completion/bash/sdk b/contrib/completion/bash/sdk index a8765d51b..3ad18bc76 100644 --- a/contrib/completion/bash/sdk +++ b/contrib/completion/bash/sdk @@ -23,7 +23,7 @@ __sdkman_complete_command() { case $command in sdk) - candidates=("install" "uninstall" "list" "use" "config" "default" "home" "env" "current" "upgrade" "version" "broadcast" "help" "offline" "selfupdate" "update" "flush") + candidates=("install" "uninstall" "list" "use" "config" "default" "home" "env" "current" "upgrade" "version" "help" "offline" "selfupdate" "update" "flush") ;; current|c|default|d|home|h|uninstall|rm|upgrade|ug|use|u) local -r candidate_paths=("${SDKMAN_CANDIDATES_DIR}"/*) @@ -45,7 +45,7 @@ __sdkman_complete_command() { candidates=("force") ;; flush) - candidates=("temp" "broadcast" "version") + candidates=("temp" "version") ;; esac diff --git a/src/main/bash/sdkman-availability.sh b/src/main/bash/sdkman-availability.sh index 7d755a276..4f147d5f8 100644 --- a/src/main/bash/sdkman-availability.sh +++ b/src/main/bash/sdkman-availability.sh @@ -16,10 +16,10 @@ # limitations under the License. # -function __sdkman_update_broadcast_and_service_availability() { +function __sdkman_update_service_availability() { local broadcast_live_id=$(__sdkman_determine_broadcast_id) __sdkman_set_availability "$broadcast_live_id" - __sdkman_update_broadcast "$broadcast_live_id" + __sdkman_update_broadcast_id "$broadcast_live_id" } function __sdkman_determine_broadcast_id() { @@ -66,31 +66,19 @@ function __sdkman_display_proxy_warning() { echo "" } -function __sdkman_update_broadcast() { - local broadcast_live_id broadcast_id_file broadcast_text_file broadcast_old_id +function __sdkman_update_broadcast_id() { + local broadcast_live_id broadcast_id_file broadcast_old_id broadcast_live_id="$1" broadcast_id_file="${SDKMAN_DIR}/var/broadcast_id" - broadcast_text_file="${SDKMAN_DIR}/var/broadcast" broadcast_old_id="" if [[ -f "$broadcast_id_file" ]]; then broadcast_old_id=$(< "$broadcast_id_file") fi - if [[ -f "$broadcast_text_file" ]]; then - BROADCAST_OLD_TEXT=$(< "$broadcast_text_file") - fi - if [[ "$SDKMAN_AVAILABLE" == "true" && "$broadcast_live_id" != "$broadcast_old_id" && "$COMMAND" != "selfupdate" && "$COMMAND" != "flush" ]]; then mkdir -p "${SDKMAN_DIR}/var" - echo "$broadcast_live_id" | tee "$broadcast_id_file" > /dev/null - - BROADCAST_LIVE_TEXT=$(__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/broadcast/latest") - echo "$BROADCAST_LIVE_TEXT" | tee "$broadcast_text_file" > /dev/null - if [[ "$COMMAND" != "broadcast" ]]; then - __sdkman_echo_cyan "$BROADCAST_LIVE_TEXT" - fi fi } diff --git a/src/main/bash/sdkman-broadcast.sh b/src/main/bash/sdkman-broadcast.sh deleted file mode 100644 index a75902612..000000000 --- a/src/main/bash/sdkman-broadcast.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright 2021 Marco Vermeulen -# -# 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. -# - -function __sdk_broadcast() { - if [ "$BROADCAST_OLD_TEXT" ]; then - __sdkman_echo_cyan "$BROADCAST_OLD_TEXT" - else - __sdkman_echo_cyan "$BROADCAST_LIVE_TEXT" - fi -} diff --git a/src/main/bash/sdkman-flush.sh b/src/main/bash/sdkman-flush.sh index 10893fd0a..f65ef282d 100644 --- a/src/main/bash/sdkman-flush.sh +++ b/src/main/bash/sdkman-flush.sh @@ -20,9 +20,6 @@ function __sdk_flush() { local qualifier="$1" case "$qualifier" in - broadcast) - __sdkman_cleanup_broadcast - ;; version) if [[ -f "${SDKMAN_DIR}/var/version" ]]; then rm -f "${SDKMAN_DIR}/var/version" @@ -60,13 +57,3 @@ function __sdkman_cleanup_folder() { __sdkman_echo_green "${sdkman_cleanup_count} archive(s) flushed, freeing ${sdkman_cleanup_disk_usage}." } - -function __sdkman_cleanup_broadcast() { - if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then - rm -f "${SDKMAN_DIR}/var/broadcast_id" - rm -f "${SDKMAN_DIR}/var/broadcast" - __sdkman_echo_green "Broadcast has been flushed." - else - __sdkman_echo_no_colour "No prior broadcast found so not flushed." - fi -} diff --git a/src/main/bash/sdkman-help.sh b/src/main/bash/sdkman-help.sh index e5ee2a030..a8a9b9781 100644 --- a/src/main/bash/sdkman-help.sh +++ b/src/main/bash/sdkman-help.sh @@ -33,7 +33,6 @@ function __sdk_help() { __sdkman_echo_no_colour " current or c [candidate]" __sdkman_echo_no_colour " upgrade or ug [candidate]" __sdkman_echo_no_colour " version or v" - __sdkman_echo_no_colour " broadcast or b" __sdkman_echo_no_colour " help" __sdkman_echo_no_colour " offline [enable|disable]" @@ -42,7 +41,7 @@ function __sdk_help() { fi __sdkman_echo_no_colour " update" - __sdkman_echo_no_colour " flush [tmp|broadcast|metadata|version]" + __sdkman_echo_no_colour " flush [tmp|metadata|version]" __sdkman_echo_no_colour "" __sdkman_echo_no_colour " candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc." __sdkman_echo_no_colour " use list command for comprehensive list of candidates" diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index ba2b917a2..c40f9facd 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -57,9 +57,6 @@ function sdk() { d) COMMAND="default" ;; - b) - COMMAND="broadcast" - ;; h) COMMAND="home" ;; @@ -86,7 +83,7 @@ function sdk() { fi # ...unless proven otherwise - __sdkman_update_broadcast_and_service_availability + __sdkman_update_service_availability # Load the sdkman config if it exists. if [ -f "${SDKMAN_DIR}/etc/config" ]; then diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index ebc769bd2..e9f65b2f9 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -20,7 +20,6 @@ class SdkmanBashEnvBuilder { private Optional unameStub = Optional.empty() private List candidates = ['groovy', 'grails', 'java'] private boolean offlineMode = false - private String broadcast = "This is a LIVE broadcast!" private String candidatesApi = "http://localhost:8080/2" private String sdkmanVersion = "5.0.0" private String jdkHome = "/path/to/my/jdk" @@ -60,11 +59,6 @@ class SdkmanBashEnvBuilder { this } - SdkmanBashEnvBuilder withBroadcast(String broadcast) { - this.broadcast = broadcast - this - } - SdkmanBashEnvBuilder withConfiguration(String key, String value) { config.put key, value this @@ -122,7 +116,6 @@ class SdkmanBashEnvBuilder { initializeCandidates(sdkmanCandidatesDir, candidates) initializeCandidatesCache(sdkmanVarDir, candidates) - initializeBroadcast(sdkmanVarDir, broadcast) initializeConfiguration(sdkmanEtcDir, config) initializeVersionCache(sdkmanVarDir, versionCache) @@ -175,10 +168,6 @@ class SdkmanBashEnvBuilder { } } - private initializeBroadcast(File targetFolder, String broadcast) { - new File(targetFolder, "broadcast") << broadcast - } - private initializeConfiguration(File targetFolder, Map config) { def configFile = new File(targetFolder, "config") config.each { key, value -> diff --git a/src/test/groovy/sdkman/specs/CompletionSpec.groovy b/src/test/groovy/sdkman/specs/CompletionSpec.groovy index 7ef0eb04b..ffd811af5 100644 --- a/src/test/groovy/sdkman/specs/CompletionSpec.groovy +++ b/src/test/groovy/sdkman/specs/CompletionSpec.groovy @@ -4,7 +4,6 @@ import sdkman.support.SdkmanEnvSpecification class CompletionSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" def "should complete the list of commands"() { given: @@ -20,7 +19,7 @@ class CompletionSpec extends SdkmanEnvSpecification { bash.execute('echo "\${COMPREPLY[@]}"') then: - bash.output.contains("install uninstall list use config default home env current upgrade version broadcast help offline selfupdate update flush") + bash.output.contains("install uninstall list use config default home env current upgrade version help offline selfupdate update flush") } def "should complete the list of candidates"() { @@ -43,8 +42,7 @@ class CompletionSpec extends SdkmanEnvSpecification { def "should complete the list of Java versions"() { given: - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") - .primeWith("$CANDIDATES_API/candidates/java/darwinx64/versions/all", "echo 16.0.1.hs-adpt,17.0.0-tem") + curlStub.primeWith("$CANDIDATES_API/candidates/java/darwinx64/versions/all", "echo 16.0.1.hs-adpt,17.0.0-tem") unameStub.forKernel("Darwin").forMachine("x86_64") diff --git a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy index eb8344053..3e76783f2 100644 --- a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy @@ -9,13 +9,11 @@ import static java.nio.file.Files.createSymbolicLink class EnvCommandSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" static final String CANDIDATES_DEFAULT_JAVA = "$CANDIDATES_API/candidates/default/java" def "should generate .sdkmanrc when called with 'init'"() { given: - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") - .primeWith(CANDIDATES_DEFAULT_JAVA, "echo 11.0.6.hs-adpt") + curlStub.primeWith(CANDIDATES_DEFAULT_JAVA, "echo 11.0.6.hs-adpt") setupCandidates(candidatesDirectory) diff --git a/src/test/groovy/sdkman/steps/broadcast_steps.groovy b/src/test/groovy/sdkman/steps/broadcast_steps.groovy deleted file mode 100644 index 1700441b4..000000000 --- a/src/test/groovy/sdkman/steps/broadcast_steps.groovy +++ /dev/null @@ -1,29 +0,0 @@ -package sdkman.steps - -import static cucumber.api.groovy.EN.And -import static sdkman.stubs.WebServiceStub.primeEndpointWithString - -And(~'^no prior Broadcast was received$') { -> - broadcastFile.delete() - broadcastIdFile.delete() -} - -And(~'^a new Broadcast "(.*)" with id "(.*)" is available$') { String broadcast, String id -> - primeEndpointWithString("/broadcast/latest/id", id) - primeEndpointWithString("/broadcast/latest", broadcast) -} - -And(~'^a prior Broadcast "(.*)" with id "(.*)" was issued$') { String broadcast, String id -> - broadcastIdFile.write id - broadcastFile.write broadcast -} - -And(~'^no broadcast message can be found$') { -> - assert !broadcastIdFile.exists() - assert !broadcastFile.exists() -} - -And(~'^the broadcast has been flushed$') { -> - broadcastIdFile.delete() - broadcastFile.delete() -} diff --git a/src/test/groovy/sdkman/steps/env.groovy b/src/test/groovy/sdkman/steps/env.groovy index ce1eb81a2..8ca0a1936 100644 --- a/src/test/groovy/sdkman/steps/env.groovy +++ b/src/test/groovy/sdkman/steps/env.groovy @@ -36,7 +36,6 @@ etcDir = "${sdkmanDirEnv}/etc" as File extDir = "${sdkmanDirEnv}/ext" as File tmpDir = "${sdkmanDir}/tmp" as File -broadcastFile = new File(varDir, "broadcast") broadcastIdFile = new File(varDir, "broadcast_id") candidatesFile = new File(varDir, "candidates") versionFile = new File(varDir, "version") diff --git a/src/test/groovy/sdkman/steps/initialisation_steps.groovy b/src/test/groovy/sdkman/steps/initialisation_steps.groovy index d789ae497..ef20fc6b6 100644 --- a/src/test/groovy/sdkman/steps/initialisation_steps.groovy +++ b/src/test/groovy/sdkman/steps/initialisation_steps.groovy @@ -10,8 +10,6 @@ import static cucumber.api.groovy.EN.And import static sdkman.stubs.WebServiceStub.primeEndpointWithString import static sdkman.stubs.WebServiceStub.primeSelfupdate -def BROADCAST_MESSAGE = "broadcast message" - And(~'^the sdkman work folder is created$') { -> assert sdkmanDir.isDirectory(), "The SDKMAN directory does not exist." } @@ -36,7 +34,6 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { Str And(~'^the internet is reachable$') { -> primeEndpointWithString("/broadcast/latest/id", "12345") - primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE) primeEndpointWithString("/app/stable", sdkmanVersion) primeSelfupdate() @@ -53,7 +50,6 @@ And(~'^the internet is not reachable$') { -> And(~'^offline mode is disabled with reachable internet$') { -> primeEndpointWithString("/broadcast/latest/id", "12345") - primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE) primeEndpointWithString("/app/stable", sdkmanVersion) offlineMode = false @@ -63,7 +59,6 @@ And(~'^offline mode is disabled with reachable internet$') { -> And(~'^offline mode is enabled with reachable internet$') { -> primeEndpointWithString("/broadcast/latest/id", "12345") - primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE) primeEndpointWithString("/app/stable", sdkmanVersion) offlineMode = true diff --git a/src/test/resources/features/broadcast.feature b/src/test/resources/features/broadcast.feature deleted file mode 100644 index 5d603e979..000000000 --- a/src/test/resources/features/broadcast.feature +++ /dev/null @@ -1,36 +0,0 @@ -Feature: Broadcast - - Background: - Given the internet is reachable - And an initialised environment - And the system is bootstrapped - - Scenario: A command is issued with no prior Broadcast received - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk version" - Then I see "This is a LIVE Broadcast!" - - Scenario: A command is issued where the prior Broadcast was different to the Live one - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk version" - Then I see "This is a LIVE Broadcast!" - - Scenario: A command is issued where the prior Broadcast was the same as the Live one - Given a prior Broadcast "This is a LIVE Broadcast!" with id "12345" was issued - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk version" - Then I do not see "This is a LIVE Broadcast!" - - Scenario: A Broadcast command recalls a prior Broadcast - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And a new Broadcast "This is an OLD Broadcast!" with id "12344" is available - When I enter "sdk broadcast" - Then I see "This is an OLD Broadcast!" - - Scenario: A Broadcast command is issued with no prior Broadcast received - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk broadcast" - Then I see "This is a LIVE Broadcast!" diff --git a/src/test/resources/features/checksum_verification.feature b/src/test/resources/features/checksum_verification.feature index a9c27ade8..03d3b8986 100644 --- a/src/test/resources/features/checksum_verification.feature +++ b/src/test/resources/features/checksum_verification.feature @@ -61,7 +61,8 @@ Feature: Verify checksums And the candidate "grails" version "1.3.9" is installed And the response headers file is created for candidate "grails" and version "1.3.9" And the exit code is 0 - + + @manual Scenario: Abort installation after download of a binary with invalid SHA checksum Given the system is bootstrapped And the candidate "grails" version "1.3.9" is available for download with checksum "c68e386a6deec9fc4c1e18df21f927000000000e" using algorithm "SHA-256" diff --git a/src/test/resources/features/flush.feature b/src/test/resources/features/flush.feature index 34e64908e..096b3f5dc 100644 --- a/src/test/resources/features/flush.feature +++ b/src/test/resources/features/flush.feature @@ -14,17 +14,6 @@ Feature: Flush And I see "1 archive(s) flushed" And I see "1 archive(s) flushed" - Scenario: Clean up the current Broadcast - Given a prior Broadcast "This is an old broadcast" with id "12344" was issued - When I enter "sdk flush broadcast" - Then no broadcast message can be found - And I see "Broadcast has been flushed." - - Scenario: Clean up an uninitialised Broadcast - Given the broadcast has been flushed - When I enter "sdk flush broadcast" - Then I see "No prior broadcast found so not flushed." - Scenario: Clean up the last known Remote Version Given a prior version "5.0.0" was detected When I enter "sdk flush version" diff --git a/src/test/resources/features/mnemonics.feature b/src/test/resources/features/mnemonics.feature index 3aac8efa0..06bfc603b 100644 --- a/src/test/resources/features/mnemonics.feature +++ b/src/test/resources/features/mnemonics.feature @@ -80,13 +80,6 @@ Feature: Mnemonics Then I see "Default groovy version set to 2.0.5" And the candidate "groovy" version "2.0.5" should be the default - Scenario: Shortcut for a Broadcast command issued - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - And the system is bootstrapped - When I enter "sdk b" - Then I see "This is a LIVE Broadcast!" - Scenario: Shortcut for displaying Home directory Given an initialised environment without debug prints And the candidate "grails" version "2.1.0" is already installed and default diff --git a/src/test/resources/features/offline_mode.feature b/src/test/resources/features/offline_mode.feature index eab3b4fd7..064f96797 100644 --- a/src/test/resources/features/offline_mode.feature +++ b/src/test/resources/features/offline_mode.feature @@ -48,16 +48,6 @@ Feature: Offline Mode Then I see "INTERNET NOT REACHABLE!" And I see "Stop! grails 2.1.0 is not available while offline." - # broadcast - - Scenario: Recall a broadcast while in Offline Mode - Given offline mode is enabled with reachable internet - And an initialised environment - And the system is bootstrapped - When a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And I enter "sdk broadcast" - Then I see "This is an OLD Broadcast!" - # sdk version Scenario: Determine the sdkman version while in Offline Mode diff --git a/src/test/resources/features/service_unavailable.feature b/src/test/resources/features/service_unavailable.feature index f78810f90..98289803f 100644 --- a/src/test/resources/features/service_unavailable.feature +++ b/src/test/resources/features/service_unavailable.feature @@ -112,14 +112,6 @@ Feature: Service Unavailable When I enter "sdk version" Then I see the current sdkman version - # broadcast command - - Scenario: Recall a broadcast while Offline - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And the system is bootstrapped - When I enter "sdk broadcast" - Then I see "This is an OLD Broadcast!" - # help command Scenario: Request help while Offline From 010736e899da0452f3fb0f7f71b17fa378b47200 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 1 Mar 2023 17:06:08 +0000 Subject: [PATCH 39/84] Simplify parameter propagation in the main sdk function. --- src/main/bash/sdkman-main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index c40f9facd..d45c31990 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -146,7 +146,7 @@ function sdk() { local converted_command_name=$(echo "$COMMAND" | tr '-' '_') # Available as a shell function - __sdk_"$converted_command_name" "$QUALIFIER" "$3" "$4" + __sdk_"$converted_command_name" "${@:2}" fi final_rc=$? From a89a8cc77458f0f081c5f8100bbe1e6a34225b60 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 1 Mar 2023 17:49:58 +0000 Subject: [PATCH 40/84] Strip out the broadcast id and rename to healthcheck where needed. --- src/main/bash/sdkman-availability.sh | 38 +++++-------------- .../CandidatesCacheUpdateFailureSpec.groovy | 4 +- .../specs/CandidatesCacheUpdateSpec.groovy | 4 +- .../sdkman/specs/CurrentCommandSpec.groovy | 4 +- .../groovy/sdkman/specs/SelfupdateSpec.groovy | 4 +- src/test/groovy/sdkman/steps/env.groovy | 2 +- .../sdkman/steps/initialisation_steps.groovy | 6 +-- 7 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/main/bash/sdkman-availability.sh b/src/main/bash/sdkman-availability.sh index 4f147d5f8..696117b5e 100644 --- a/src/main/bash/sdkman-availability.sh +++ b/src/main/bash/sdkman-availability.sh @@ -17,25 +17,24 @@ # function __sdkman_update_service_availability() { - local broadcast_live_id=$(__sdkman_determine_broadcast_id) - __sdkman_set_availability "$broadcast_live_id" - __sdkman_update_broadcast_id "$broadcast_live_id" + local healthcheck_status=$(__sdkman_determine_healthcheck_status) + __sdkman_set_availability "$healthcheck_status" } -function __sdkman_determine_broadcast_id() { +function __sdkman_determine_healthcheck_status() { if [[ "$SDKMAN_OFFLINE_MODE" == "true" || "$COMMAND" == "offline" && "$QUALIFIER" == "enable" ]]; then echo "" else - echo $(__sdkman_secure_curl_with_timeouts "${SDKMAN_CANDIDATES_API}/broadcast/latest/id") + echo $(__sdkman_secure_curl_with_timeouts "${SDKMAN_CANDIDATES_API}/healthcheck") fi } function __sdkman_set_availability() { - local broadcast_id="$1" - local detect_html="$(echo "$broadcast_id" | tr '[:upper:]' '[:lower:]' | grep 'html')" - if [[ -z "$broadcast_id" ]]; then + local healthcheck_status="$1" + local detect_html="$(echo "$healthcheck_status" | tr '[:upper:]' '[:lower:]' | grep 'html')" + if [[ -z "$healthcheck_status" ]]; then SDKMAN_AVAILABLE="false" - __sdkman_display_offline_warning "$broadcast_id" + __sdkman_display_offline_warning "$healthcheck_status" elif [[ -n "$detect_html" ]]; then SDKMAN_AVAILABLE="false" __sdkman_display_proxy_warning @@ -45,8 +44,8 @@ function __sdkman_set_availability() { } function __sdkman_display_offline_warning() { - local broadcast_id="$1" - if [[ -z "$broadcast_id" && "$COMMAND" != "offline" && "$SDKMAN_OFFLINE_MODE" != "true" ]]; then + local healthcheck_status="$1" + if [[ -z "$healthcheck_status" && "$COMMAND" != "offline" && "$SDKMAN_OFFLINE_MODE" != "true" ]]; then __sdkman_echo_red "==== INTERNET NOT REACHABLE! ===================================================" __sdkman_echo_red "" __sdkman_echo_red " Some functionality is disabled or only partially available." @@ -65,20 +64,3 @@ function __sdkman_display_proxy_warning() { __sdkman_echo_red "================================================================================" echo "" } - -function __sdkman_update_broadcast_id() { - local broadcast_live_id broadcast_id_file broadcast_old_id - - broadcast_live_id="$1" - broadcast_id_file="${SDKMAN_DIR}/var/broadcast_id" - broadcast_old_id="" - - if [[ -f "$broadcast_id_file" ]]; then - broadcast_old_id=$(< "$broadcast_id_file") - fi - - if [[ "$SDKMAN_AVAILABLE" == "true" && "$broadcast_live_id" != "$broadcast_old_id" && "$COMMAND" != "selfupdate" && "$COMMAND" != "flush" ]]; then - mkdir -p "${SDKMAN_DIR}/var" - echo "$broadcast_live_id" | tee "$broadcast_id_file" > /dev/null - fi -} diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy index 5f2eef230..d51c208bf 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy @@ -6,14 +6,14 @@ class CandidatesCacheUpdateFailureSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" static final String CANDIDATES_ALL_ENDPOINT = "$CANDIDATES_API/candidates/all" File candidatesCache def setup() { candidatesCache = new File("${sdkmanDotDirectory}/var", "candidates") - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") .primeWith(CANDIDATES_ALL_ENDPOINT, "echo html") sdkmanBashEnvBuilder.withConfiguration("sdkman_debug_mode", "true") } diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index f7120091b..a9131658d 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -6,14 +6,14 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" static final String CANDIDATES_ALL_ENDPOINT = "$CANDIDATES_API/candidates/all" File candidatesCache def setup() { candidatesCache = new File("${sdkmanDotDirectory}/var", "candidates") - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") .primeWith(CANDIDATES_ALL_ENDPOINT, "echo groovy,scala") sdkmanBashEnvBuilder.withConfiguration("sdkman_debug_mode", "true") } diff --git a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy index c1fcd1e96..ea5a296ae 100644 --- a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy @@ -9,10 +9,10 @@ import static java.nio.file.Files.createSymbolicLink class CurrentCommandSpec extends SdkmanEnvSpecification { static final CANDIDATES_API = "http://localhost:8080/2" - static final BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" def setup() { - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") } void "should display current version of all candidates installed"() { diff --git a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy index 2ac64e547..4ba6a55e8 100644 --- a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy @@ -8,11 +8,11 @@ import static java.time.temporal.ChronoUnit.DAYS class SelfupdateSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" static final String VERSION_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" def setup() { - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") curlStub.primeWith(VERSION_ENDPOINT, "echo 5.0.0") } diff --git a/src/test/groovy/sdkman/steps/env.groovy b/src/test/groovy/sdkman/steps/env.groovy index 8ca0a1936..aff9e647d 100644 --- a/src/test/groovy/sdkman/steps/env.groovy +++ b/src/test/groovy/sdkman/steps/env.groovy @@ -36,7 +36,7 @@ etcDir = "${sdkmanDirEnv}/etc" as File extDir = "${sdkmanDirEnv}/ext" as File tmpDir = "${sdkmanDir}/tmp" as File -broadcastIdFile = new File(varDir, "broadcast_id") +healthcheckFile = new File(varDir, "healthcheck") candidatesFile = new File(varDir, "candidates") versionFile = new File(varDir, "version") initScript = new File(binDir, "sdkman-init.sh") diff --git a/src/test/groovy/sdkman/steps/initialisation_steps.groovy b/src/test/groovy/sdkman/steps/initialisation_steps.groovy index ef20fc6b6..5ec0f8fe6 100644 --- a/src/test/groovy/sdkman/steps/initialisation_steps.groovy +++ b/src/test/groovy/sdkman/steps/initialisation_steps.groovy @@ -33,7 +33,7 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { Str } And(~'^the internet is reachable$') { -> - primeEndpointWithString("/broadcast/latest/id", "12345") + primeEndpointWithString("/healthcheck", "12345") primeEndpointWithString("/app/stable", sdkmanVersion) primeSelfupdate() @@ -49,7 +49,7 @@ And(~'^the internet is not reachable$') { -> } And(~'^offline mode is disabled with reachable internet$') { -> - primeEndpointWithString("/broadcast/latest/id", "12345") + primeEndpointWithString("/healthcheck", "12345") primeEndpointWithString("/app/stable", sdkmanVersion) offlineMode = false @@ -58,7 +58,7 @@ And(~'^offline mode is disabled with reachable internet$') { -> } And(~'^offline mode is enabled with reachable internet$') { -> - primeEndpointWithString("/broadcast/latest/id", "12345") + primeEndpointWithString("/healthcheck", "12345") primeEndpointWithString("/app/stable", sdkmanVersion) offlineMode = true From 4b172a6d8744b8e7bfa7f7d9c4b0653fb9e5716c Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Fri, 3 Mar 2023 08:43:23 +0000 Subject: [PATCH 41/84] Remove auto-update feature. --- .../sdkman-cli/brew/formula.rb.tpl | 1 - src/main/bash/sdkman-main.sh | 5 -- src/main/bash/sdkman-selfupdate.sh | 35 ---------- .../groovy/sdkman/specs/SelfupdateSpec.groovy | 31 --------- .../resources/features/self_update.feature | 69 ------------------- 5 files changed, 141 deletions(-) diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl index 6904af617..93072611c 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl @@ -17,7 +17,6 @@ class {{brewFormulaName}} < Formula sdkman_auto_answer=false sdkman_auto_complete=true sdkman_auto_env=false - sdkman_auto_update=false sdkman_beta_channel=false sdkman_colour_enable=true sdkman_curl_connect_timeout=7 diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index d45c31990..8f9b7c407 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -149,10 +149,5 @@ function sdk() { __sdk_"$converted_command_name" "${@:2}" fi final_rc=$? - - # Attempt upgrade after all is done - if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_feature" == "true" && "$sdkman_auto_update" == "true" ]]; then - __sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION" - fi return $final_rc } diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 7e2b7753c..31af763bd 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -32,38 +32,3 @@ function __sdk_selfupdate() { __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable/${SDKMAN_PLATFORM}" | bash fi } - -function __sdkman_auto_update() { - local remote_version version delay_upgrade - - remote_version="$1" - version="$2" - delay_upgrade="${SDKMAN_DIR}/var/delay_upgrade" - - if [[ -n "$(find "$delay_upgrade" -mtime +1)" && "$remote_version" != "$version" ]]; then - echo "" - echo "" - __sdkman_echo_yellow "ATTENTION: A new version of SDKMAN is available..." - echo "" - __sdkman_echo_no_colour "The current version is $remote_version, but you have $version." - echo "" - - if [[ "$sdkman_auto_answer" == false ]]; then - __sdkman_echo_confirm "Would you like to upgrade now? (Y/n): " - read upgrade - fi - - if [[ -z "$upgrade" ]]; then - upgrade="Y" - fi - - if [[ "$upgrade" == "Y" || "$upgrade" == "y" ]]; then - __sdk_selfupdate "force" - unset upgrade - else - __sdkman_echo_no_colour "Not upgrading today..." - fi - - touch "$delay_upgrade" - fi -} diff --git a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy index 4ba6a55e8..1d7a5dae6 100644 --- a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy @@ -57,35 +57,4 @@ class SelfupdateSpec extends SdkmanEnvSpecification { "false" | { it.contains("Invalid command: selfupdate") } "true" | { it.contains("No update available at this time.") } } - - def "should perform an autoupdate when the selfupdate feature is toggled on and autoupdate is enabled"() { - given: - new File("$sdkmanDotDirectory/var/delay_upgrade").with { - parentFile.mkdirs() - createNewFile() - lastModified = Instant.now().minus(2, DAYS).toEpochMilli() - } - - bash = sdkmanBashEnvBuilder - .withSdkmanVersion("4.0.0") - .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) - .withConfiguration("sdkman_auto_update", autoUpdateEnabled) - .withConfiguration("sdkman_auto_answer", "true") - .build() - - bash.start() - bash.execute("source $bootstrapScript") - - when: - bash.execute("sdk version") - - then: - verifyOutput(bash.output) - - where: - selfupdateFeature | autoUpdateEnabled | verifyOutput - "true" | "true" | { it.contains("ATTENTION: A new version of SDKMAN is available...") } - "true" | "false" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } - "false" | "true" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } - } } diff --git a/src/test/resources/features/self_update.feature b/src/test/resources/features/self_update.feature index 2baf8252a..8ef34fe9e 100644 --- a/src/test/resources/features/self_update.feature +++ b/src/test/resources/features/self_update.feature @@ -14,75 +14,6 @@ Feature: Self Update And I see "Updating SDKMAN..." And I see "Successfully upgraded SDKMAN." - Scenario: Selfupdate when out of date - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk selfupdate" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Updating SDKMAN..." - And I see "Successfully upgraded SDKMAN." - - Scenario: Agree to a suggested Selfupdate - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "Y" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Successfully upgraded SDKMAN." - And I do not see "Not upgrading today..." - - Scenario: Do not agree to a suggested Selfupdate - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "N" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I do not see "Successfully upgraded SDKMAN." - - Scenario: Automatically Selfupdate - Given an outdated initialised environment - And the configuration file has been primed with "sdkman_auto_answer=true" - And the system is bootstrapped - When I enter "sdk help" - Then I see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Successfully upgraded SDKMAN." - - Scenario: Do not automatically Selfupdate - Given an outdated initialised environment - And the configuration file has been primed with "sdkman_auto_answer=false" - And the system is bootstrapped - When I enter "sdk help" and answer "n" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I do not see "Successfully upgraded SDKMAN." - - Scenario: Do not check and prompt for update - Given an outdated initialised environment - And the configuration file has been primed with "sdkman_selfupdate_enable=false" - And the system is bootstrapped - When I enter "sdk help" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - - Scenario: Bother the user with Upgrade message once a day - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "N" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I enter "sdk help" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading now..." - And I do not see "Successfully upgraded SDKMAN." - Scenario: Selfupdate when not out of date Given an initialised environment And the system is bootstrapped From 65402771ee225092eb8dc632268fcfd95ca2247a Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Sun, 19 Mar 2023 13:54:09 +0100 Subject: [PATCH 42/84] chore: Improve `sdk env` error handling (#1193) --- src/main/bash/sdkman-env.sh | 19 +++++++++++++-- .../groovy/sdkman/specs/EnvCommandSpec.groovy | 23 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/bash/sdkman-env.sh b/src/main/bash/sdkman-env.sh index 5d2ce6589..28b541c65 100644 --- a/src/main/bash/sdkman-env.sh +++ b/src/main/bash/sdkman-env.sh @@ -54,10 +54,25 @@ function __sdkman_load_env() { return 1 fi - __sdkman_env_each_candidate "$sdkmanrc" "__sdk_use" && + __sdkman_env_each_candidate "$sdkmanrc" "__sdkman_check_and_use" && SDKMAN_ENV=$PWD } +function __sdkman_check_and_use() { + local -r candidate=$1 + local -r version=$2 + + if [[ ! -d "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}" ]]; then + __sdkman_echo_red "Stop! $candidate $version is not installed." + echo "" + __sdkman_echo_yellow "Run 'sdk env install' to install it." + + return 1 + fi + + __sdk_use "$candidate" "$version" +} + function __sdkman_create_env_file() { local sdkmanrc="$1" @@ -130,7 +145,7 @@ function __sdkman_env_each_candidate() { return 1 fi - $func "${normalised_line%=*}" "${normalised_line#*=}" + $func "${normalised_line%=*}" "${normalised_line#*=}" || return done < "$filepath" } diff --git a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy index 3e76783f2..f52eb9928 100644 --- a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy @@ -357,6 +357,29 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } } + def "should issue an error when .sdkmanrc contains a candidate version which is not installed"() { + given: + bash = sdkmanBashEnvBuilder + .withVersionCache("x.y.z") + .withOfflineMode(true) + .build() + + new File(bash.workDir, ".sdkmanrc").text = "groovy=2.4.1" + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk env") + + then: + verifyAll(bash) { + status == 1 + output.contains("Stop! groovy 2.4.1 is not installed.") + output.contains("Run 'sdk env install' to install it.") + } + } + def "should support blank lines, comments and inline comments"() { given: new FileTreeBuilder(candidatesDirectory).with { From 40d3c2f29353072f714c81d40911af71a9f29971 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Thu, 16 Mar 2023 18:40:48 +0000 Subject: [PATCH 43/84] Removes version cache refresh. --- gradle/archive.gradle | 1 - src/main/bash/sdkman-cache.sh | 28 --- src/main/bash/sdkman-init.sh | 4 - src/main/bash/sdkman-main.sh | 2 - src/main/bash/sdkman-version.sh | 3 +- .../specs/BetaChannelBootstrapSpec.groovy | 104 ----------- .../specs/CandidatesCacheUpdateSpec.groovy | 10 +- .../groovy/sdkman/specs/SelfupdateSpec.groovy | 2 +- .../specs/VersionCacheBootstrapSpec.groovy | 164 ------------------ .../features/idempotent_self_update.feature | 3 +- 10 files changed, 7 insertions(+), 314 deletions(-) delete mode 100644 src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy delete mode 100644 src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy diff --git a/gradle/archive.gradle b/gradle/archive.gradle index 827529262..0c5baa0ce 100644 --- a/gradle/archive.gradle +++ b/gradle/archive.gradle @@ -10,7 +10,6 @@ task prepareBin(type: Copy) { filter( ReplaceTokens, tokens: [ - SDKMAN_VERSION : sdkmanVersion, SDKMAN_CANDIDATES_API: candidatesApi ] ) diff --git a/src/main/bash/sdkman-cache.sh b/src/main/bash/sdkman-cache.sh index b21d19043..b64e1df72 100644 --- a/src/main/bash/sdkman-cache.sh +++ b/src/main/bash/sdkman-cache.sh @@ -35,31 +35,3 @@ function ___sdkman_check_candidates_cache() { return 0 fi } - -function ___sdkman_check_version_cache() { - local version_url - local version_file="${SDKMAN_DIR}/var/version" - - if [[ "$sdkman_beta_channel" != "true" && -f "$version_file" && -z "$(find "$version_file" -mmin +$((60 * 24)))" ]]; then - __sdkman_echo_debug "Not refreshing version cache now..." - SDKMAN_REMOTE_VERSION=$(cat "$version_file") - else - __sdkman_echo_debug "Version cache needs updating..." - if [[ "$sdkman_beta_channel" == "true" ]]; then - __sdkman_echo_debug "Refreshing version cache with BETA version." - version_url="${SDKMAN_CANDIDATES_API}/broker/download/sdkman/version/beta" - else - __sdkman_echo_debug "Refreshing version cache with STABLE version." - version_url="${SDKMAN_CANDIDATES_API}/broker/download/sdkman/version/stable" - fi - - SDKMAN_REMOTE_VERSION=$(__sdkman_secure_curl_with_timeouts "$version_url") - if [[ -z "$SDKMAN_REMOTE_VERSION" || -n "$(echo "$SDKMAN_REMOTE_VERSION" | tr '[:upper:]' '[:lower:]' | grep 'html')" ]]; then - __sdkman_echo_debug "Version information corrupt or empty! Ignoring: $SDKMAN_REMOTE_VERSION" - SDKMAN_REMOTE_VERSION="$SDKMAN_VERSION" - else - __sdkman_echo_debug "Overwriting version cache with: $SDKMAN_REMOTE_VERSION" - echo "${SDKMAN_REMOTE_VERSION}" | tee "$version_file" > /dev/null - fi - fi -} diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index dcbaa0880..b56aced0e 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -17,10 +17,6 @@ # # set env vars if not set -if [ -z "$SDKMAN_VERSION" ]; then - export SDKMAN_VERSION="@SDKMAN_VERSION@" -fi - if [ -z "$SDKMAN_CANDIDATES_API" ]; then export SDKMAN_CANDIDATES_API="@SDKMAN_CANDIDATES_API@" fi diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index 8f9b7c407..1b91f894f 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -73,8 +73,6 @@ function sdk() { if [[ "$COMMAND" != "update" ]]; then ___sdkman_check_candidates_cache "$SDKMAN_CANDIDATES_CACHE" || return 1 fi - # Check version cache - ___sdkman_check_version_cache # Always presume internet availability SDKMAN_AVAILABLE="true" diff --git a/src/main/bash/sdkman-version.sh b/src/main/bash/sdkman-version.sh index 6d4351ee8..0b3b49335 100644 --- a/src/main/bash/sdkman-version.sh +++ b/src/main/bash/sdkman-version.sh @@ -17,6 +17,7 @@ # function __sdk_version() { + local version=$(cat $SDKMAN_DIR/var/version) echo "" - __sdkman_echo_yellow "SDKMAN ${SDKMAN_VERSION}" + __sdkman_echo_yellow "SDKMAN $version" } diff --git a/src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy b/src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy deleted file mode 100644 index e378d877f..000000000 --- a/src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy +++ /dev/null @@ -1,104 +0,0 @@ -package sdkman.specs - -import sdkman.support.SdkmanEnvSpecification - -class BetaChannelBootstrapSpec extends SdkmanEnvSpecification { - - static final TWO_DAYS_AGO = System.currentTimeMillis() - (48 * 60 * 60 * 1000) - static final CANDIDATES_API = "http://localhost:8080/2" - static final CLI_STABLE_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" - static final CLI_BETA_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/beta" - - File versionCache - - def setup() { - versionCache = new File("${sdkmanDotDirectory}/var", "version") - sdkmanBashEnvBuilder.withCandidates(["groovy"]) - } - - void "should attempt immediate upgrade of stable to beta version if beta channel is first enabled"() { - given: - def betaVersion = "x.y.c" - curlStub.primeWith(CLI_BETA_ENDPOINT, "echo $betaVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "true") - .withVersionCache("x.y.b") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(betaVersion) - } - - void "should attempt downgrade of beta to stable version if beta channel is first disabled"() { - given: - def stableVersion = "x.y.b" - curlStub.primeWith(CLI_STABLE_ENDPOINT, "echo $stableVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "false") - .withVersionCache("x.y.c") - .build() - versionCache.setLastModified(TWO_DAYS_AGO) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(stableVersion) - } - - void "should attempt immediate upgrade to new version of beta channel if available"() { - given: - def newerBetaVersion = "x.y.d" - curlStub.primeWith(CLI_BETA_ENDPOINT, "echo $newerBetaVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "true") - .withVersionCache("x.y.c") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(newerBetaVersion) - } - - void "should attempt upgrade to new version of stable channel if available"() { - given: - def newerStableVersion = "x.y.d" - curlStub.primeWith(CLI_STABLE_ENDPOINT, "echo $newerStableVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "false") - .withVersionCache("x.y.c") - .build() - versionCache.setLastModified(TWO_DAYS_AGO) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(newerStableVersion) - } -} diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index a9131658d..3d5842fed 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -53,14 +53,11 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { when: bash.execute("source $bootstrapScript") - bash.execute("sdk version") + bash.execute("sdk help") then: bash.output.contains('We periodically need to update the local cache.') bash.output.contains('$ sdk update') - - and: - bash.output.contains('SDKMAN 5.0.0') } void "should log a success message in debug mode when no update needed"() { @@ -74,13 +71,10 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { when: bash.execute("source $bootstrapScript") - bash.execute("sdk version") + bash.execute("sdk help") then: bash.output.contains('No update at this time. Using existing cache') - - and: - bash.output.contains('SDKMAN 5.0.0') } void "should bypass cache check if update command issued"() { diff --git a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy index 1d7a5dae6..5a8f000ab 100644 --- a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy @@ -55,6 +55,6 @@ class SelfupdateSpec extends SdkmanEnvSpecification { where: selfupdateFeature | verifyOutput "false" | { it.contains("Invalid command: selfupdate") } - "true" | { it.contains("No update available at this time.") } + "true" | { !it.contains("Invalid command: selfupdate") } } } diff --git a/src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy b/src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy deleted file mode 100644 index f24605ce2..000000000 --- a/src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy +++ /dev/null @@ -1,164 +0,0 @@ -package sdkman.specs - -import sdkman.support.SdkmanEnvSpecification - -import static java.lang.System.currentTimeMillis - -class VersionCacheBootstrapSpec extends SdkmanEnvSpecification { - - static final MORE_THAN_A_DAY_IN_MILLIS = 24 * 61 * 60 * 1000 - - static final CANDIDATES_API = "http://localhost:8080/2" - static final CLI_VERSION_STABLE_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" - static final CLI_VERSION_BETA_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/beta" - static final CANDIDATES_ENDPOINT = "$CANDIDATES_API/candidates" - - File versionCache - - def setup() { - versionCache = new File("${sdkmanDotDirectory}/var", "version") - curlStub.primeWith(CANDIDATES_ENDPOINT, "echo 'groovy,scala'") - } - - void "should store version cache if does not exist"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo x.y.b") - bash = sdkmanBashEnvBuilder.build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.b") - } - - void "should not query server if unexpired version cache is found"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "sleep 50") //will timeout and fail if called - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.z") - } - - void "should refresh version cache if older than a day"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo x.y.b") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.a") - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.b") - } - - void "should fallback and ignore version if version cache expired and api is offline"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo ''") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.text.contains("x.y.z") - } - - void "should not go offline if curl times out"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo ''") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - !bash.output.contains("SDKMAN can't reach the internet so going offline.") - } - - void "should ignore version if api returns garbage"() { - given: - def sdkmanVersion = "x.y.z" - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo 'sorry'") - bash = sdkmanBashEnvBuilder - .withVersionCache(sdkmanVersion) - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.text.contains(sdkmanVersion) - } - - void "should always refresh version cache if on beta_channel"() { - given: - curlStub.primeWith(CLI_VERSION_BETA_ENDPOINT, "echo x.y.z") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.w") - .withConfiguration("sdkman_beta_channel", "true") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.z") - } -} diff --git a/src/test/resources/features/idempotent_self_update.feature b/src/test/resources/features/idempotent_self_update.feature index d5373f5cc..977fad42a 100644 --- a/src/test/resources/features/idempotent_self_update.feature +++ b/src/test/resources/features/idempotent_self_update.feature @@ -8,7 +8,8 @@ Feature: Idempotent Self Update Scenario: Attempt Self Update on an up to date system When I enter "sdk selfupdate" - Then I see "No update available at this time." + #TODO Fix this without relying on version file + #Then I see "No update available at this time." Scenario: Force Self Update on an up to date system When I enter "sdk selfupdate force" From e78438370dd88ce366cf03928d85f62ec2541ca4 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Thu, 16 Mar 2023 18:41:10 +0000 Subject: [PATCH 44/84] Update sdk env. --- .sdkmanrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sdkmanrc b/.sdkmanrc index 42efcf3ea..985fcd876 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,3 +1,3 @@ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below -java=11.0.13-tem +java=11.0.17-tem From 8a8c69de2d9e4487f7c5d794d241522df96904b2 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 18 Mar 2023 17:38:02 +0000 Subject: [PATCH 45/84] Fix selfupdate. Compare local and remote versions on selfupdate. --- src/main/bash/sdkman-selfupdate.sh | 21 +++++++++++++++---- ...ec.groovy => SelfupdateFeatureSpec.groovy} | 2 +- .../sdkman/steps/initialisation_steps.groovy | 6 +++--- .../features/idempotent_self_update.feature | 16 -------------- .../resources/features/self_update.feature | 20 +++++++----------- 5 files changed, 29 insertions(+), 36 deletions(-) rename src/test/groovy/sdkman/specs/{SelfupdateSpec.groovy => SelfupdateFeatureSpec.groovy} (96%) delete mode 100644 src/test/resources/features/idempotent_self_update.feature diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 31af763bd..80472958b 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -18,17 +18,30 @@ function __sdk_selfupdate() { local force_selfupdate + local sdkman_version_api - force_selfupdate="$1" if [[ "$SDKMAN_AVAILABLE" == "false" ]]; then echo "This command is not available while offline." - elif [[ "$SDKMAN_REMOTE_VERSION" == "$SDKMAN_VERSION" && "$force_selfupdate" != "force" ]]; then + return 1 + fi + + if [[ "$sdkman_beta_channel" == "true" ]]; then + sdkman_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/beta" + else + sdkman_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/stable" + fi + + sdkman_remote_version=$(__sdkman_secure_curl "$sdkman_version_api") + sdkman_local_version=$(cat "$SDKMAN_DIR/var/version") + __sdkman_echo_debug "Local version: $sdkman_local_version; remote version: $sdkman_remote_version" + + force_selfupdate="$1" + export sdkman_debug_mode + if [[ "$sdkman_local_version" == "$sdkman_remote_version" && "$force_selfupdate" != "force" ]]; then echo "No update available at this time." elif [[ "$sdkman_beta_channel" == "true" ]]; then - export sdkman_debug_mode __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta/${SDKMAN_PLATFORM}" | bash else - export sdkman_debug_mode __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable/${SDKMAN_PLATFORM}" | bash fi } diff --git a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateFeatureSpec.groovy similarity index 96% rename from src/test/groovy/sdkman/specs/SelfupdateSpec.groovy rename to src/test/groovy/sdkman/specs/SelfupdateFeatureSpec.groovy index 5a8f000ab..a5738c363 100644 --- a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/SelfupdateFeatureSpec.groovy @@ -6,7 +6,7 @@ import java.time.Instant import static java.time.temporal.ChronoUnit.DAYS -class SelfupdateSpec extends SdkmanEnvSpecification { +class SelfupdateFeatureSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" static final String VERSION_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" diff --git a/src/test/groovy/sdkman/steps/initialisation_steps.groovy b/src/test/groovy/sdkman/steps/initialisation_steps.groovy index 5ec0f8fe6..180fce0e0 100644 --- a/src/test/groovy/sdkman/steps/initialisation_steps.groovy +++ b/src/test/groovy/sdkman/steps/initialisation_steps.groovy @@ -34,7 +34,7 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { Str And(~'^the internet is reachable$') { -> primeEndpointWithString("/healthcheck", "12345") - primeEndpointWithString("/app/stable", sdkmanVersion) + primeEndpointWithString("/broker/version/sdkman/script/stable", sdkmanVersion) primeSelfupdate() offlineMode = false @@ -50,7 +50,7 @@ And(~'^the internet is not reachable$') { -> And(~'^offline mode is disabled with reachable internet$') { -> primeEndpointWithString("/healthcheck", "12345") - primeEndpointWithString("/app/stable", sdkmanVersion) + primeEndpointWithString("/broker/version/sdkman/script/stable", sdkmanVersion) offlineMode = false serviceUrlEnv = SERVICE_UP_URL @@ -59,7 +59,7 @@ And(~'^offline mode is disabled with reachable internet$') { -> And(~'^offline mode is enabled with reachable internet$') { -> primeEndpointWithString("/healthcheck", "12345") - primeEndpointWithString("/app/stable", sdkmanVersion) + primeEndpointWithString("/broker/version/sdkman/script/stable", sdkmanVersion) offlineMode = true serviceUrlEnv = SERVICE_UP_URL diff --git a/src/test/resources/features/idempotent_self_update.feature b/src/test/resources/features/idempotent_self_update.feature deleted file mode 100644 index 977fad42a..000000000 --- a/src/test/resources/features/idempotent_self_update.feature +++ /dev/null @@ -1,16 +0,0 @@ -Feature: Idempotent Self Update - - Background: - Given the internet is reachable - And an initialised environment - And the system is bootstrapped - And an available selfupdate - - Scenario: Attempt Self Update on an up to date system - When I enter "sdk selfupdate" - #TODO Fix this without relying on version file - #Then I see "No update available at this time." - - Scenario: Force Self Update on an up to date system - When I enter "sdk selfupdate force" - Then I see "Successfully upgraded SDKMAN." diff --git a/src/test/resources/features/self_update.feature b/src/test/resources/features/self_update.feature index 8ef34fe9e..b962fb6e9 100644 --- a/src/test/resources/features/self_update.feature +++ b/src/test/resources/features/self_update.feature @@ -3,19 +3,15 @@ Feature: Self Update Background: Given the internet is reachable - - Scenario: Force a Selfupdate - Given an initialised environment + And an initialised environment And the system is bootstrapped - When I enter "sdk selfupdate force" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Updating SDKMAN..." - And I see "Successfully upgraded SDKMAN." + And an available selfupdate - Scenario: Selfupdate when not out of date - Given an initialised environment - And the system is bootstrapped + Scenario: Attempt Self Update on an up to date system When I enter "sdk selfupdate" Then I see "No update available at this time." + + Scenario: Force Self Update on an up to date system + When I enter "sdk selfupdate force" + Then I see "Successfully upgraded SDKMAN." + \ No newline at end of file From c7374b7a5d4c1855d150f0e7a37ad98c7cf155e0 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 18 Mar 2023 17:51:18 +0000 Subject: [PATCH 46/84] Preparation for considering native version in selfupdate. --- src/main/bash/sdkman-selfupdate.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 80472958b..ccbb90709 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -18,7 +18,8 @@ function __sdk_selfupdate() { local force_selfupdate - local sdkman_version_api + local sdkman_script_version_api + local sdkman_native_version_api if [[ "$SDKMAN_AVAILABLE" == "false" ]]; then echo "This command is not available while offline." @@ -26,18 +27,20 @@ function __sdk_selfupdate() { fi if [[ "$sdkman_beta_channel" == "true" ]]; then - sdkman_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/beta" + sdkman_script_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/beta" + sdkman_native_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/native/beta" else - sdkman_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/stable" + sdkman_script_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/stable" + sdkman_native_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/native/stable" fi - sdkman_remote_version=$(__sdkman_secure_curl "$sdkman_version_api") - sdkman_local_version=$(cat "$SDKMAN_DIR/var/version") - __sdkman_echo_debug "Local version: $sdkman_local_version; remote version: $sdkman_remote_version" + sdkman_remote_script_version=$(__sdkman_secure_curl "$sdkman_script_version_api") + sdkman_local_script_version=$(cat "$SDKMAN_DIR/var/version") + __sdkman_echo_debug "Script: local version: $sdkman_local_script_version; remote version: $sdkman_remote_script_version" force_selfupdate="$1" export sdkman_debug_mode - if [[ "$sdkman_local_version" == "$sdkman_remote_version" && "$force_selfupdate" != "force" ]]; then + if [[ "$sdkman_local_script_version" == "$sdkman_remote_script_version" && "$force_selfupdate" != "force" ]]; then echo "No update available at this time." elif [[ "$sdkman_beta_channel" == "true" ]]; then __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta/${SDKMAN_PLATFORM}" | bash From 6d2bcda8bb38e315bca7441bf37340a0de55165b Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 18 Mar 2023 18:38:08 +0000 Subject: [PATCH 47/84] Consider native version in selfupdate, fix tests and add coverage. --- src/main/bash/sdkman-selfupdate.sh | 7 ++- .../sdkman/env/SdkmanBashEnvBuilder.groovy | 25 ++++++---- .../sdkman/specs/ConfigCommandSpec.groovy | 2 +- .../sdkman/specs/CurrentCommandSpec.groovy | 2 +- .../groovy/sdkman/specs/EnvCommandSpec.groovy | 22 ++++----- .../sdkman/specs/InitialisationSpec.groovy | 2 +- .../sdkman/specs/SdkCompatibilitySpec.groovy | 2 +- src/test/groovy/sdkman/steps/env.groovy | 4 +- .../sdkman/steps/initialisation_steps.groovy | 46 ++++++------------- .../groovy/sdkman/steps/stub_steps.groovy | 2 +- .../resources/features/self_update.feature | 21 ++++++++- src/test/resources/features/version.feature | 2 +- 12 files changed, 73 insertions(+), 64 deletions(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index ccbb90709..dfc52de8c 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -35,12 +35,17 @@ function __sdk_selfupdate() { fi sdkman_remote_script_version=$(__sdkman_secure_curl "$sdkman_script_version_api") + sdkman_remote_native_version=$(__sdkman_secure_curl "$sdkman_native_version_api") + sdkman_local_script_version=$(cat "$SDKMAN_DIR/var/version") + sdkman_local_native_version=$(cat "$SDKMAN_DIR/var/version_native") + __sdkman_echo_debug "Script: local version: $sdkman_local_script_version; remote version: $sdkman_remote_script_version" + __sdkman_echo_debug "Native: local version: $sdkman_local_native_version; remote version: $sdkman_remote_native_version" force_selfupdate="$1" export sdkman_debug_mode - if [[ "$sdkman_local_script_version" == "$sdkman_remote_script_version" && "$force_selfupdate" != "force" ]]; then + if [[ "$sdkman_local_script_version" == "$sdkman_remote_script_version" && "$sdkman_local_native_version" == "$sdkman_remote_native_version" && "$force_selfupdate" != "force" ]]; then echo "No update available at this time." elif [[ "$sdkman_beta_channel" == "true" ]]; then __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta/${SDKMAN_PLATFORM}" | bash diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index e9f65b2f9..fbbfbe360 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -21,10 +21,10 @@ class SdkmanBashEnvBuilder { private List candidates = ['groovy', 'grails', 'java'] private boolean offlineMode = false private String candidatesApi = "http://localhost:8080/2" - private String sdkmanVersion = "5.0.0" private String jdkHome = "/path/to/my/jdk" private String httpProxy - private String versionCache + private String scriptVersion + private String nativeVersion private boolean debugMode = true Map config = [ @@ -84,13 +84,13 @@ class SdkmanBashEnvBuilder { this } - SdkmanBashEnvBuilder withVersionCache(String version) { - this.versionCache = version + SdkmanBashEnvBuilder withScriptVersion(String version) { + this.scriptVersion = version this } - SdkmanBashEnvBuilder withSdkmanVersion(String version) { - this.sdkmanVersion = version + SdkmanBashEnvBuilder withNativeVersion(String version) { + this.nativeVersion = version this } @@ -117,7 +117,8 @@ class SdkmanBashEnvBuilder { initializeCandidates(sdkmanCandidatesDir, candidates) initializeCandidatesCache(sdkmanVarDir, candidates) initializeConfiguration(sdkmanEtcDir, config) - initializeVersionCache(sdkmanVarDir, versionCache) + initializeScriptVersionFile(sdkmanVarDir, scriptVersion) + initializeNativeVersionFile(sdkmanVarDir, nativeVersion) primeInitScript(sdkmanBinDir) primeModuleScripts(sdkmanSrcDir) @@ -128,7 +129,6 @@ class SdkmanBashEnvBuilder { SDKMAN_CANDIDATES_DIR: sdkmanCandidatesDir.absolutePath, SDKMAN_OFFLINE_MODE : "$offlineMode", SDKMAN_CANDIDATES_API: candidatesApi, - SDKMAN_VERSION : sdkmanVersion, sdkman_debug_mode : Boolean.toString(debugMode), JAVA_HOME : jdkHome ] @@ -146,13 +146,18 @@ class SdkmanBashEnvBuilder { directory } - private initializeVersionCache(File folder, String version) { + private initializeScriptVersionFile(File folder, String version) { if (version) { new File(folder, "version") << version } } - + private initializeNativeVersionFile(File folder, String version) { + if (version) { + new File(folder, "version_native") << version + } + } + private initializeCandidates(File folder, List candidates) { candidates.each { candidate -> new File(folder, candidate).mkdirs() diff --git a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy index 384c0a11f..43b9b3122 100644 --- a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy @@ -6,7 +6,7 @@ class ConfigCommandSpec extends SdkmanEnvSpecification { def "it should open the config in the system's default editor"() { given: bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .build() diff --git a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy index ea5a296ae..f59ec9fdb 100644 --- a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy @@ -41,7 +41,7 @@ class CurrentCommandSpec extends SdkmanEnvSpecification { bash = sdkmanBashEnvBuilder .withOfflineMode(false) - .withVersionCache("5.0.0") + .withScriptVersion("5.0.0") .withCandidates(installedCandidates.keySet().toList()) .build() diff --git a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy index f52eb9928..13c7c6d29 100644 --- a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy @@ -19,7 +19,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { bash = sdkmanBashEnvBuilder .withOfflineMode(true) - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .build() bash.start() @@ -61,7 +61,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .build() @@ -98,7 +98,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", sdkmanAutoEnv) .build() @@ -133,7 +133,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -164,7 +164,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -191,7 +191,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -225,7 +225,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { createSymbolicLink(Paths.get("$candidatesDirectory/groovy/current"), Paths.get("$candidatesDirectory/groovy/2.4.6")) bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -264,7 +264,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { createSymbolicLink(Paths.get("$candidatesDirectory/ant/current"), Paths.get("$candidatesDirectory/ant/1.10.8")) bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -312,7 +312,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -338,7 +338,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { def "should issue an error if .sdkmanrc contains a malformed candidate version"() { given: bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .build() @@ -389,7 +389,7 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .withOfflineMode(true) .build() diff --git a/src/test/groovy/sdkman/specs/InitialisationSpec.groovy b/src/test/groovy/sdkman/specs/InitialisationSpec.groovy index f49b0da80..a52649c09 100644 --- a/src/test/groovy/sdkman/specs/InitialisationSpec.groovy +++ b/src/test/groovy/sdkman/specs/InitialisationSpec.groovy @@ -15,7 +15,7 @@ class InitialisationSpec extends SdkmanEnvSpecification { def setup() { bash = sdkmanBashEnvBuilder .withCandidates(allCandidates) - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .build() prepareCandidateDirectories(allCandidates) } diff --git a/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy b/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy index cb5ba7bfc..aeb5549d0 100644 --- a/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy +++ b/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy @@ -12,7 +12,7 @@ class SdkCompatibilitySpec extends SdkmanEnvSpecification { def setup() { bash = sdkmanBashEnvBuilder .withCandidates(allCandidates) - .withVersionCache("x.y.z") + .withScriptVersion("x.y.z") .build() } diff --git a/src/test/groovy/sdkman/steps/env.groovy b/src/test/groovy/sdkman/steps/env.groovy index aff9e647d..5d42daf91 100644 --- a/src/test/groovy/sdkman/steps/env.groovy +++ b/src/test/groovy/sdkman/steps/env.groovy @@ -19,8 +19,8 @@ counter = "${(Math.random() * 10000).toInteger()}".padLeft(4, "0") localGroovyCandidate = "/tmp/groovy-core" as File -sdkmanVersion = "5.0.0" -sdkmanVersionOutdated = "4.0.0" +sdkmanScriptVersion = "5.0.0" +sdkmanNativeVersion = "0.0.1" sdkmanBaseEnv = FilesystemUtils.prepareBaseDir().absolutePath sdkmanBaseDir = sdkmanBaseEnv as File diff --git a/src/test/groovy/sdkman/steps/initialisation_steps.groovy b/src/test/groovy/sdkman/steps/initialisation_steps.groovy index 180fce0e0..342e49aee 100644 --- a/src/test/groovy/sdkman/steps/initialisation_steps.groovy +++ b/src/test/groovy/sdkman/steps/initialisation_steps.groovy @@ -32,9 +32,12 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { Str assert !archive.exists() } +And(~'^the sdkman (.*) version "(.*)" is available for download$') { format, version -> + primeEndpointWithString("/broker/version/sdkman/${format}/stable", version) +} + And(~'^the internet is reachable$') { -> primeEndpointWithString("/healthcheck", "12345") - primeEndpointWithString("/broker/version/sdkman/script/stable", sdkmanVersion) primeSelfupdate() offlineMode = false @@ -50,7 +53,6 @@ And(~'^the internet is not reachable$') { -> And(~'^offline mode is disabled with reachable internet$') { -> primeEndpointWithString("/healthcheck", "12345") - primeEndpointWithString("/broker/version/sdkman/script/stable", sdkmanVersion) offlineMode = false serviceUrlEnv = SERVICE_UP_URL @@ -59,7 +61,6 @@ And(~'^offline mode is disabled with reachable internet$') { -> And(~'^offline mode is enabled with reachable internet$') { -> primeEndpointWithString("/healthcheck", "12345") - primeEndpointWithString("/broker/version/sdkman/script/stable", sdkmanVersion) offlineMode = true serviceUrlEnv = SERVICE_UP_URL @@ -86,9 +87,9 @@ And(~'^an initialised environment$') { -> .withCandidatesApi(serviceUrlEnv) .withJdkHome(javaHome) .withHttpProxy(HTTP_PROXY) - .withVersionCache(sdkmanVersion) + .withScriptVersion(sdkmanScriptVersion) + .withNativeVersion(sdkmanNativeVersion) .withCandidates(localCandidates) - .withSdkmanVersion(sdkmanVersion) .build() } @@ -98,36 +99,13 @@ And(~'^an initialised environment without debug prints$') { -> .withCandidatesApi(serviceUrlEnv) .withJdkHome(javaHome) .withHttpProxy(HTTP_PROXY) - .withVersionCache(sdkmanVersion) + .withScriptVersion(sdkmanScriptVersion) + .withNativeVersion(sdkmanNativeVersion) .withCandidates(localCandidates) - .withSdkmanVersion(sdkmanVersion) .withDebugMode(false) .build() } -And(~'^an outdated initialised environment$') { -> - bash = SdkmanBashEnvBuilder.create(sdkmanBaseDir) - .withOfflineMode(offlineMode) - .withCandidatesApi(serviceUrlEnv) - .withJdkHome(javaHome) - .withHttpProxy(HTTP_PROXY) - .withVersionCache(sdkmanVersionOutdated) - .withSdkmanVersion(sdkmanVersionOutdated) - .build() - - def twoDaysAgoInMillis = System.currentTimeMillis() - 172800000 - - def upgradeFile = "$sdkmanDir/var/delay_upgrade" as File - upgradeFile.createNewFile() - upgradeFile.setLastModified(twoDaysAgoInMillis) - - def versionFile = "$sdkmanDir/var/version" as File - versionFile.setLastModified(twoDaysAgoInMillis) - - def initFile = "$sdkmanDir/bin/sdkman-init.sh" as File - initFile.text = initFile.text.replace(sdkmanVersion, sdkmanVersionOutdated) -} - And(~'^the system is bootstrapped$') { -> bash.start() bash.execute("source $sdkmanDirEnv/bin/sdkman-init.sh") @@ -137,8 +115,12 @@ And(~'^the system is bootstrapped again$') { -> bash.execute("source $sdkmanDirEnv/bin/sdkman-init.sh") } -And(~/^the sdkman version is "([^"]*)"$/) { String version -> - sdkmanVersion = version +And(~/^the sdkman scripts version is "([^"]*)"$/) { String version -> + sdkmanScriptVersion = version +} + +And(~/^the sdkman native version is "([^"]*)"$/) { String version -> + sdkmanNativeVersion = version } And(~/^the candidates cache is initialised with "(.*)"$/) { String candidate -> diff --git a/src/test/groovy/sdkman/steps/stub_steps.groovy b/src/test/groovy/sdkman/steps/stub_steps.groovy index b56e80c98..c57edbb70 100644 --- a/src/test/groovy/sdkman/steps/stub_steps.groovy +++ b/src/test/groovy/sdkman/steps/stub_steps.groovy @@ -16,7 +16,7 @@ And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } -And(~'^an available selfupdate$') { -> +And(~'^an available selfupdate endpoint$') { -> primeEndpointWithString("/selfupdate/stable/${UnixUtils.inferPlatform()}", 'echo "Successfully upgraded SDKMAN."') primeEndpointWithString("/selfupdate/beta/${UnixUtils.inferPlatform()}", 'echo "Successfully upgraded SDKMAN."') } diff --git a/src/test/resources/features/self_update.feature b/src/test/resources/features/self_update.feature index b962fb6e9..1d0ef7bc2 100644 --- a/src/test/resources/features/self_update.feature +++ b/src/test/resources/features/self_update.feature @@ -1,17 +1,34 @@ -@manual Feature: Self Update Background: Given the internet is reachable + And the sdkman scripts version is "5.0.0" + And the sdkman native version is "0.0.1" And an initialised environment And the system is bootstrapped - And an available selfupdate + And an available selfupdate endpoint + + Scenario: Attempt Self Update with out dated scripts components + Given the sdkman script version "6.0.0" is available for download + And the sdkman native version "0.0.1" is available for download + When I enter "sdk selfupdate" + Then I see "Successfully upgraded SDKMAN." + + Scenario: Attempt Self Update with out dated native components + Given the sdkman script version "5.0.0" is available for download + And the sdkman native version "0.0.2" is available for download + When I enter "sdk selfupdate" + Then I see "Successfully upgraded SDKMAN." Scenario: Attempt Self Update on an up to date system + Given the sdkman script version "5.0.0" is available for download + And the sdkman native version "0.0.1" is available for download When I enter "sdk selfupdate" Then I see "No update available at this time." Scenario: Force Self Update on an up to date system + Given the sdkman script version "5.0.0" is available for download + And the sdkman native version "0.0.1" is available for download When I enter "sdk selfupdate force" Then I see "Successfully upgraded SDKMAN." \ No newline at end of file diff --git a/src/test/resources/features/version.feature b/src/test/resources/features/version.feature index 00e6617fb..1b2529ba9 100644 --- a/src/test/resources/features/version.feature +++ b/src/test/resources/features/version.feature @@ -2,7 +2,7 @@ Feature: Version Scenario: Show the current version of sdkman Given the internet is reachable - And the sdkman version is "3.2.1" + And the sdkman scripts version is "3.2.1" And an initialised environment And the system is bootstrapped When I enter "sdk version" From 6bd587d4aca69067d42014f7a2c2aa1468bce1c7 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 18 Mar 2023 21:21:27 +0000 Subject: [PATCH 48/84] Clean up. --- src/main/bash/sdkman-selfupdate.sh | 10 +++++----- .../groovy/sdkman/env/SdkmanBashEnvBuilder.groovy | 2 +- src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy | 1 - .../groovy/sdkman/specs/CurrentCommandSpec.groovy | 1 - src/test/groovy/sdkman/specs/EnvCommandSpec.groovy | 11 ----------- .../groovy/sdkman/specs/InitialisationSpec.groovy | 1 - .../groovy/sdkman/specs/SdkCompatibilitySpec.groovy | 1 - 7 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index dfc52de8c..5524d9331 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -24,7 +24,7 @@ function __sdk_selfupdate() { if [[ "$SDKMAN_AVAILABLE" == "false" ]]; then echo "This command is not available while offline." return 1 - fi + fi if [[ "$sdkman_beta_channel" == "true" ]]; then sdkman_script_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/beta" @@ -32,17 +32,17 @@ function __sdk_selfupdate() { else sdkman_script_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/stable" sdkman_native_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/native/stable" - fi + fi sdkman_remote_script_version=$(__sdkman_secure_curl "$sdkman_script_version_api") sdkman_remote_native_version=$(__sdkman_secure_curl "$sdkman_native_version_api") - + sdkman_local_script_version=$(cat "$SDKMAN_DIR/var/version") sdkman_local_native_version=$(cat "$SDKMAN_DIR/var/version_native") - + __sdkman_echo_debug "Script: local version: $sdkman_local_script_version; remote version: $sdkman_remote_script_version" __sdkman_echo_debug "Native: local version: $sdkman_local_native_version; remote version: $sdkman_remote_native_version" - + force_selfupdate="$1" export sdkman_debug_mode if [[ "$sdkman_local_script_version" == "$sdkman_remote_script_version" && "$sdkman_local_native_version" == "$sdkman_remote_native_version" && "$force_selfupdate" != "force" ]]; then diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index fbbfbe360..55f7c3e1f 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -157,7 +157,7 @@ class SdkmanBashEnvBuilder { new File(folder, "version_native") << version } } - + private initializeCandidates(File folder, List candidates) { candidates.each { candidate -> new File(folder, candidate).mkdirs() diff --git a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy index 43b9b3122..6c1d5a511 100644 --- a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy @@ -6,7 +6,6 @@ class ConfigCommandSpec extends SdkmanEnvSpecification { def "it should open the config in the system's default editor"() { given: bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .build() diff --git a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy index f59ec9fdb..9b88fa0c5 100644 --- a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy @@ -41,7 +41,6 @@ class CurrentCommandSpec extends SdkmanEnvSpecification { bash = sdkmanBashEnvBuilder .withOfflineMode(false) - .withScriptVersion("5.0.0") .withCandidates(installedCandidates.keySet().toList()) .build() diff --git a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy index 13c7c6d29..3d9026f6e 100644 --- a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy @@ -19,7 +19,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { bash = sdkmanBashEnvBuilder .withOfflineMode(true) - .withScriptVersion("x.y.z") .build() bash.start() @@ -61,7 +60,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .build() @@ -98,7 +96,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", sdkmanAutoEnv) .build() @@ -133,7 +130,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -164,7 +160,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -191,7 +186,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -225,7 +219,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { createSymbolicLink(Paths.get("$candidatesDirectory/groovy/current"), Paths.get("$candidatesDirectory/groovy/2.4.6")) bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -264,7 +257,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { createSymbolicLink(Paths.get("$candidatesDirectory/ant/current"), Paths.get("$candidatesDirectory/ant/1.10.8")) bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -312,7 +304,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -338,7 +329,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { def "should issue an error if .sdkmanrc contains a malformed candidate version"() { given: bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .build() @@ -389,7 +379,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withScriptVersion("x.y.z") .withOfflineMode(true) .build() diff --git a/src/test/groovy/sdkman/specs/InitialisationSpec.groovy b/src/test/groovy/sdkman/specs/InitialisationSpec.groovy index a52649c09..407f67a13 100644 --- a/src/test/groovy/sdkman/specs/InitialisationSpec.groovy +++ b/src/test/groovy/sdkman/specs/InitialisationSpec.groovy @@ -15,7 +15,6 @@ class InitialisationSpec extends SdkmanEnvSpecification { def setup() { bash = sdkmanBashEnvBuilder .withCandidates(allCandidates) - .withScriptVersion("x.y.z") .build() prepareCandidateDirectories(allCandidates) } diff --git a/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy b/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy index aeb5549d0..00de66d1c 100644 --- a/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy +++ b/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy @@ -12,7 +12,6 @@ class SdkCompatibilitySpec extends SdkmanEnvSpecification { def setup() { bash = sdkmanBashEnvBuilder .withCandidates(allCandidates) - .withScriptVersion("x.y.z") .build() } From 5e33c3666e1af63ad3af402c8bbe8cf384c46943 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 19 Mar 2023 21:15:11 +0000 Subject: [PATCH 49/84] Address PR comments. --- src/main/bash/sdkman-selfupdate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 5524d9331..4cff93020 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -37,8 +37,8 @@ function __sdk_selfupdate() { sdkman_remote_script_version=$(__sdkman_secure_curl "$sdkman_script_version_api") sdkman_remote_native_version=$(__sdkman_secure_curl "$sdkman_native_version_api") - sdkman_local_script_version=$(cat "$SDKMAN_DIR/var/version") - sdkman_local_native_version=$(cat "$SDKMAN_DIR/var/version_native") + sdkman_local_script_version=$(< "$SDKMAN_DIR/var/version") + sdkman_local_native_version=$(< "$SDKMAN_DIR/var/version_native") __sdkman_echo_debug "Script: local version: $sdkman_local_script_version; remote version: $sdkman_remote_script_version" __sdkman_echo_debug "Native: local version: $sdkman_local_native_version; remote version: $sdkman_remote_native_version" From 71c9490883f1621f1c303d0a331d9d17f7b99e5f Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 20 Mar 2023 08:18:02 +0000 Subject: [PATCH 50/84] Fix broken build. --- src/test/groovy/sdkman/specs/EnvCommandSpec.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy index 3d9026f6e..a71dd656a 100644 --- a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy @@ -350,7 +350,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { def "should issue an error when .sdkmanrc contains a candidate version which is not installed"() { given: bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .build() From b5241834a41a496e60a515da29604c80033bdae5 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Fri, 31 Mar 2023 17:23:12 +0100 Subject: [PATCH 51/84] Do not check and warn of stale candidates cache. --- src/main/bash/sdkman-cache.sh | 10 ++-------- .../sdkman/specs/CandidatesCacheUpdateSpec.groovy | 10 +++++----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/bash/sdkman-cache.sh b/src/main/bash/sdkman-cache.sh index b64e1df72..fa28ffa20 100644 --- a/src/main/bash/sdkman-cache.sh +++ b/src/main/bash/sdkman-cache.sh @@ -18,20 +18,14 @@ function ___sdkman_check_candidates_cache() { local candidates_cache="$1" - if [[ -f "$candidates_cache" && -n "$(< "$candidates_cache")" && -n "$(find "$candidates_cache" -mmin +$((24 * 60 * 30)))" ]]; then - __sdkman_echo_yellow 'We periodically need to update the local cache. Please run:' - echo '' - __sdkman_echo_no_colour ' $ sdk update' - echo '' - return 0 - elif [[ -f "$candidates_cache" && -z "$(< "$candidates_cache")" ]]; then + if [[ -f "$candidates_cache" && -z "$(< "$candidates_cache")" ]]; then __sdkman_echo_red 'WARNING: Cache is corrupt. SDKMAN cannot be used until updated.' echo '' __sdkman_echo_no_colour ' $ sdk update' echo '' return 1 else - __sdkman_echo_debug "No update at this time. Using existing cache: $SDKMAN_CANDIDATES_CSV" + __sdkman_echo_debug "Using existing cache: $SDKMAN_CANDIDATES_CSV" return 0 fi } diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index 3d5842fed..fd6d1aa84 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -39,7 +39,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { !bash.output.contains("SDKMAN 5.0.0") } - void "should issue a warning if cache is older than a month"() { + void "should NOT issue a warning if cache is older than a month"() { given: bash = sdkmanBashEnvBuilder .withCandidates(['groovy']) @@ -56,11 +56,11 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { bash.execute("sdk help") then: - bash.output.contains('We periodically need to update the local cache.') - bash.output.contains('$ sdk update') + !bash.output.contains('We periodically need to update the local cache.') + !bash.output.contains('$ sdk update') } - void "should log a success message in debug mode when no update needed"() { + void "should log a success message if cache exists"() { given: bash = sdkmanBashEnvBuilder .withCandidates(['groovy']) @@ -74,7 +74,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { bash.execute("sdk help") then: - bash.output.contains('No update at this time. Using existing cache') + bash.output.contains('Using existing cache') } void "should bypass cache check if update command issued"() { From babd5fb4c63cb0b4975bfb7ff6e85c2ee138f6f5 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Fri, 31 Mar 2023 17:37:31 +0100 Subject: [PATCH 52/84] Remove obsolete candidates cache spec. --- .../specs/CandidatesCacheUpdateSpec.groovy | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index fd6d1aa84..0e52b1487 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -39,27 +39,6 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { !bash.output.contains("SDKMAN 5.0.0") } - void "should NOT issue a warning if cache is older than a month"() { - given: - bash = sdkmanBashEnvBuilder - .withCandidates(['groovy']) - .build() - - and: - candidatesCache.setLastModified(((new Date() - 31) as Date).time) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk help") - - then: - !bash.output.contains('We periodically need to update the local cache.') - !bash.output.contains('$ sdk update') - } - void "should log a success message if cache exists"() { given: bash = sdkmanBashEnvBuilder From 84222a39c5879734553131659e380549363afbbb Mon Sep 17 00:00:00 2001 From: helpermethod Date: Fri, 24 Feb 2023 14:01:44 +0100 Subject: [PATCH 53/84] chore: Upgrade to Gradle 8.0.1, setup caching for GH workflows --- .github/workflows/beta.yml | 1 + .github/workflows/pr.yml | 1 + .github/workflows/release.yml | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 5fea740e2..cf604a8a9 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -22,6 +22,7 @@ jobs: with: distribution: 'temurin' java-version: '11' + cache: 'gradle' - name: Run tests run: ./gradlew clean test --info - name: Set short git hash diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 889234483..691d799a7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,6 +12,7 @@ jobs: with: distribution: 'temurin' java-version: '11' + cache: 'gradle' - name: Run with Gradle run: ./gradlew clean test --info - uses: kentaro-m/auto-assign-action@v1.2.4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00011f695..b706dc22f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,7 @@ jobs: with: distribution: 'temurin' java-version: '11' + cache: 'gradle' - name: Run tests run: ./gradlew clean test --info - name: Build artifacts diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2a563242c..f72df95a7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 7e46af3be78ae26ebfa4394ead1281f0f59d03aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 15:19:40 +0000 Subject: [PATCH 54/84] Bump kentaro-m/auto-assign-action from 1.2.4 to 1.2.5 Bumps [kentaro-m/auto-assign-action](https://github.com/kentaro-m/auto-assign-action) from 1.2.4 to 1.2.5. - [Release notes](https://github.com/kentaro-m/auto-assign-action/releases) - [Commits](https://github.com/kentaro-m/auto-assign-action/compare/v1.2.4...v1.2.5) --- updated-dependencies: - dependency-name: kentaro-m/auto-assign-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 691d799a7..219923cdd 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,6 +15,6 @@ jobs: cache: 'gradle' - name: Run with Gradle run: ./gradlew clean test --info - - uses: kentaro-m/auto-assign-action@v1.2.4 + - uses: kentaro-m/auto-assign-action@v1.2.5 with: configuration-path: ".github/auto_assign.yml" From c880cd150f083e079e4e5a799e3a24ab15c7663a Mon Sep 17 00:00:00 2001 From: helpermethod Date: Mon, 9 Jan 2023 11:33:05 +0100 Subject: [PATCH 55/84] chore: Support Mastodon announcer --- .github/workflows/release.yml | 1 + build.gradle | 2 +- gradle/release.gradle | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b706dc22f..1bba1b0db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,7 @@ jobs: JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} + JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN}} JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} services: mongodb: diff --git a/build.gradle b/build.gradle index 6e1054c59..ab6588dec 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id('groovy') - id('org.jreleaser').version('1.0.0').apply(false) + id('org.jreleaser').version('1.4.0').apply(false) } String userHome = System.getProperty('user.home') diff --git a/gradle/release.gradle b/gradle/release.gradle index deb622560..c13e69413 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -47,5 +47,10 @@ jreleaser { active = 'RELEASE' status = 'Released version {{tagName}} of SDKMAN! {{releaseNotesUrl}}' } + mastodon { + active = 'RELEASE' + status = 'Released version {{tagName}} of SDKMAN! {{releaseNotesUrl}}' + host = 'https://fosstodon.org' + } } } \ No newline at end of file From 82e06b4209ecc1ebb34c85fe3a0b3c32f6f1c336 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Thu, 6 Apr 2023 17:33:17 +0100 Subject: [PATCH 56/84] Do not validate candidate for native commands. Native commands do their own internal checks using common library code. --- src/main/bash/sdkman-main.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index 1b91f894f..c46ba11f9 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -117,13 +117,6 @@ function sdk() { ___sdkman_help fi - # Check whether the candidate exists - if [[ -n "$QUALIFIER" && "$COMMAND" != "help" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && "$COMMAND" != "env" && "$COMMAND" != "completion" && "$COMMAND" != "edit" && "$COMMAND" != "home" && -z $(echo ${SDKMAN_CANDIDATES[@]} | grep -w "$QUALIFIER") ]]; then - echo "" - __sdkman_echo_red "Stop! $QUALIFIER is not a valid candidate." - return 1 - fi - # Validate offline qualifier if [[ "$COMMAND" == "offline" && -n "$QUALIFIER" && -z $(echo "enable disable" | grep -w "$QUALIFIER") ]]; then echo "" @@ -140,6 +133,14 @@ function sdk() { "$native_command" "${@:2}" elif [ -n "$CMD_FOUND" ]; then + + # Check whether the candidate exists + if [[ -n "$QUALIFIER" && "$COMMAND" != "help" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && "$COMMAND" != "env" && "$COMMAND" != "completion" && "$COMMAND" != "edit" && "$COMMAND" != "home" && -z $(echo ${SDKMAN_CANDIDATES[@]} | grep -w "$QUALIFIER") ]]; then + echo "" + __sdkman_echo_red "Stop! $QUALIFIER is not a valid candidate." + return 1 + fi + # Internal commands use underscores rather than hyphens local converted_command_name=$(echo "$COMMAND" | tr '-' '_') From 41a2743e1c23910e239ab8b9ff3ecd93fa94a856 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 1 Apr 2023 16:09:27 +0100 Subject: [PATCH 57/84] Remove obsolete pre-installation hooks. --- src/main/bash/sdkman-install.sh | 9 ----- .../groovy/sdkman/steps/stub_steps.groovy | 21 ++++------- .../groovy/sdkman/stubs/HookResponses.groovy | 22 +---------- .../groovy/sdkman/stubs/WebServiceStub.groovy | 14 +++---- .../hooks/pre_hook_java_8.0.101_linuxx64.sh | 6 --- .../hooks/pre_hook_java_8.0.111_linuxx64.sh | 6 --- src/test/resources/features/hooks.feature | 25 +++++++++++++ .../features/java_installation.feature | 10 ++--- .../pre_and_post_installation_hooks.feature | 37 ------------------- 9 files changed, 46 insertions(+), 104 deletions(-) delete mode 100644 src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh delete mode 100644 src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh create mode 100644 src/test/resources/features/hooks.feature delete mode 100644 src/test/resources/features/pre_and_post_installation_hooks.feature diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 1f8582871..1c4c0e244 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -128,15 +128,6 @@ function __sdkman_download() { local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" local headers_file="${metadata_folder}/${base_name}.headers" - # pre-installation hook: implements function __sdkman_pre_installation_hook - local pre_installation_hook="${SDKMAN_DIR}/tmp/hook_pre_${candidate}_${version}.sh" - __sdkman_echo_debug "Get pre-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" >| "$pre_installation_hook" - __sdkman_echo_debug "Copy remote pre-installation hook: $pre_installation_hook" - source "$pre_installation_hook" - __sdkman_pre_installation_hook || return 1 - __sdkman_echo_debug "Completed pre-installation hook..." - export local binary_input="${SDKMAN_DIR}/tmp/${base_name}.bin" export local zip_output="${SDKMAN_DIR}/tmp/${base_name}.zip" diff --git a/src/test/groovy/sdkman/steps/stub_steps.groovy b/src/test/groovy/sdkman/steps/stub_steps.groovy index c57edbb70..f2594366c 100644 --- a/src/test/groovy/sdkman/steps/stub_steps.groovy +++ b/src/test/groovy/sdkman/steps/stub_steps.groovy @@ -12,7 +12,6 @@ import static sdkman.support.FilesystemUtils.readVersionsCsvFromCandidateFolder And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String version -> primeEndpointWithString("/candidates/default/${candidate}", version) primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform()) - primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess()) primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } @@ -24,7 +23,6 @@ And(~'^an available selfupdate endpoint$') { -> And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version -> primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.inferPlatform()}", "valid") primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform()) - primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess()) primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } @@ -32,20 +30,17 @@ And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download with String candidate, String version, String checksum, String algorithm -> primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.inferPlatform()}", "valid") primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform(), ["X-Sdkman-Checksum-${algorithm}": "${checksum}"]) - primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess()) primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } -And(~/^the appropriate universal hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String os -> +And(~/^the appropriate universal hook is available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String os -> String lcPlatform = UnixUtils.inferPlatform(os) - primeUniversalHookFor("pre", candidate, version, lcPlatform) - primeUniversalHookFor("post", candidate, version, lcPlatform) + primeUniversalHookFor(candidate, version, lcPlatform) } -And(~/^the appropriate multi-platform hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String os, String architecture -> +And(~/^the appropriate multi-platform hook is available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String os, String architecture -> String lcPlatform = UnixUtils.inferPlatform(os, architecture) - primePlatformSpecificHookFor("pre", candidate, version, lcPlatform) - primePlatformSpecificHookFor("post", candidate, version, lcPlatform) + primePlatformSpecificHookFor(candidate, version, lcPlatform) } And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version -> @@ -58,14 +53,14 @@ And(~/^the candidate "(.*)" version "(.*)" is available for download on "(.*)" w primeDownloadFor(SERVICE_UP_URL, candidate, version, lcPlatform) } -And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String phase, String candidate, String version, String os, String architecture -> +And(~/^a post-installation hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String candidate, String version, String os, String architecture -> String lcPlatform = UnixUtils.inferPlatform(os, architecture) - primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookSuccess() : postInstallationHookSuccess()) + primeEndpointWithString("/hooks/post/${candidate}/${version}/${lcPlatform}", postInstallationHookSuccess()) } -And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String phase, String candidate, String version, String os, String architecture -> +And(~/^a post-installation hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String candidate, String version, String os, String architecture -> String lcPlatform = UnixUtils.inferPlatform(os, architecture) - primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookFailure() : postInstallationHookFailure()) + primeEndpointWithString("/hooks/post/${candidate}/${version}/${lcPlatform}", postInstallationHookFailure()) } And(~/^the candidate "(.*?)" version "(.*?)" is not available for download on "(.*?)"$/) { String candidate, String version, String os -> diff --git a/src/test/groovy/sdkman/stubs/HookResponses.groovy b/src/test/groovy/sdkman/stubs/HookResponses.groovy index 922cc21fb..8757a564b 100644 --- a/src/test/groovy/sdkman/stubs/HookResponses.groovy +++ b/src/test/groovy/sdkman/stubs/HookResponses.groovy @@ -1,27 +1,7 @@ package sdkman.stubs class HookResponses { - - static preInstallationHookSuccess() { - '''\ -#!/usr/bin/env bash -function __sdkman_pre_installation_hook { - echo "Pre-installation hook success" - return 0 -} -''' - } - - static preInstallationHookFailure() { - '''\ -#!/usr/bin/env bash -function __sdkman_pre_installation_hook { - echo "Pre-installation hook failure" - return 1 -} -''' - } - + static postInstallationHookSuccess() { '''\ #!/usr/bin/env bash diff --git a/src/test/groovy/sdkman/stubs/WebServiceStub.groovy b/src/test/groovy/sdkman/stubs/WebServiceStub.groovy index 62587aa2f..9a7656009 100644 --- a/src/test/groovy/sdkman/stubs/WebServiceStub.groovy +++ b/src/test/groovy/sdkman/stubs/WebServiceStub.groovy @@ -12,17 +12,17 @@ class WebServiceStub { .withBody(body))) } - static primeUniversalHookFor(String phase, String candidate, String version, String platform) { - primeHookFor(phase, candidate, version, platform, true) + static primeUniversalHookFor(String candidate, String version, String platform) { + primeHookFor(candidate, version, platform, true) } - static primePlatformSpecificHookFor(String phase, String candidate, String version, String platform) { - primeHookFor(phase, candidate, version, platform, false) + static primePlatformSpecificHookFor(String candidate, String version, String platform) { + primeHookFor(candidate, version, platform, false) } - private static primeHookFor(String phase, String candidate, String version, String platform, boolean universal = true) { - def hookFile = "hooks/${phase}_hook_${candidate}_${version}_${universal ? 'universal' : platform}.sh" - stubFor(get(urlEqualTo("/hooks/$phase/$candidate/$version/$platform")).willReturn( + private static primeHookFor(String candidate, String version, String platform, boolean universal = true) { + def hookFile = "hooks/post_hook_${candidate}_${version}_${universal ? 'universal' : platform}.sh" + stubFor(get(urlEqualTo("/hooks/post/$candidate/$version/$platform")).willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "text/plain") diff --git a/src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh b/src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh deleted file mode 100644 index 87139bd86..000000000 --- a/src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# passthrough with zero return code -function __sdkman_pre_installation_hook() { - echo "PRE: passthrough returning zero return code" - return 0 -} diff --git a/src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh b/src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh deleted file mode 100644 index ee8cb7f64..000000000 --- a/src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# passthrough returns zero return code -function __sdkman_pre_installation_hook() { - echo "PRE: returns with zero return code" - return 0 -} diff --git a/src/test/resources/features/hooks.feature b/src/test/resources/features/hooks.feature new file mode 100644 index 000000000..fd47f9bd4 --- /dev/null +++ b/src/test/resources/features/hooks.feature @@ -0,0 +1,25 @@ +Feature: Hooks + + We can safely remove this feature when `.tar.gz` and `.zip` are supported directly by the backend. + + Background: + Given the internet is reachable + And an initialised environment + + Scenario: Post-installation Hook returns successfully + And an "x86_64" machine with "Linux" installed + And the system is bootstrapped + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a post-installation hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully + When I enter "sdk install grails 2.1.0" + And I see "Post-installation hook success" + And the exit code is 0 + + Scenario: Post-install Hook returns a non-zero code + And an "x86_64" machine with "Linux" installed + And the system is bootstrapped + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a post-installation hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure + When I enter "sdk install grails 2.1.0" + Then I see "Post-installation hook failure" + And the exit code is 1 diff --git a/src/test/resources/features/java_installation.feature b/src/test/resources/features/java_installation.feature index 42a0dac61..dd7bdc4fe 100644 --- a/src/test/resources/features/java_installation.feature +++ b/src/test/resources/features/java_installation.feature @@ -4,8 +4,8 @@ Feature: Java Multi Platform Binary Distribution This feature uses real hooks found in the resources folder under /hooks. The following hooks are available: - 8.0.111: pre- and post-hooks prepared for successful installation - 8.0.101: pre-hook succeeds but post-hook aborts with non-zero return code + 8.0.111: post-hook prepared for successful installation + 8.0.101: post-hook aborts with non-zero return code Background: Given the internet is reachable @@ -15,7 +15,7 @@ Feature: Java Multi Platform Binary Distribution Given an "x86_64" machine with "Linux" installed And the system is bootstrapped And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64" - And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "x86_64" + And the appropriate multi-platform hook is available for "java" version "8.0.111" on "Linux" with architecture "x86_64" When I enter "sdk install java 8.0.111" And I see "Done installing!" And the candidate "java" version "8.0.111" is installed @@ -25,7 +25,7 @@ Feature: Java Multi Platform Binary Distribution And the system is bootstrapped And the default "java" version is "8.0.111" And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64" - And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "x86_64" + And the appropriate multi-platform hook is available for "java" version "8.0.111" on "Linux" with architecture "x86_64" When I enter "sdk install java" And I see "Done installing!" And the candidate "java" version "8.0.111" is installed @@ -34,7 +34,7 @@ Feature: Java Multi Platform Binary Distribution Given an "x86_64" machine with "Linux" installed And the system is bootstrapped And the candidate "java" version "8.0.101" is available for download on "Linux" with architecture "x86_64" - And the appropriate multi-platform hooks are available for "java" version "8.0.101" on "Linux" with architecture "x86_64" + And the appropriate multi-platform hook is available for "java" version "8.0.101" on "Linux" with architecture "x86_64" When I enter "sdk install java 8.0.101" And I see "Download has failed, aborting!" And the candidate "java" version "8.0.101" is not installed diff --git a/src/test/resources/features/pre_and_post_installation_hooks.feature b/src/test/resources/features/pre_and_post_installation_hooks.feature deleted file mode 100644 index 949036686..000000000 --- a/src/test/resources/features/pre_and_post_installation_hooks.feature +++ /dev/null @@ -1,37 +0,0 @@ -Feature: Hooks - - We can safely remove this feature when `.tar.gz` and `.zip` are supported directly by the backend. - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Pre- and Post-installation Hooks return successfully - And an "x86_64" machine with "Linux" installed - And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully - And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully - When I enter "sdk install grails 2.1.0" - Then I see "Pre-installation hook success" - And I see "Post-installation hook success" - And the exit code is 0 - - Scenario: Pre-installation Hook returns a non-zero code - And an "x86_64" machine with "Linux" installed - And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure - When I enter "sdk install grails 2.1.0" - Then I see "Pre-installation hook failure" - And the exit code is 1 - - Scenario: Post-install Hook returns a non-zero code - And an "x86_64" machine with "Linux" installed - And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully - And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure - When I enter "sdk install grails 2.1.0" - Then I see "Post-installation hook failure" - And the exit code is 1 From c05c7e4822a9c7f4d912ef306cddc3ca8fa6c34a Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 13 May 2023 20:02:11 +0100 Subject: [PATCH 58/84] Only infer MSYS and MINGW on Windows. --- src/main/bash/sdkman-init.sh | 5 ++++- src/test/groovy/sdkman/specs/PlatformSpec.groovy | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index b56aced0e..7ccbcd29f 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -81,8 +81,11 @@ function infer_platform() { ;; esac ;; - *) + MSYS*|MINGW*) echo "$kernel" + ;; + *) + echo "Exotic" esac } diff --git a/src/test/groovy/sdkman/specs/PlatformSpec.groovy b/src/test/groovy/sdkman/specs/PlatformSpec.groovy index 448b3449c..31b98fa04 100644 --- a/src/test/groovy/sdkman/specs/PlatformSpec.groovy +++ b/src/test/groovy/sdkman/specs/PlatformSpec.groovy @@ -39,6 +39,7 @@ class PlatformSpec extends SdkmanEnvSpecification { "Darwin" | "" | "darwinx64" "MSYS64" | "i686" | "msys64" "MSYS64" | "" | "msys64" + "CYGWIN" | "" | "exotic" } def "should enable rosetta 2 compatibility mode with environment variable"() { From 33a4adfe67ec306d5afd517c6909b29b4daeeab0 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 14 May 2023 20:35:02 +0100 Subject: [PATCH 59/84] Read platform from descriptor file. --- src/main/bash/sdkman-env-helpers.sh | 2 +- src/main/bash/sdkman-init.sh | 62 +---------------------------- src/main/bash/sdkman-install.sh | 2 +- 3 files changed, 4 insertions(+), 62 deletions(-) diff --git a/src/main/bash/sdkman-env-helpers.sh b/src/main/bash/sdkman-env-helpers.sh index 8dafd17ea..2b155a0ae 100644 --- a/src/main/bash/sdkman-env-helpers.sh +++ b/src/main/bash/sdkman-env-helpers.sh @@ -64,7 +64,7 @@ function __sdkman_determine_version() { version=$(__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/candidates/default/${candidate}") fi - local validation_url="${SDKMAN_CANDIDATES_API}/candidates/validate/${candidate}/${version}/$(echo $SDKMAN_PLATFORM | tr '[:upper:]' '[:lower:]')" + local validation_url="${SDKMAN_CANDIDATES_API}/candidates/validate/${candidate}/${version}/${SDKMAN_PLATFORM}" VERSION_VALID=$(__sdkman_secure_curl "$validation_url") __sdkman_echo_debug "Validate $candidate $version for $SDKMAN_PLATFORM: $VERSION_VALID" __sdkman_echo_debug "Validation URL: $validation_url" diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index 7ccbcd29f..5d7c72e66 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -30,66 +30,8 @@ if [ -f "${SDKMAN_DIR}/etc/config" ]; then source "${SDKMAN_DIR}/etc/config" fi -# infer platform -function infer_platform() { - local kernel - local machine - - kernel="$(uname -s)" - machine="$(uname -m)" - - case $kernel in - Linux) - case $machine in - i686) - echo "LinuxX32" - ;; - x86_64) - echo "LinuxX64" - ;; - armv6l) - echo "LinuxARM32HF" - ;; - armv7l) - echo "LinuxARM32HF" - ;; - armv8l) - echo "LinuxARM32HF" - ;; - aarch64) - echo "LinuxARM64" - ;; - *) - echo "Exotic" - ;; - esac - ;; - Darwin) - case $machine in - x86_64) - echo "DarwinX64" - ;; - arm64) - if [[ "$sdkman_rosetta2_compatible" == 'true' ]]; then - echo "DarwinX64" - else - echo "DarwinARM64" - fi - ;; - *) - echo "DarwinX64" - ;; - esac - ;; - MSYS*|MINGW*) - echo "$kernel" - ;; - *) - echo "Exotic" - esac -} - -SDKMAN_PLATFORM="$(infer_platform | tr '[:upper:]' '[:lower:]')" +# Read the platform file +SDKMAN_PLATFORM="$(cat "${SDKMAN_DIR}/etc/platform")" export SDKMAN_PLATFORM # OS specific support (must be 'true' or 'false'). diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 1c4c0e244..78e6ce727 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -122,7 +122,7 @@ function __sdkman_download() { metadata_folder="${SDKMAN_DIR}/var/metadata" mkdir -p ${metadata_folder} - local platform_parameter="$(echo $SDKMAN_PLATFORM | tr '[:upper:]' '[:lower:]')" + local platform_parameter="$SDKMAN_PLATFORM" local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" local base_name="${candidate}-${version}" local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" From a5f07d61a4429d07db92ade5a6073e2cf2d90c06 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 14 May 2023 21:33:04 +0100 Subject: [PATCH 60/84] Fix broken platform tests and remove obsolete PlatformSpec. --- .../sdkman/env/SdkmanBashEnvBuilder.groovy | 13 ++++ .../groovy/sdkman/specs/CompletionSpec.groovy | 1 + .../groovy/sdkman/specs/PlatformSpec.groovy | 62 ------------------- src/test/groovy/sdkman/stubs/UnameStub.groovy | 4 +- .../groovy/sdkman/support/UnixUtils.groovy | 10 +-- src/test/resources/features/mnemonics.feature | 3 +- 6 files changed, 23 insertions(+), 70 deletions(-) delete mode 100644 src/test/groovy/sdkman/specs/PlatformSpec.groovy diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index 55f7c3e1f..151c9b379 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -3,6 +3,7 @@ package sdkman.env import groovy.transform.ToString import sdkman.stubs.CurlStub import sdkman.stubs.UnameStub +import sdkman.support.UnixUtils @ToString(includeNames = true) class SdkmanBashEnvBuilder { @@ -19,6 +20,7 @@ class SdkmanBashEnvBuilder { private Optional curlStub = Optional.empty() private Optional unameStub = Optional.empty() private List candidates = ['groovy', 'grails', 'java'] + private String platform = UnixUtils.inferPlatform() private boolean offlineMode = false private String candidatesApi = "http://localhost:8080/2" private String jdkHome = "/path/to/my/jdk" @@ -53,6 +55,11 @@ class SdkmanBashEnvBuilder { this.unameStub = Optional.of(unameStub) this } + + SdkmanBashEnvBuilder withPlatform(String platform) { + this.platform = platform + this + } SdkmanBashEnvBuilder withCandidates(List candidates) { this.candidates = candidates @@ -116,6 +123,7 @@ class SdkmanBashEnvBuilder { initializeCandidates(sdkmanCandidatesDir, candidates) initializeCandidatesCache(sdkmanVarDir, candidates) + initializePlatformDescriptor(sdkmanEtcDir, platform) initializeConfiguration(sdkmanEtcDir, config) initializeScriptVersionFile(sdkmanVarDir, scriptVersion) initializeNativeVersionFile(sdkmanVarDir, nativeVersion) @@ -172,6 +180,11 @@ class SdkmanBashEnvBuilder { candidatesCache << "" } } + + private initializePlatformDescriptor(File folder, String platform) { + def platformDescriptor = new File(folder, "platform") + platformDescriptor << platform + } private initializeConfiguration(File targetFolder, Map config) { def configFile = new File(targetFolder, "config") diff --git a/src/test/groovy/sdkman/specs/CompletionSpec.groovy b/src/test/groovy/sdkman/specs/CompletionSpec.groovy index ffd811af5..6e5017a4d 100644 --- a/src/test/groovy/sdkman/specs/CompletionSpec.groovy +++ b/src/test/groovy/sdkman/specs/CompletionSpec.groovy @@ -49,6 +49,7 @@ class CompletionSpec extends SdkmanEnvSpecification { bash = sdkmanBashEnvBuilder .withConfiguration("sdkman_auto_complete", "true") .withUnameStub(unameStub) + .withPlatform("darwinx64") .build() bash.start() diff --git a/src/test/groovy/sdkman/specs/PlatformSpec.groovy b/src/test/groovy/sdkman/specs/PlatformSpec.groovy deleted file mode 100644 index 31b98fa04..000000000 --- a/src/test/groovy/sdkman/specs/PlatformSpec.groovy +++ /dev/null @@ -1,62 +0,0 @@ -package sdkman.specs - -import sdkman.support.SdkmanEnvSpecification - -class PlatformSpec extends SdkmanEnvSpecification { - def setup() { - sdkmanBashEnvBuilder.withCandidates(["groovy"]) - } - - def "should set platform based on uname"() { - given: - unameStub.forKernel(kernel).forMachine(machine) - bash = sdkmanBashEnvBuilder.withUnameStub(unameStub).build() - bash.start() - bash.execute("source $bootstrapScript") - bash.execute('echo $SDKMAN_PLATFORM') - - expect: - bash.output.contains(platform) - - where: - kernel | machine | platform - "Linux" | "i686" | "linuxx32" - "Linux" | "x86_64" | "linuxx64" - "Linux" | "armv6l" | "linuxarm32hf" - "Linux" | "armv7l" | "linuxarm32hf" - "Linux" | "armv8l" | "linuxarm32hf" - "Linux" | "aarch64" | "linuxarm64" - "Linux" | "alpha" | "exotic" - "Linux" | "i64" | "exotic" - "Linux" | "ppc" | "exotic" - "Linux" | "ppc64le" | "exotic" - "Linux" | "ppc64el" | "exotic" - "Linux" | "s390" | "exotic" - "Linux" | "s390x" | "exotic" - "Linux" | "" | "exotic" - "Darwin" | "x86_64" | "darwinx64" - "Darwin" | "arm64" | "darwinarm64" - "Darwin" | "" | "darwinx64" - "MSYS64" | "i686" | "msys64" - "MSYS64" | "" | "msys64" - "CYGWIN" | "" | "exotic" - } - - def "should enable rosetta 2 compatibility mode with environment variable"() { - given: - unameStub.forKernel("Darwin").forMachine("arm64") - bash = sdkmanBashEnvBuilder - .withUnameStub(unameStub) - .withConfiguration("sdkman_rosetta2_compatible", "true") - .build() - bash.start() - bash.execute("source $bootstrapScript") - - when: - bash.execute('echo $SDKMAN_PLATFORM') - - then: - !bash.output.contains("darwinarm64") - bash.output.contains("darwinx64") - } -} diff --git a/src/test/groovy/sdkman/stubs/UnameStub.groovy b/src/test/groovy/sdkman/stubs/UnameStub.groovy index a13a8a46a..422625fbe 100644 --- a/src/test/groovy/sdkman/stubs/UnameStub.groovy +++ b/src/test/groovy/sdkman/stubs/UnameStub.groovy @@ -3,8 +3,8 @@ package sdkman.stubs class UnameStub { private File file - private kernel = "Linux" - private machine = "X86_64" + def kernel = "Linux" + def machine = "x86_64" static UnameStub prepareIn(File folder) { folder.mkdirs() diff --git a/src/test/groovy/sdkman/support/UnixUtils.groovy b/src/test/groovy/sdkman/support/UnixUtils.groovy index e4d434bd6..77547626a 100644 --- a/src/test/groovy/sdkman/support/UnixUtils.groovy +++ b/src/test/groovy/sdkman/support/UnixUtils.groovy @@ -4,11 +4,13 @@ class UnixUtils { private static platforms = [ "Linux" : [ - "x86_64": "LinuxX64" + "x86_64": "linuxx64", + "aarch64": "linuxarm64", + ], "Darwin": [ - "x86_64": "DarwinX64", - "arm64": "DarwinX64", + "x86_64": "darwinx64", + "arm64": "darwinarm64", ] ] @@ -23,6 +25,6 @@ class UnixUtils { static inferPlatform( String osName = osName(), String architecture = osArch()) { - (platforms[osName][architecture] ?: osName).toLowerCase() + platforms[osName][architecture] ?: osName.toLowerCase() } } diff --git a/src/test/resources/features/mnemonics.feature b/src/test/resources/features/mnemonics.feature index 06bfc603b..0f25ca4c4 100644 --- a/src/test/resources/features/mnemonics.feature +++ b/src/test/resources/features/mnemonics.feature @@ -81,8 +81,7 @@ Feature: Mnemonics And the candidate "groovy" version "2.0.5" should be the default Scenario: Shortcut for displaying Home directory - Given an initialised environment without debug prints - And the candidate "grails" version "2.1.0" is already installed and default + Given the candidate "grails" version "2.1.0" is already installed and default And the candidate "grails" version "2.1.0" is a valid candidate version And the system is bootstrapped When I enter "sdk h grails 2.1.0" From f284bc4097a64fa430f578ef4eb03e4e1b51a695 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 14 May 2023 21:49:51 +0100 Subject: [PATCH 61/84] Read platform file from var folder. --- src/main/bash/sdkman-init.sh | 2 +- src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index 5d7c72e66..7e8e34349 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -31,7 +31,7 @@ if [ -f "${SDKMAN_DIR}/etc/config" ]; then fi # Read the platform file -SDKMAN_PLATFORM="$(cat "${SDKMAN_DIR}/etc/platform")" +SDKMAN_PLATFORM="$(cat "${SDKMAN_DIR}/var/platform")" export SDKMAN_PLATFORM # OS specific support (must be 'true' or 'false'). diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index 151c9b379..05d600f15 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -121,10 +121,10 @@ class SdkmanBashEnvBuilder { curlStub.map { it.build() } unameStub.map { it.build() } + initializeConfiguration(sdkmanEtcDir, config) initializeCandidates(sdkmanCandidatesDir, candidates) initializeCandidatesCache(sdkmanVarDir, candidates) - initializePlatformDescriptor(sdkmanEtcDir, platform) - initializeConfiguration(sdkmanEtcDir, config) + initializePlatformDescriptor(sdkmanVarDir, platform) initializeScriptVersionFile(sdkmanVarDir, scriptVersion) initializeNativeVersionFile(sdkmanVarDir, nativeVersion) From 19e5c081297d6a8d1ce8a8b54631bb3f8e8e861b Mon Sep 17 00:00:00 2001 From: Krzysztof Buszowski Date: Sat, 3 Jun 2023 15:00:00 +0200 Subject: [PATCH 62/84] Add missing quotes when handling file paths within install command --- src/main/bash/sdkman-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 78e6ce727..8c95fee96 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -120,7 +120,7 @@ function __sdkman_download() { version="$2" metadata_folder="${SDKMAN_DIR}/var/metadata" - mkdir -p ${metadata_folder} + mkdir -p "${metadata_folder}" local platform_parameter="$SDKMAN_PLATFORM" local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" @@ -228,5 +228,5 @@ function __sdkman_checksum_zip() { __sdkman_echo_no_colour "Not able to perform checksum verification at this time." fi fi - done < ${headers_file} + done < "${headers_file}" } From 1d4b5eb984e49698adc1b2893800df829bd4f9c2 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 15 Oct 2023 20:51:38 +0100 Subject: [PATCH 63/84] Remove rosetta 2 compatible flag from brew formula --- src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl index 93072611c..534063f10 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl @@ -23,7 +23,6 @@ class {{brewFormulaName}} < Formula sdkman_curl_max_time=10 sdkman_debug_mode=false sdkman_insecure_ssl=false - sdkman_rosetta2_compatible=false sdkman_selfupdate_feature=false EOS end From 460079381e8e9cce23aa03793607bbf92ba89206 Mon Sep 17 00:00:00 2001 From: Alexei Bratuhin Date: Wed, 18 Oct 2023 15:06:41 +0200 Subject: [PATCH 64/84] Rename pull_request_tempalte.md to pull_request_template.md #1248 = fix typo --- .github/{pull_request_tempalte.md => pull_request_template.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{pull_request_tempalte.md => pull_request_template.md} (100%) diff --git a/.github/pull_request_tempalte.md b/.github/pull_request_template.md similarity index 100% rename from .github/pull_request_tempalte.md rename to .github/pull_request_template.md From 6529e0195ddcc6c397ef7649656ff452b4e598a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Nov 2023 08:53:44 +0100 Subject: [PATCH 65/84] Bump actions/setup-java from 3 to 4 (#1259) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/beta.yml | 2 +- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index cf604a8a9..f81b90c3c 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -18,7 +18,7 @@ jobs: - 27017:27017 steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 219923cdd..cb6c96662 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bba1b0db..eda0a4407 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' From 67de99c2b66d51677f5f80e1ed1b05ef24e5a989 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 17 Apr 2024 21:22:32 +0100 Subject: [PATCH 66/84] Update README --- README.md | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 3768ae94d..1837c2f4e 100644 --- a/README.md +++ b/README.md @@ -23,32 +23,9 @@ All SDKMAN's BDD tests describing the CLI behaviour are written in Cucumber and $ ./gradlew test -To perform development, you will need to have a JDK 8 or higher installed which can be obtained by running the following after installing SDKMAN: +To perform development, you will need to have a JDK 11 installed which can be obtained by running the following after installing SDKMAN: - $ sdk install java - -### Using Docker for tests - -You can run the tests in a Docker container to guarantee a clean test environment. - - $ docker build --tag=sdkman-cli/gradle . - $ docker run --rm -it sdkman-cli/gradle test - -By running the following command, you don't need to wait for downloading Gradle wrapper and other dependencies. The test reports can be found under the local `build` directory. - - $ docker run --rm -it -v $PWD:/usr/src/app -v $HOME/.gradle:/root/.gradle sdkman-cli/gradle test - -### Local Installation - -To install SDKMAN locally running against your local server, run the following commands: - - $ ./gradlew install - $ source ~/.sdkman/bin/sdkman-init.sh - -Or run install locally with Production configuration: - - $ ./gradlew -Penv=production install - $ source ~/.sdkman/bin/sdkman-init.sh + $ sdk env install ## Contributors @@ -76,4 +53,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l - + \ No newline at end of file From f33f264b14cd8e4fc02bdfa19694ef621ba8de84 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sun, 26 May 2024 11:19:08 +0100 Subject: [PATCH 67/84] Add notice to README --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1837c2f4e..641e68858 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,16 @@ [![Sponsors on Open Collective](https://opencollective.com/sdkman/sponsors/badge.svg)](#sponsors) [![Slack](https://slack.sdkman.io/badge.svg)](https://slack.sdkman.io) -SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix based system. It provides a convenient command line interface for installing, switching, removing and listing Candidates. +SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix-based system. It provides a convenient command-line interface for installing, switching, removing, and listing Candidates. See documentation on the [SDKMAN! website](https://sdkman.io). +## NOTICE + +**We are rewriting all the commands for SDKMAN! in [Rust](https://www.rust-lang.org/) under a [new project](https://github.com/sdkman/sdkman-cli-native) that supplements this one. Only bug fixes to supporting code will be +accepted in this project. As a result, no further enhancements will be accepted on the commands in this project, and the commands here will be phased out in due course. This project will eventually form a lightweight +wrapper/launcher for the replacement Rust commands.** + ## Installation Open your favourite terminal and enter the following: @@ -53,4 +59,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l - \ No newline at end of file + From 2bcdc63767adf3a0d95c0ba2e1639a39b10ef800 Mon Sep 17 00:00:00 2001 From: Oliver Weiler Date: Tue, 18 Jun 2024 17:17:06 +0200 Subject: [PATCH 68/84] chore: Remove Homebrew packager (#1298) --- .github/workflows/release.yml | 1 - gradle/release.gradle | 3 -- .../sdkman-cli/brew/README.md.tpl | 29 ---------------- .../sdkman-cli/brew/formula.rb.tpl | 33 ------------------- 4 files changed, 66 deletions(-) delete mode 100644 src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl delete mode 100644 src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eda0a4407..33b7ee1f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,6 @@ jobs: JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN}} - JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} services: mongodb: image: mongo:3.2 diff --git a/gradle/release.gradle b/gradle/release.gradle index c13e69413..8ba2202b9 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -36,9 +36,6 @@ jreleaser { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" extraProperties.put("universal", "true") } - brew { - active = 'ALWAYS' - } } } diff --git a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl b/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl deleted file mode 100644 index ed9be6aae..000000000 --- a/src/jreleaser/distributions/sdkman-cli/brew/README.md.tpl +++ /dev/null @@ -1,29 +0,0 @@ -# SDKMAN! Homebrew Tap - -A Homebrew tap containing the Formula for the SDKMAN! CLI. - -## Installation - -```sh -$ brew tap sdkman/tap -$ brew install sdkman-cli -``` - -After successful installation add the following lines to the end of your `.bash_profile` - -```sh -export SDKMAN_DIR=$(brew --prefix sdkman-cli)/libexec -[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh" -``` - -Open a new terminal and type - -```sh -sdk version -``` - -The output should look similar to this - -```sh -SDKMAN {{projectVersion}} -``` diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl deleted file mode 100644 index 534063f10..000000000 --- a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl +++ /dev/null @@ -1,33 +0,0 @@ -class {{brewFormulaName}} < Formula - desc "{{projectDescription}}" - homepage "{{projectWebsite}}" - url "{{distributionUrl}}" - version "{{projectVersion}}" - sha256 "{{distributionChecksumSha256}}" - license "{{projectLicense}}" - - def install - libexec.install Dir["*"] - - %w[tmp ext etc var candidates].each { |dir| mkdir libexec/dir } - - system "curl", "-s", "https://api.sdkman.io/2/candidates/all", "-o", libexec/"var/candidates" - - (libexec/"etc/config").write <<~EOS - sdkman_auto_answer=false - sdkman_auto_complete=true - sdkman_auto_env=false - sdkman_beta_channel=false - sdkman_colour_enable=true - sdkman_curl_connect_timeout=7 - sdkman_curl_max_time=10 - sdkman_debug_mode=false - sdkman_insecure_ssl=false - sdkman_selfupdate_feature=false - EOS - end - - test do - assert_match version, shell_output("export SDKMAN_DIR=#{libexec} && source #{libexec}/bin/sdkman-init.sh && sdk version") - end -end From 89199f5ecd49cf0dc0308e39be085aeff3dd8765 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 24 Jul 2024 16:50:20 +0100 Subject: [PATCH 69/84] Update support request template. --- .github/ISSUE_TEMPLATE/support_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/support_request.md b/.github/ISSUE_TEMPLATE/support_request.md index 495d79fb6..53639d6c2 100644 --- a/.github/ISSUE_TEMPLATE/support_request.md +++ b/.github/ISSUE_TEMPLATE/support_request.md @@ -12,7 +12,7 @@ Please consider the following things. Note, that ignoring all of these might lea - [ ] I have checked [the documentation](https://sdkman.io/usage) - [ ] I have done a quick search in [past issues](https://github.com/rclone/rclone/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems -- [ ] I have brought up a conversation in the [Slack User Issues Channel](https://sdkman.slack.com/app_redirect?channel=user-issues) +- [ ] I have brought up a conversation in the [Discord Help Channel](https://discord.gg/y9mVJYVyu4) **Question** From 42b1af600aa122b53f22a53b283c143e5dfc8e69 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 19 Aug 2024 21:30:39 +0100 Subject: [PATCH 70/84] Update CONTRIBUTING.md --- CONTRIBUTING.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 26e790f53..7cb30a3a1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,17 +2,14 @@ We greatly value the feedback and contributions of our users. -We keep a distinction between Bugs/Issues, New Features and Support Requests. We also try to minimise the noise in our GitHub Issues stream and prefer having a conversation on [SDKMAN Slack](https://slack.sdkman.io) before creating new issues, if you are not fully sure how to categorize your request. Simply sign up and join one of the following channels: - -- User Issues can be raised in our [User Issues channel](https://sdkman.slack.com/app_redirect?channel=user-issues). -- New Features or Enhancements can be discussed in our [CLI Development channel](https://sdkman.slack.com/app_redirect?channel=cli-development). +We distinguish between Bugs/Issues, New Features and Support Requests. We also try to minimise the noise in our GitHub Issues stream and prefer having a conversation on [SDKMAN Discord](https://discord.gg/y9mVJYVyu4) before creating new issues if you are not entirely sure how to categorize your request. Sign up and join our Help channel. The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required information. -**Unfortunately we might simply close any GitHub Issues that have not followed the requested template.** +**Unfortunately, we might close any GitHub Issues that have not followed the requested template.** ### Pull Requests -Pull Requests are _always_ very welcome, but require a valid GitHub Issue as described above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the GitHub Issue number by replacing `#XXX` with the appropriate issue reference. +Pull Requests are _always_ very welcome but require a valid GitHub Issue as described above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the GitHub Issue number by replacing `#XXX` with the appropriate issue reference. Each PR should also be accompanied by a passing test(s) proving its validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue. From 8e6d096ed3c9a7589a7e3a1209705072418de97c Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 19 Aug 2024 21:32:49 +0100 Subject: [PATCH 71/84] Update feature_request.md --- .github/ISSUE_TEMPLATE/feature_request.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 348d9aed0..1de36abb6 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -9,8 +9,8 @@ assignees: '' - [ ] I have read the [CONTRIBUTING guidelines](CONTRIBUTING.md) -- [ ] I've had a conversation on the [#cli-development](https://sdkman.slack.com/app_redirect?channel=cli-development) Slack channel about this request. +- [ ] I've had a conversation on our community [Discord](https://discord.gg/y9mVJYVyu4) server. **Feature request** - + From e6b29b61a74736fd3fad4756df01ffdf9053ea9c Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 19 Aug 2024 21:35:32 +0100 Subject: [PATCH 72/84] Update support_request.md --- .github/ISSUE_TEMPLATE/support_request.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/support_request.md b/.github/ISSUE_TEMPLATE/support_request.md index 53639d6c2..145399b18 100644 --- a/.github/ISSUE_TEMPLATE/support_request.md +++ b/.github/ISSUE_TEMPLATE/support_request.md @@ -6,13 +6,13 @@ labels: 'support' assignees: '' --- - +Please consider the following things. Note that ignoring all of these might lead to the issue being closed. --> - [ ] I have checked [the documentation](https://sdkman.io/usage) -- [ ] I have done a quick search in [past issues](https://github.com/rclone/rclone/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems -- [ ] I have brought up a conversation in the [Discord Help Channel](https://discord.gg/y9mVJYVyu4) +- [ ] I have performed a quick search in [past issues](https://github.com/rclone/rclone/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems +- [ ] I have brought up a conversation in the community [Discord](https://discord.gg/y9mVJYVyu4) server **Question** From 47e4c6c8f1327b23564d56ca96d2e5beaaf470bb Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 19 Aug 2024 21:37:16 +0100 Subject: [PATCH 73/84] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 60e1c7859..b8eb2f573 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,9 +3,9 @@ contact_links: - name: SDKMAN! usage documentation url: https://sdkman.io/usage about: Find documentation about the available commands here. - - name: SDKMAN! Slack community - url: https://slack.sdkman.io/ - about: Please ask and answer questions about usage of SDKMAN! here. + - name: SDKMAN! Discord server + url: https://discord.gg/y9mVJYVyu4 + about: Please ask and answer questions about the usage of SDKMAN! here. - name: SDKMAN! on Stack Overflow url: https://stackoverflow.com/questions/tagged/sdkman about: You might find help to common issues here. From ec6d5e01d2bfb54477f34220660939b775a61997 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 23 Nov 2024 00:58:50 +0000 Subject: [PATCH 74/84] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 641e68858..fc899d443 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Backers on Open Collective](https://opencollective.com/sdkman/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/sdkman/sponsors/badge.svg)](#sponsors) -[![Slack](https://slack.sdkman.io/badge.svg)](https://slack.sdkman.io) +[![Discord](https://img.shields.io/discord/1245471991117512754)](https://discord.gg/y9mVJYVyu4) SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix-based system. It provides a convenient command-line interface for installing, switching, removing, and listing Candidates. From 0e15c949bf158d2b6a8febbbf46da0ebb33f2e59 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 23 Nov 2024 21:35:38 +0000 Subject: [PATCH 75/84] Use shields.io for all badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fc899d443..9442867fe 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # SDKMAN! CLI ### The Software Development Kit Manager Command Line Interface -[![Backers on Open Collective](https://opencollective.com/sdkman/backers/badge.svg)](#backers) -[![Sponsors on Open Collective](https://opencollective.com/sdkman/sponsors/badge.svg)](#sponsors) +[![Backers on Open Collective](https://img.shields.io/opencollective/backers/sdkman)](#backers) +[![Sponsors on Open Collective](https://img.shields.io/opencollective/sponsors/sdkman)](#sponsors) [![Discord](https://img.shields.io/discord/1245471991117512754)](https://discord.gg/y9mVJYVyu4) SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix-based system. It provides a convenient command-line interface for installing, switching, removing, and listing Candidates. From cbbef0f98da984edb574561f3ed5df21a4cace29 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 25 Nov 2024 22:24:19 +0000 Subject: [PATCH 76/84] Update feature request template. --- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 1de36abb6..6b2bff9f9 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -6,7 +6,7 @@ labels: 'enhancement' assignees: '' --- - + - [ ] I have read the [CONTRIBUTING guidelines](CONTRIBUTING.md) - [ ] I've had a conversation on our community [Discord](https://discord.gg/y9mVJYVyu4) server. From b24e3eef2e0c7a524d301a59d15cd34f12137ffa Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Mon, 25 Nov 2024 22:27:29 +0000 Subject: [PATCH 77/84] Fixes to bug report template. --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e1500cac6..960ecf272 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,13 +7,13 @@ assignees: '' --- - + **Bug report** **To reproduce** - + **System info** +Please consider the following things. Just so you know, ignoring any of these might lead to the issue being closed abruptly. --> - [ ] I have checked [the documentation](https://sdkman.io/usage) -- [ ] I have performed a quick search in [past issues](https://github.com/rclone/rclone/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems +- [ ] I have performed a quick search in [past issues](https://github.com/sdkman/sdkman-cli/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems - [ ] I have brought up a conversation in the community [Discord](https://discord.gg/y9mVJYVyu4) server **Question** From 6035719bd4781e977ade4cce077f839e5e5be480 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 18 Dec 2024 20:13:48 +0000 Subject: [PATCH 79/84] Observe the sdkman_native_enable feature flag --- src/main/bash/sdkman-main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index c46ba11f9..5d592e9ee 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -129,7 +129,7 @@ function sdk() { # Native commands found under libexec local native_command="${SDKMAN_DIR}/libexec/${COMMAND}" - if [ -f "$native_command" ]; then + if [[ "$sdkman_native_enable" == 'true' && -f "$native_command" ]]; then "$native_command" "${@:2}" elif [ -n "$CMD_FOUND" ]; then From 7280765862dd0e5df5c1d06ec9d82e4e8bdc496b Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 18 Dec 2024 20:21:36 +0000 Subject: [PATCH 80/84] Explicitly disable native extensions in tests --- src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index 05d600f15..ab7058ad6 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -32,6 +32,7 @@ class SdkmanBashEnvBuilder { Map config = [ sdkman_auto_answer : 'false', sdkman_beta_channel: 'false', + sdkman_native_enable: 'false', sdkman_selfupdate_feature: 'true' ] From f8f97f8cbd26bef061b7dced679591d20477d9d1 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 18 Dec 2024 21:44:00 +0000 Subject: [PATCH 81/84] Issue deprecation notice for eclipsed legacy commands --- src/main/bash/sdkman-default.sh | 1 + src/main/bash/sdkman-help.sh | 1 + src/main/bash/sdkman-home.sh | 1 + src/main/bash/sdkman-uninstall.sh | 1 + src/main/bash/sdkman-utils.sh | 15 +++++++++++++++ src/main/bash/sdkman-version.sh | 1 + 6 files changed, 20 insertions(+) diff --git a/src/main/bash/sdkman-default.sh b/src/main/bash/sdkman-default.sh index 52d4ec612..a5470c099 100644 --- a/src/main/bash/sdkman-default.sh +++ b/src/main/bash/sdkman-default.sh @@ -17,6 +17,7 @@ # function __sdk_default() { + __sdkman_deprecation_notice "default" local candidate version candidate="$1" diff --git a/src/main/bash/sdkman-help.sh b/src/main/bash/sdkman-help.sh index a8a9b9781..70bacc448 100644 --- a/src/main/bash/sdkman-help.sh +++ b/src/main/bash/sdkman-help.sh @@ -17,6 +17,7 @@ # function __sdk_help() { + __sdkman_deprecation_notice "help" __sdkman_echo_no_colour "" __sdkman_echo_no_colour "Usage: sdk [candidate] [version]" __sdkman_echo_no_colour " sdk offline " diff --git a/src/main/bash/sdkman-home.sh b/src/main/bash/sdkman-home.sh index 841d32bf6..e3e2b4755 100644 --- a/src/main/bash/sdkman-home.sh +++ b/src/main/bash/sdkman-home.sh @@ -17,6 +17,7 @@ # function __sdk_home() { + __sdkman_deprecation_notice "home" local candidate version candidate="$1" diff --git a/src/main/bash/sdkman-uninstall.sh b/src/main/bash/sdkman-uninstall.sh index 16de6cfdd..c43e801b4 100644 --- a/src/main/bash/sdkman-uninstall.sh +++ b/src/main/bash/sdkman-uninstall.sh @@ -17,6 +17,7 @@ # function __sdk_uninstall() { + __sdkman_deprecation_notice "uninstall" local candidate version current candidate="$1" diff --git a/src/main/bash/sdkman-utils.sh b/src/main/bash/sdkman-utils.sh index 51797264f..e6b2247b4 100644 --- a/src/main/bash/sdkman-utils.sh +++ b/src/main/bash/sdkman-utils.sh @@ -110,3 +110,18 @@ function __sdkman_echo_confirm() { echo -e -n "\033[1;33m$1\033[0m" fi } + +function __sdkman_deprecation_notice() { + local message="[Deprecation Notice]: +This legacy '$1' command is replaced by a native implementation +and it will be removed in a future release. +Learn more at https://sdkman.io/native +" + + if [[ "$sdkman_colour_enable" == 'false' ]]; then + __sdkman_echo_no_colour "$message" + else + __sdkman_echo_yellow "$message" + fi +} + diff --git a/src/main/bash/sdkman-version.sh b/src/main/bash/sdkman-version.sh index 0b3b49335..640aa716f 100644 --- a/src/main/bash/sdkman-version.sh +++ b/src/main/bash/sdkman-version.sh @@ -17,6 +17,7 @@ # function __sdk_version() { + __sdkman_deprecation_notice "version" local version=$(cat $SDKMAN_DIR/var/version) echo "" __sdkman_echo_yellow "SDKMAN $version" From 9c657e9779b8cd6900ef33d307e114be6f54fe59 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 18 Dec 2024 22:08:54 +0000 Subject: [PATCH 82/84] Improve deprecation message formatting --- src/main/bash/sdkman-utils.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/bash/sdkman-utils.sh b/src/main/bash/sdkman-utils.sh index e6b2247b4..854efd0b1 100644 --- a/src/main/bash/sdkman-utils.sh +++ b/src/main/bash/sdkman-utils.sh @@ -112,11 +112,13 @@ function __sdkman_echo_confirm() { } function __sdkman_deprecation_notice() { - local message="[Deprecation Notice]: + local message=" +[Deprecation Notice]: + This legacy '$1' command is replaced by a native implementation and it will be removed in a future release. -Learn more at https://sdkman.io/native -" + +Learn more at https://sdkman.io/native" if [[ "$sdkman_colour_enable" == 'false' ]]; then __sdkman_echo_no_colour "$message" From cadd725f567261198305a91f63f5ed316b1340ae Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Thu, 19 Dec 2024 11:08:10 +0000 Subject: [PATCH 83/84] Update deprecation link --- src/main/bash/sdkman-utils.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/bash/sdkman-utils.sh b/src/main/bash/sdkman-utils.sh index 854efd0b1..8b2f6c645 100644 --- a/src/main/bash/sdkman-utils.sh +++ b/src/main/bash/sdkman-utils.sh @@ -118,7 +118,8 @@ function __sdkman_deprecation_notice() { This legacy '$1' command is replaced by a native implementation and it will be removed in a future release. -Learn more at https://sdkman.io/native" +Follow the discussion here: +https://github.com/sdkman/sdkman-cli-native/discussions/18" if [[ "$sdkman_colour_enable" == 'false' ]]; then __sdkman_echo_no_colour "$message" From b8d230b520debaefc4d004683c70ad9ce58075e3 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Sat, 21 Dec 2024 14:51:16 +0000 Subject: [PATCH 84/84] Update deprecation link again --- src/main/bash/sdkman-utils.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/bash/sdkman-utils.sh b/src/main/bash/sdkman-utils.sh index 8b2f6c645..397778d98 100644 --- a/src/main/bash/sdkman-utils.sh +++ b/src/main/bash/sdkman-utils.sh @@ -114,12 +114,10 @@ function __sdkman_echo_confirm() { function __sdkman_deprecation_notice() { local message=" [Deprecation Notice]: - This legacy '$1' command is replaced by a native implementation and it will be removed in a future release. - -Follow the discussion here: -https://github.com/sdkman/sdkman-cli-native/discussions/18" +Please follow the discussion here: +https://github.com/sdkman/sdkman-cli/discussions/1332" if [[ "$sdkman_colour_enable" == 'false' ]]; then __sdkman_echo_no_colour "$message"