├── .editorconfig ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST │ └── pull_request_template.md └── workflows │ ├── build.yml │ └── pre-commit.yml ├── .pre-commit-config.yaml ├── .secrets.baseline ├── .tool-versions ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── bin ├── download ├── exec-env ├── install ├── list-all └── list-bin-paths ├── contributing.md ├── docker-compose.yml ├── lib └── utils.bash ├── pyproject.toml ├── renovate.json └── scripts ├── github_actions-install_tools.bash └── tests.bash /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @asdf-community/asdf-kotlin 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "" 5 | labels: bug 6 | assignees: "" 7 | --- 8 | 9 | ## Describe the bug 10 | 11 | 12 | 13 | ## Steps to reproduce 14 | 15 | 16 | 17 | ## Expected behavior 18 | 19 | 20 | 21 | ## Screenshots 22 | 23 | 24 | 25 | ## Additional context 26 | 27 | 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "" 5 | labels: enhancement 6 | assignees: "" 7 | --- 8 | 9 | ## Is your feature request related to a problem? Please describe 10 | 11 | 17 | 18 | ## Describe the solution you'd like 19 | 20 | 21 | 22 | ## Describe alternatives you've considered 23 | 24 | 30 | 31 | ## Additional context 32 | 33 | 34 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ## Description 5 | 6 | 7 | 8 | ## Motivation and Context 9 | 10 | 11 | 12 | 13 | ## Types of changes 14 | 15 | 21 | 22 | - [ ] Bug fix (non-breaking change which fixes an issue) 23 | - [ ] New feature (non-breaking change which adds functionality) 24 | - [ ] Breaking change 25 | (fix or feature that would cause existing functionality to change) 26 | 27 | ## Usage examples 28 | 29 | 30 | 31 | ## How Has This Been Tested? 32 | 33 | 34 | 35 | ## Checklist 36 | 37 | 44 | 45 | - [ ] I have updated the documentation accordingly. 46 | - [ ] I have added tests to cover my changes. 47 | - [ ] Local linux/docker tests pass (See 48 | [README](https://github.com/asdf-community/asdf-kotlin#locally-with-docker-compose) 49 | ). 50 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Build 3 | on: 4 | schedule: 5 | - cron: "0 23 * * 1" 6 | push: 7 | branches: 8 | - master 9 | pull_request: 10 | jobs: 11 | plugin_test: 12 | name: asdf plugin test 13 | strategy: 14 | matrix: 15 | os: 16 | - ubuntu-latest 17 | - macos-latest 18 | runs-on: ${{ matrix.os }} 19 | steps: 20 | - name: asdf_plugin_test 21 | uses: asdf-vm/actions/plugin-test@v4 22 | with: 23 | command: kotlin -help 24 | - uses: actions/setup-java@v4 25 | with: 26 | distribution: 'temurin' 27 | java-version: '21' 28 | - name: Checkout code 29 | uses: actions/checkout@v4 30 | with: 31 | path: kotlin 32 | - name: Move kotlin plugin to plugins dir 33 | run: | 34 | mkdir -p "${HOME}/.asdf/plugins/" 35 | mv kotlin "${HOME}/.asdf/plugins/" 36 | - name: Run kotlin specific tests 37 | run: |- 38 | bash "${HOME}/.asdf/plugins/kotlin/scripts/tests.bash" 39 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Run pre-commit 3 | on: 4 | push: 5 | branches: [develop, master, main] 6 | pull_request: 7 | jobs: 8 | pre-commit: 9 | name: Run pre-commit 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - name: Install asdf dependencies 15 | uses: asdf-vm/actions/install@v4 16 | - name: Setup python 17 | uses: actions/setup-python@v5 18 | - name: Install tools 19 | shell: bash 20 | run: | 21 | bash -x ./scripts/github_actions-install_tools.bash 22 | - name: run pre-commit 23 | uses: pre-commit/action@v3.0.1 24 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | - repo: https://github.com/lyz-code/yamlfix/ 4 | rev: 1.17.0 5 | hooks: 6 | - id: yamlfix 7 | - repo: https://github.com/Yelp/detect-secrets 8 | rev: v1.5.0 9 | hooks: 10 | - id: detect-secrets 11 | args: 12 | - --baseline 13 | - .secrets.baseline 14 | exclude: package.lock.json 15 | - repo: https://github.com/pre-commit/pre-commit-hooks 16 | rev: v5.0.0 17 | hooks: 18 | - id: check-case-conflict 19 | - id: check-executables-have-shebangs 20 | - id: check-merge-conflict 21 | - id: check-shebang-scripts-are-executable 22 | - id: check-toml 23 | - id: detect-private-key 24 | - id: end-of-file-fixer 25 | - id: mixed-line-ending 26 | - id: trailing-whitespace 27 | - id: pretty-format-json 28 | args: 29 | - --autofix 30 | - repo: https://github.com/gruntwork-io/pre-commit 31 | rev: v0.1.26 32 | hooks: 33 | - id: shellcheck 34 | - repo: https://github.com/igorshubovych/markdownlint-cli 35 | rev: v0.44.0 36 | hooks: 37 | - id: markdownlint-fix 38 | - repo: https://github.com/rhysd/actionlint 39 | rev: v1.7.7 40 | hooks: 41 | - id: actionlint-system 42 | -------------------------------------------------------------------------------- /.secrets.baseline: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.4.0", 3 | "plugins_used": [ 4 | { 5 | "name": "ArtifactoryDetector" 6 | }, 7 | { 8 | "name": "AWSKeyDetector" 9 | }, 10 | { 11 | "name": "AzureStorageKeyDetector" 12 | }, 13 | { 14 | "name": "Base64HighEntropyString", 15 | "limit": 4.5 16 | }, 17 | { 18 | "name": "BasicAuthDetector" 19 | }, 20 | { 21 | "name": "CloudantDetector" 22 | }, 23 | { 24 | "name": "DiscordBotTokenDetector" 25 | }, 26 | { 27 | "name": "GitHubTokenDetector" 28 | }, 29 | { 30 | "name": "HexHighEntropyString", 31 | "limit": 3.0 32 | }, 33 | { 34 | "name": "IbmCloudIamDetector" 35 | }, 36 | { 37 | "name": "IbmCosHmacDetector" 38 | }, 39 | { 40 | "name": "JwtTokenDetector" 41 | }, 42 | { 43 | "name": "KeywordDetector", 44 | "keyword_exclude": "" 45 | }, 46 | { 47 | "name": "MailchimpDetector" 48 | }, 49 | { 50 | "name": "NpmDetector" 51 | }, 52 | { 53 | "name": "PrivateKeyDetector" 54 | }, 55 | { 56 | "name": "SendGridDetector" 57 | }, 58 | { 59 | "name": "SlackDetector" 60 | }, 61 | { 62 | "name": "SoftlayerDetector" 63 | }, 64 | { 65 | "name": "SquareOAuthDetector" 66 | }, 67 | { 68 | "name": "StripeDetector" 69 | }, 70 | { 71 | "name": "TwilioKeyDetector" 72 | } 73 | ], 74 | "filters_used": [ 75 | { 76 | "path": "detect_secrets.filters.allowlist.is_line_allowlisted" 77 | }, 78 | { 79 | "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", 80 | "min_level": 2 81 | }, 82 | { 83 | "path": "detect_secrets.filters.heuristic.is_indirect_reference" 84 | }, 85 | { 86 | "path": "detect_secrets.filters.heuristic.is_likely_id_string" 87 | }, 88 | { 89 | "path": "detect_secrets.filters.heuristic.is_lock_file" 90 | }, 91 | { 92 | "path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string" 93 | }, 94 | { 95 | "path": "detect_secrets.filters.heuristic.is_potential_uuid" 96 | }, 97 | { 98 | "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign" 99 | }, 100 | { 101 | "path": "detect_secrets.filters.heuristic.is_sequential_string" 102 | }, 103 | { 104 | "path": "detect_secrets.filters.heuristic.is_swagger_file" 105 | }, 106 | { 107 | "path": "detect_secrets.filters.heuristic.is_templated_secret" 108 | } 109 | ], 110 | "results": {}, 111 | "generated_at": "2023-03-02T02:55:51Z" 112 | } 113 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | shellcheck 0.10.0 2 | shfmt 3.11.0 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:noble-20250529 2 | 3 | RUN \ 4 | apt update && \ 5 | apt install -y git curl rsync unzip python3-pip && \ 6 | pip3 install shyaml && \ 7 | useradd --create-home --shell /bin/bash build && \ 8 | mkdir -p /home/build/src && \ 9 | chown build:build /home/build/src 10 | 11 | USER build 12 | WORKDIR /home/build/src 13 | ENTRYPOINT ["/bin/bash", "-c"] 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ricardo Rosales 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SRCFILES = $(shell git ls-files "bin/**" "lib/**" "scripts/**") 2 | SHFMT_BASE_FLAGS = -s -i 2 -ci 3 | 4 | format: 5 | shfmt -w $(SHFMT_BASE_FLAGS) $(SRCFILES) 6 | .PHONY: format 7 | 8 | format-check: 9 | shfmt -d $(SHFMT_BASE_FLAGS) $(SRCFILES) 10 | .PHONY: format-check 11 | 12 | lint: 13 | shellcheck $(SRCFILES) 14 | .PHONY: lint 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | > [!WARNING] 5 | > Looking for maintainers. See 6 | 7 |
8 | 9 | # asdf-kotlin [![Build](https://github.com/asdf-community/asdf-kotlin/actions/workflows/build.yml/badge.svg)](https://github.com/asdf-community/asdf-kotlin/actions/workflows/build.yml) 10 | 11 | kotlin (and [kotlin-native if available](https://github.com/asdf-community/asdf-kotlin/pull/4)) plugin for [asdf version manager](https://github.com/asdf-vm/asdf) 12 | 13 |
14 | 15 | 16 | # Contents 17 | 18 | - [Dependencies](#dependencies) 19 | - [Install](#install) 20 | - [Contributing](#contributing) 21 | - [Issues](#issues) 22 | - [License](#license) 23 | - [Tests](#tests) 24 | 25 | # Dependencies 26 | 27 | - `curl`, `tar`, `unzip`: generic POSIX utilities. 28 | - [Java 8+](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 29 | - You may want to try [asdf-java](https://github.com/halcyon/asdf-java) 30 | `asdf plugin-add java https://github.com/halcyon/asdf-java` 31 | - [Which versions of JVM does Kotlin target?](https://kotlinlang.org/docs/faq.html#which-versions-of-jvm-does-kotlin-target) 32 | 33 | # Install 34 | 35 | Plugin: 36 | 37 | ```shell 38 | asdf plugin add kotlin 39 | # or 40 | asdf plugin add kotlin https://github.com/asdf-community/asdf-kotlin.git 41 | ``` 42 | 43 | kotlin: 44 | 45 | ```shell 46 | # Show all installable versions 47 | asdf list-all kotlin 48 | 49 | # Install specific version 50 | asdf install kotlin latest 51 | 52 | # Set a version globally (on your ~/.tool-versions file) 53 | asdf set kotlin latest 54 | 55 | # Now kotlin commands are available 56 | kotlin -help 57 | ``` 58 | 59 | Check the [asdf](https://github.com/asdf-vm/asdf) readme for instructions on 60 | how to install & manage versions of kotlin. 61 | 62 | # Contributing 63 | 64 | Contributions of any kind welcome! See the 65 | [contributing guide](contributing.md). 66 | 67 | [Thanks goes to these contributors](https://github.com/asdf-community/asdf-kotlin/graphs/contributors)! 68 | 69 | # Issues 70 | 71 | - Doesn't check if java is installed 72 | 73 | # License 74 | 75 | MIT License 76 | 77 | # Tests 78 | 79 | ## Github Actions 80 | 81 | **Note**: See [workflows](./.github/workflows) 82 | 83 | - It tests installing a version of kotlin without kotlin native 84 | (Version `1.0.3`) on mac and linux 85 | - It tests installing a version of kotlin with kotlin native (Version `1.3.21`) 86 | on mac and linux 87 | - It tests installing a version of kotlin with new kotlin native naming 88 | (Version `1.4.30-RC`) on mac and linux 89 | - It tests installing a version of kotling with new kotlin native naming that 90 | includes arch (Version `1.5.30-M1`) on mac and linux 91 | - It tests installing `latest` version of kotlin on mac and linux 92 | 93 | ## Locally with Docker Compose 94 | 95 | **Note**: Only tests linux (Ubuntu `22.04`) and takes a while since it builds 96 | on every run 97 | 98 | - `cd /path/to/this/repo` 99 | - `docker compose up --force-recreate --abort-on-container-exit` 100 | 101 | 102 | 103 | ```bash 104 | Creating asdf-kotlin-linux-test ... done 105 | Attaching to asdf-kotlin-linux-test 106 | asdf-kotlin-linux-test | Cloning into '/home/build/.asdf'... 107 | ... 108 | asdf-kotlin-linux-test | % Total % Received % Xferd Average Speed Time Time Time Current 109 | asdf-kotlin-linux-test | Dload Upload Total Spent Left Speed 110 | 100 621 0 621 0 0 1673 0 --:--:-- --:--:-- --:--:-- 1673 111 | 100 75.5M 100 75.5M 0 0 11.1M 0 0:00:06 0:00:06 --:--:-- 13.6M 112 | asdf-kotlin-linux-test | Setting kotlin 1.0.3 as the default value in ~/.tool-versions 113 | asdf-kotlin-linux-test | Confirming version 1.0.3 114 | asdf-kotlin-linux-test | Kotlin version 1.0.3 (JRE 11.0.1+13) 115 | asdf-kotlin-linux-test | Setting kotlin 1.3.21 as the default value in ~/.tool-versions 116 | asdf-kotlin-linux-test | Confirming version 1.3.21 117 | asdf-kotlin-linux-test | Kotlin version 1.3.21-release-158 (JRE 11.0.1+13) 118 | asdf-kotlin-linux-test | info: kotlinc-native 1.3.21 (JRE 11.0.1+13) 119 | asdf-kotlin-linux-test exited with code 0 120 | ``` 121 | 122 | 123 | -------------------------------------------------------------------------------- /bin/download: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | current_script_path=${BASH_SOURCE[0]} 6 | plugin_dir=$(dirname "$(dirname "$current_script_path")") 7 | 8 | # shellcheck disable=SC1091 9 | source "${plugin_dir}/lib/utils.bash" 10 | 11 | mkdir -p "${ASDF_DOWNLOAD_PATH}" 12 | 13 | release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.zip" 14 | 15 | # Download compressed file to the download directory 16 | download_release "$ASDF_INSTALL_VERSION" "$release_file" 17 | 18 | # Extract contents of zip file into the download directory 19 | unzip -qq "$release_file" -d "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file" 20 | 21 | # Remove the tar.gz file since we don't need to keep it 22 | rm "$release_file" 23 | 24 | # Download native if available 25 | native_download_path="$(get_native_download_path)" 26 | if [[ -n $native_download_path ]]; then 27 | mkdir -p "${ASDF_DOWNLOAD_PATH}/kotlin-native" 28 | native_download_url="https://github.com${native_download_path}" 29 | native_release_file="${ASDF_DOWNLOAD_PATH}/${TOOL_NAME}-native-${ASDF_INSTALL_VERSION}.tar.gz" 30 | echo "* Downloading ${TOOL_NAME}-native for release ${ASDF_INSTALL_VERSION}..." 31 | # shellcheck disable=SC2154 32 | curl "${curl_opts[@]}" -o "${native_release_file}" -C - \ 33 | "${native_download_url}" || fail "Could not download ${native_download_url}" 34 | tar -xf "${native_release_file}" --strip-components=1 \ 35 | --directory "${ASDF_DOWNLOAD_PATH}/kotlin-native" || fail "Could not extract ${native_release_file}" 36 | rm "${native_release_file}" 37 | fi 38 | -------------------------------------------------------------------------------- /bin/exec-env: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | function export_kotlin_home() { 5 | local IFS=$'\n\t' 6 | if [[ -z ${KOTLIN_HOME:-""} ]]; then 7 | export KOTLIN_HOME=${ASDF_INSTALL_PATH}/kotlinc 8 | fi 9 | } 10 | 11 | export_kotlin_home 12 | -------------------------------------------------------------------------------- /bin/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | current_script_path=${BASH_SOURCE[0]} 6 | plugin_dir=$(dirname "$(dirname "$current_script_path")") 7 | 8 | # shellcheck disable=SC1091 9 | source "${plugin_dir}/lib/utils.bash" 10 | 11 | install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" 12 | -------------------------------------------------------------------------------- /bin/list-all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | current_script_path=${BASH_SOURCE[0]} 6 | plugin_dir=$(dirname "$(dirname "$current_script_path")") 7 | 8 | # shellcheck disable=SC1091 9 | source "${plugin_dir}/lib/utils.bash" 10 | 11 | list_all_versions | sort_versions | xargs echo 12 | -------------------------------------------------------------------------------- /bin/list-bin-paths: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | echo -n "kotlinc/bin" "kotlin-native/bin" 6 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Testing Locally: 4 | 5 | ```shell 6 | asdf plugin test \ 7 | [--asdf-tool-version ] \ 8 | [--asdf-plugin-gitref ] \ 9 | [test-command*] 10 | ``` 11 | 12 | ## Example 13 | 14 | ```shell 15 | asdf plugin test kotlin https://github.com/missingcharacter/asdf-kotlin.git \ 16 | "kotlin -help" 17 | ``` 18 | 19 | Tests are automatically run in GitHub Actions on push and PR. 20 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | services: 4 | no-direnv: 5 | build: . 6 | container_name: asdf-kotlin-no-direnv 7 | tty: true 8 | working_dir: /home/build 9 | volumes: 10 | - .:/home/build/src 11 | command: 12 | - |- 13 | git clone https://github.com/asdf-vm/asdf.git ~/.asdf && \ 14 | . ~/.asdf/asdf.sh && \ 15 | mkdir -p ~/.asdf/plugins/kotlin && \ 16 | rsync -a /home/build/src/ ~/.asdf/plugins/kotlin/ && \ 17 | bash ~/.asdf/plugins/kotlin/scripts/tests.bash 18 | -------------------------------------------------------------------------------- /lib/utils.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | GH_REPO="https://github.com/JetBrains/kotlin" 6 | TOOL_NAME="kotlin" 7 | TOOL_TEST="kotlin -help" 8 | 9 | fail() { 10 | echo -e "asdf-${TOOL_NAME}: ${*}" 11 | exit 1 12 | } 13 | 14 | curl_opts=(-fsSL) 15 | 16 | # NOTE: You might want to remove this if kotlin is not hosted on GitHub releases. 17 | if [ -n "${GITHUB_API_TOKEN-}" ]; then 18 | curl_opts=("${curl_opts[@]}" -H "Authorization: token ${GITHUB_API_TOKEN}") 19 | fi 20 | 21 | sort_versions() { 22 | sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | 23 | LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' 24 | } 25 | 26 | list_github_tags() { 27 | git ls-remote --tags --refs "${GH_REPO}" | 28 | grep -o 'refs/tags/v.*' | cut -d/ -f3- | 29 | sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags 30 | } 31 | 32 | list_all_versions() { 33 | list_github_tags 34 | } 35 | 36 | download_release() { 37 | local version filename url 38 | version="${1}" 39 | filename="${2}" 40 | 41 | url="${GH_REPO}/releases/download/v${version}/${TOOL_NAME}-compiler-${version}.zip" 42 | 43 | echo "* Downloading $TOOL_NAME release ${version}..." 44 | curl "${curl_opts[@]}" -o "${filename}" -C - "${url}" || fail "Could not download ${url}" 45 | } 46 | 47 | install_version() { 48 | local install_type="${1}" 49 | local version="${2}" 50 | local install_path="${3}" 51 | 52 | if [ "$install_type" != "version" ]; then 53 | fail "asdf-${TOOL_NAME} supports release installs only" 54 | fi 55 | 56 | ( 57 | mkdir -p "${install_path}" 58 | cp -r "${ASDF_DOWNLOAD_PATH}"/* "${install_path}" 59 | 60 | local tool_cmd 61 | tool_cmd="$(echo "${TOOL_TEST}" | cut -d' ' -f1)" 62 | test -x "${install_path}/kotlinc/bin/${tool_cmd}" || fail "Expected ${install_path}/kotlinc/bin/${tool_cmd} to be executable." 63 | if [[ -d "${install_path}/kotlin-native" ]]; then 64 | test -x "${install_path}/kotlin-native/bin/${tool_cmd}c-native" || fail "Expected ${install_path}/kotlin-native/bin/${tool_cmd}c-native to be executable." 65 | fi 66 | 67 | echo "${TOOL_NAME} ${version} installation was successful!" 68 | ) || ( 69 | rm -rf "${install_path}" 70 | fail "An error ocurred while installing ${TOOL_NAME} ${version}." 71 | ) 72 | } 73 | 74 | # the releases page version does not line up with the kotlin version 75 | # so fetch the native-x.y.z version from the releases page 76 | get_native_download_path() { 77 | local check_regex grep_option tempdir native_download_path="" 78 | local check_url="${GH_REPO}/releases/expanded_assets/v${ASDF_INSTALL_VERSION}" 79 | grep_option="$(get_grep_options)" 80 | tempdir="$(create_temp_dir)" 81 | check_regex="/JetBrains/kotlin/releases/download/v${ASDF_INSTALL_VERSION}/$(get_native_regex_pattern)" 82 | local temp_html="${tempdir}/github-kotlin.html" 83 | curl -s --disable "${check_url}" -o "${temp_html}" 84 | if grep -q "${grep_option}" "${check_regex}" "${temp_html}"; then 85 | native_download_path="$(grep "${grep_option}" "${check_regex}" "${temp_html}" | grep -v 'sha256' | cut -f2 -d '"')" 86 | fi 87 | rm -rf "${tempdir}" 88 | echo "${native_download_path}" 89 | } 90 | 91 | get_kernel() { 92 | local kernel_name 93 | kernel_name="$(uname)" 94 | case "${kernel_name}" in 95 | Linux) 96 | echo -n 'linux' 97 | ;; 98 | Darwin) 99 | echo -n 'macos' 100 | ;; 101 | *) 102 | fail "Sorry, ${kernel_name} is not supported." 103 | ;; 104 | esac 105 | } 106 | 107 | get_arch() { 108 | local machine_hw_name 109 | machine_hw_name="$(uname -m)" 110 | case "${machine_hw_name}" in 111 | x86_64) 112 | echo -n 'x86_64' 113 | ;; 114 | aarch64 | arm64) 115 | echo -n 'aarch64' 116 | ;; 117 | *) 118 | fail "Sorry, ${machine_hw_name} is not supported." 119 | ;; 120 | esac 121 | } 122 | 123 | get_grep_options() { 124 | case "$(get_kernel)" in 125 | linux) 126 | echo -n '-P' 127 | ;; 128 | macos) 129 | /bin/echo -n '-E' 130 | ;; 131 | esac 132 | } 133 | 134 | get_native_regex_pattern() { 135 | echo -n "kotlin-native-(prebuilt-)?$(get_kernel)-($(get_arch)-)?\d+\.\d+\.\d+[^.]*.tar.gz" 136 | } 137 | 138 | create_temp_dir() { 139 | case "$(get_kernel)" in 140 | linux) 141 | echo -n "$(mktemp -dt asdf-kotlin-native.XXXX)" 142 | ;; 143 | macos) 144 | echo -n "$(/usr/bin/mktemp -dt asdf-kotlin-native)" 145 | ;; 146 | esac 147 | } 148 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.yamlfix] 2 | line_length = 80 3 | comments_min_spaces_from_content = 1 4 | flow_style_sequence = false 5 | sequence_style = "keep_style" 6 | preserve_quotes = true 7 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base", 5 | "schedule:daily" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /scripts/github_actions-install_tools.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | function retry_command() { 6 | # Source: https://github.com/aws-quickstart/quickstart-linux-utilities/blob/master/quickstart-cfn-tools.source#L413-L433 7 | # $1 = NumberOfRetries $2 = Command 8 | # retry_command 10 some_command.sh 9 | # Command will retry with linear back-off 10 | local -r __tries="${1}" 11 | shift 12 | declare -a __run=("${@}") 13 | local -i __backoff_delay=2 14 | local __current_try=0 15 | until "${__run[@]}"; do 16 | if ((__current_try == __tries)); then 17 | echo "Tried ${__current_try} times and failed!" 18 | return 1 19 | else 20 | echo "Retrying ...." 21 | sleep $(((__backoff_delay++) + (__current_try++))) 22 | fi 23 | done 24 | } 25 | 26 | function get_arch() { 27 | case "$(uname -m)" in 28 | armv5*) echo -n "armv5" ;; 29 | armv6*) echo -n "armv6" ;; 30 | armv7*) echo -n "armv7" ;; 31 | aarch64) echo -n "arm64" ;; 32 | x86) echo -n "386" ;; 33 | x86_64) echo -n "amd64" ;; 34 | i686) echo -n "386" ;; 35 | i386) echo -n "386" ;; 36 | esac 37 | } 38 | 39 | function get_os() { 40 | local kernel_name 41 | kernel_name="$(uname)" 42 | case "${kernel_name}" in 43 | Linux) 44 | echo -n 'linux' 45 | ;; 46 | Darwin) 47 | echo -n 'macos' 48 | ;; 49 | *) 50 | echo "Sorry, ${kernel_name} is not supported." >&2 51 | exit 1 52 | ;; 53 | esac 54 | } 55 | 56 | function get_latest_github_tag() { 57 | local owner="${1}" 58 | local repo="${2}" 59 | local remove_v="${3:-false}" 60 | local latest_tag 61 | latest_tag="$(curl -s "https://api.github.com/repos/${owner}/${repo}/releases/latest" | jq -r .tag_name)" 62 | if [[ "${remove_v}" == 'true' ]]; then 63 | echo -n "${latest_tag}" | tr -d 'v' 64 | return 0 65 | fi 66 | echo -n "${latest_tag}" 67 | } 68 | 69 | OS="$(get_os)" 70 | 71 | retry=3 72 | 73 | echo "Install detect-secrets" 74 | 75 | retry_command "${retry}" 'bash' '-c' 'pip install detect-secrets' 76 | 77 | echo "Install shellcheck" 78 | SHELLCHECK_VERSION="$(get_latest_github_tag 'koalaman' 'shellcheck' 'true')" 79 | wget -qO- "https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.${OS}.$(uname -m).tar.xz" | tar -xJf - 80 | mv "shellcheck-v${SHELLCHECK_VERSION}/shellcheck" /usr/local/bin 81 | rm -rf "shellcheck-v${SHELLCHECK_VERSION}" 82 | 83 | echo "Install actionlint" 84 | mkdir actionlint-download 85 | ACTIONLINT_VERSION="$(get_latest_github_tag 'rhysd' 'actionlint' 'true')" 86 | wget -qO- "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_${OS}_$(get_arch).tar.gz" | tar -C actionlint-download -xzf - 87 | mv actionlint-download/actionlint /usr/local/bin 88 | rm -rf actionlint-download 89 | 90 | hash -r 91 | -------------------------------------------------------------------------------- /scripts/tests.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | IFS=$'\n\t' 4 | 5 | JAVA_VERSION='openjdk-11.0.1' 6 | ANSI_NO_COLOR=$'\033[0m' 7 | THIS_SCRIPT=$(basename "${0}") 8 | 9 | function usage() { 10 | msg_info "Usage:" 11 | msg_info "${THIS_SCRIPT}" 12 | echo 13 | msg_info "Run kotlin tests" 14 | exit 1 15 | } 16 | 17 | function msg_info() { 18 | local GREEN=$'\033[0;32m' 19 | printf "%s\n" "${GREEN}${*}${ANSI_NO_COLOR}" >&2 20 | } 21 | 22 | function msg_warn() { 23 | local YELLOW=$'\033[0;33m' 24 | printf "%s\n" "${YELLOW}${*}${ANSI_NO_COLOR}" >&2 25 | } 26 | 27 | function msg_error() { 28 | local RED=$'\033[0;31m' 29 | printf "%s\n" "${RED}${*}${ANSI_NO_COLOR}" >&2 30 | } 31 | 32 | function msg_fatal() { 33 | msg_error "${*}" 34 | exit 1 35 | } 36 | 37 | function return_non_empty_array() { 38 | declare -a INPUT 39 | # https://stackoverflow.com/questions/7577052/bash-empty-array-expansion-with-set-u 40 | INPUT=("${@+"${@}"}") 41 | if [[ ${#INPUT[@]} -ne 0 ]]; then 42 | printf "%s\n" "${INPUT[@]}" 43 | fi 44 | } 45 | 46 | function install_requirements() { 47 | asdf plugin-add java 48 | msg_info "Will try to install java's ${JAVA_VERSION}" 49 | asdf install java "${JAVA_VERSION}" 50 | asdf set java "${JAVA_VERSION}" 51 | } 52 | 53 | function get_tool_version() { 54 | local TOOL="${1}" 55 | awk '{ print $2 }' <(grep "${TOOL}" "${HOME}"/.tool-versions) 56 | } 57 | 58 | function set_kotlin_version() { 59 | local KOTLIN_VERSION="${1}" 60 | msg_warn "Setting kotlin ${KOTLIN_VERSION} as the default value in ${HOME}/.tool-versions" 61 | asdf set kotlin "${KOTLIN_VERSION}" 62 | } 63 | 64 | function confirm_kotlin_version() { 65 | local KOTLIN_VERSION="${1}" 66 | declare -a KOTLIN_ARGS=('kotlin' '-version') KOTLINC_ARGS=('kotlinc-native' '-version') 67 | msg_warn 'Listing kotlin binaries in PATH' 68 | type -a kotlin 69 | msg_warn 'Printing kotlin binary used when called' 70 | type -P kotlin 71 | msg_warn "Confirming version ${KOTLIN_VERSION}" 72 | grep "^Kotlin version ${KOTLIN_VERSION}" <("${KOTLIN_ARGS[@]}" 2>&1) 73 | if [[ ${KOTLIN_VERSION} != '1.0.3' ]]; then 74 | if [[ ${KOTLIN_VERSION} == '1.3.21' ]]; then 75 | grep '^Kotlin/Native: 1.1.2' <("${KOTLINC_ARGS[@]}" 2>&1) 76 | else 77 | grep -i "^Kotlin/Native: ${KOTLIN_VERSION}" <("${KOTLINC_ARGS[@]}" 2>&1) 78 | fi 79 | fi 80 | } 81 | 82 | function test_kotlin_version() { 83 | local KOTLIN_VERSION="${1}" 84 | set_kotlin_version "${KOTLIN_VERSION}" 85 | msg_warn "java version is $(java -version)" 86 | confirm_kotlin_version "${KOTLIN_VERSION}" 87 | } 88 | 89 | while [[ $# -gt 0 ]]; do 90 | case "${1}" in 91 | -h | --help) 92 | usage 93 | ;; 94 | -*) 95 | echo "Unknown option ${1}" 96 | usage 97 | ;; 98 | esac 99 | done 100 | 101 | if [[ -z ${GITHUB_ACTIONS:-""} ]]; then 102 | GITHUB_ACTIONS='false' 103 | fi 104 | 105 | msg_info "GITHUB_EVENT_NAME is ${GITHUB_EVENT_NAME}" 106 | msg_info "GITHUB_REF_NAME is ${GITHUB_REF_NAME}" 107 | msg_info "GITHUB_SHA is ${GITHUB_SHA}" 108 | msg_info "GITHUB_ACTIONS is ${GITHUB_ACTIONS}" 109 | if [[ ${GITHUB_ACTIONS} == 'true' ]]; then 110 | msg_info "GITHUB_RUN_NUMBER is ${GITHUB_RUN_NUMBER}" 111 | msg_info "GITHUB_RUN_ATTEMPT is ${GITHUB_RUN_ATTEMPT}" 112 | fi 113 | 114 | if [[ ${GITHUB_ACTIONS} != 'true' ]]; then 115 | install_requirements 116 | fi 117 | msg_warn 'Trying to list all versions of kotlin' 118 | asdf list all kotlin 119 | msg_info 'Will try to install kotlin 1.0.3 (version without kotlin native)' 120 | asdf install kotlin '1.0.3' 121 | msg_info 'Will try to install kotlin 1.3.21 (version with kotlin native)' 122 | asdf install kotlin '1.3.21' 123 | msg_info 'Will try to install kotlin 1.4.30-RC (version with new kotlin native naming)' 124 | asdf install kotlin '1.4.30-RC' 125 | msg_info 'Will try to install kotlin 1.5.30-M1 (version with MacOS aarch64 kotlin native)' 126 | asdf install kotlin '1.5.30-M1' 127 | msg_info 'Will try to install kotlin latest version' 128 | asdf install kotlin 'latest' | tee -a kotlin-latest.out 129 | LATEST_VERSION="$(grep 'installation was successful' kotlin-latest.out | awk '{ print $2 }')" 130 | rm kotlin-latest.out 131 | msg_info 'Will test versions now' 132 | test_kotlin_version '1.0.3' 133 | test_kotlin_version '1.3.21' 134 | test_kotlin_version '1.4.30-RC' 135 | test_kotlin_version '1.5.30-M1' 136 | test_kotlin_version "${LATEST_VERSION}" 137 | --------------------------------------------------------------------------------