diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d07adf074..e40a01958 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -# pull request +# Pull Request diff --git a/.github/workflows/check-deprecated-exercises.yml b/.github/workflows/check-deprecated-exercises.yml new file mode 100644 index 000000000..8defbd0cf --- /dev/null +++ b/.github/workflows/check-deprecated-exercises.yml @@ -0,0 +1,21 @@ +name: Deprecated + +on: + pull_request: + paths: + - "exercises/**" + push: + branches: + - main + workflow_dispatch: + +jobs: + test-deprecated: + name: Check for deprecated exercises + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + fetch-depth: 0 + - name: Test deprecated exercises using test-deprecated-exercises + run: bin/test-deprecated-exercises diff --git a/.github/workflows/create-configlet-sync-issues.yml b/.github/workflows/create-configlet-sync-issues.yml new file mode 100644 index 000000000..1a256cfb9 --- /dev/null +++ b/.github/workflows/create-configlet-sync-issues.yml @@ -0,0 +1,176 @@ +name: Create Configlet Sync Issues + +on: + workflow_call: + workflow_dispatch: + +permissions: + issues: write + contents: read + +jobs: + create-sync-issues: + runs-on: ubuntu-24.04 + timeout-minutes: 15 + + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PARENT_ISSUE_TITLE: "🚨 configlet sync --test found unsynced tests" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Fetch configlet + run: ./bin/fetch-configlet + + - name: Run configlet sync --tests and capture output + id: sync + shell: bash {0} + run: | + raw_output="$(./bin/configlet sync --tests 2>&1)" + exit_code=$? + printf "exit_code=%d\n" "$exit_code" >> "$GITHUB_OUTPUT" + { + printf "output<> "$GITHUB_OUTPUT" + printf "configlet exit code: %d\n" "$exit_code" + printf "%s\n" "$raw_output" + + - name: Parse exercises with missing tests + id: parse + if: steps.sync.outputs.exit_code != '0' + shell: bash + run: | + output='${{ steps.sync.outputs.output }}' + + # Extract exercise slugs from lines like: [warn] dot-dsl: missing 19 test cases + mapfile -t exercises < <(printf "%s\n" "$output" | grep -oP '(?<=\[warn\] )[a-z][a-z0-9-]+(?=: missing \d+ test case)') + + if [[ ${#exercises[@]} -eq 0 ]]; then + printf "No exercises with missing tests found in output.\n" + printf "exercises_json=[]\n" >> "$GITHUB_OUTPUT" + exit 0 + fi + + printf "Found %d exercise(s) with missing tests:\n" "${#exercises[@]}" + printf " - %s\n" "${exercises[@]}" + + # Build JSON array of slugs + json="[" + for i in "${!exercises[@]}"; do + [[ $i -gt 0 ]] && json+="," + json+="\"${exercises[$i]}\"" + done + json+="]" + printf "exercises_json=%s\n" "$json" >> "$GITHUB_OUTPUT" + + # Build per-exercise details: slug test_name uuid (one row per test) + { + printf "details<> "$GITHUB_OUTPUT" + + - name: Find parent tracking issue + id: find_parent + if: steps.sync.outputs.exit_code != '0' && steps.parse.outputs.exercises_json != '[]' + shell: bash + run: | + issue_data=$(gh issue list \ + --repo "${{ github.repository }}" \ + --search "is:issue is:open in:title \"${PARENT_ISSUE_TITLE}\"" \ + --json number \ + --jq '.[0].number // empty') + + if [[ -z "$issue_data" ]]; then + printf "::warning::Parent issue not found. Run 'Run Configlet Sync' first.\n" + printf "parent_number=\n" >> "$GITHUB_OUTPUT" + else + printf "Found parent issue #%s\n" "$issue_data" + printf "parent_number=%s\n" "$issue_data" >> "$GITHUB_OUTPUT" + fi + + - name: Create or update child issues per exercise + if: steps.sync.outputs.exit_code != '0' && steps.parse.outputs.exercises_json != '[]' + shell: bash + env: + EXERCISES_JSON: ${{ steps.parse.outputs.exercises_json }} + DETAILS: ${{ steps.parse.outputs.details }} + PARENT_NUMBER: ${{ steps.find_parent.outputs.parent_number }} + run: | + repo="${{ github.repository }}" + + mapfile -t exercises < <(printf "%s\n" "$EXERCISES_JSON" | jq -r '.[]') + + for slug in "${exercises[@]}"; do + child_title="[configlet] ${slug}: missing test cases" + + # Collect missing tests for this exercise + missing_tests="" + while IFS=$'\t' read -r es_slug test_name uuid; do + [[ "$es_slug" == "$slug" ]] || continue + missing_tests+="- \`${uuid}\` ${test_name}"$'\n' + done <<< "$DETAILS" + + parent_ref="" + [[ -n "$PARENT_NUMBER" ]] && parent_ref="Part of #${PARENT_NUMBER}." + + # Write body to a temp file to avoid quoting / indentation issues + body_file=$(mktemp) + cat > "$body_file" << ISSUE_BODY_EOF + ## Missing test cases for \`${slug}\` + + ${parent_ref} + + The following test cases from [problem-specifications](https://github.com/exercism/problem-specifications/tree/main/exercises/${slug}) are not yet implemented in this track: + + ${missing_tests} + ### How to help + + For detailed instructions on how to fetch configlet and update the tests, please see the **"How to do this task"** section in the main tracking issue: + 👉 **[Read the instructions here](${{ github.server_url }}/${{ github.repository }}/issues/${PARENT_NUMBER:-"none"})** + + _This issue is managed automatically by the [Create Configlet Sync Issues](${{ github.server_url }}/${{ github.repository }}/actions/workflows/create-configlet-sync-issues.yml) workflow._ + ISSUE_BODY_EOF + + # Check for an existing open child issue + existing=$(gh issue list \ + --repo "$repo" \ + --search "is:issue is:open in:title \"${child_title}\"" \ + --json number \ + --jq '.[0].number // empty') + + if [[ -z "$existing" ]]; then + printf "Creating child issue for: %s\n" "$slug" + issue_url=$(gh issue create \ + --repo "$repo" \ + --title "$child_title" \ + --body-file "$body_file" \ + --label "x:knowledge/elementary,x:module/practice-exercise") + new_number=$(basename "$issue_url") + printf "Created #%s for %s\n" "$new_number" "$slug" + else + printf "Updating existing child issue #%s for: %s\n" "$existing" "$slug" + gh issue edit "$existing" \ + --repo "$repo" \ + --body-file "$body_file" + fi + + rm -f "$body_file" + done + + - name: All tests synced — nothing to do + if: steps.sync.outputs.exit_code == '0' + run: printf "✅ All exercises are fully synced. No child issues needed.\n" diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index ad374a4f0..867890a6c 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -11,44 +11,90 @@ on: workflow_dispatch: jobs: - build: - name: Check if tests compile cleanly with starter sources + build-all: + name: Check if all exercise tests compile cleanly with starter sources + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - - name: Set up JDK 1.17 - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + - name: Set up JDK 25 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 with: - java-version: 17 + java-version: 25 distribution: "temurin" - name: Check if tests compile cleanly with starter sources run: ./gradlew compileStarterTestJava --continue working-directory: exercises - lint: - name: Lint Java files using Checkstyle + build-changed: + name: Check if changed exercise tests compile cleanly with starter sources + if: github.event_name == 'pull_request' + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + fetch-depth: 0 + - name: Set up JDK 25 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 + with: + java-version: 25 + distribution: "temurin" + - name: Check if changed exercise tests compile cleanly + run: bin/build-changed-exercise + + lint-all: + name: Lint all exercises using Checkstyle + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - - name: Set up JDK 1.17 - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + - name: Set up JDK 25 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 with: - java-version: 17 + java-version: 25 distribution: "temurin" - name: Run checkstyle run: ./gradlew check --exclude-task test --continue working-directory: exercises + lint-changed: + name: Lint changed exercises using Checkstyle + if: github.event_name == 'pull_request' + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + fetch-depth: 0 + - name: Set up JDK 25 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 + with: + java-version: 25 + distribution: "temurin" + - name: Lint changed exercises + run: bin/lint-changed-exercise + test-all: name: Test all exercises using java-test-runner if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - name: Test all exercises using java-test-runner run: bin/test-with-test-runner + - name: Print summary + run: | + if [ -f exercises/build/summary.txt ]; then + echo "===== TEST SUMMARY =====" + cat exercises/build/summary.txt + echo "========================" + else + echo "===== ALL TESTS PASSED =====" + echo "No summary file was generated." + echo "=============================" + fi + if: always() - name: Archive test results - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: test-results path: exercises/**/build/results.json @@ -59,14 +105,28 @@ jobs: if: github.event_name == 'pull_request' runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with: fetch-depth: 0 - name: Test changed exercises using java-test-runner run: bin/test-changed-exercise + - name: Print summary + run: | + if [ -f exercises/build/summary.txt ]; then + echo "===== TEST SUMMARY =====" + cat exercises/build/summary.txt + echo "========================" + else + echo "===== ALL TESTS PASSED =====" + echo "No summary file was generated." + echo "=============================" + fi + if: always() - name: Archive test results - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: test-results - path: exercises/**/build/results.json + path: | + exercises/**/build/results.txt + exercises/**/build/results.json if: failure() diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index 81e5bbe77..9467459c7 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -17,6 +17,6 @@ jobs: name: Lint Markdown files runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - name: Lint markdown - uses: DavidAnson/markdownlint-cli2-action@992badcdf24e3b8eb7e87ff9287fe931bcb00c6e + uses: DavidAnson/markdownlint-cli2-action@6b51ade7a9e4a75a7ad929842dd298a3804ebe8b diff --git a/.github/workflows/run-configlet-sync.yml b/.github/workflows/run-configlet-sync.yml index b49cbffe8..832564a3a 100644 --- a/.github/workflows/run-configlet-sync.yml +++ b/.github/workflows/run-configlet-sync.yml @@ -8,3 +8,8 @@ on: jobs: call-gha-workflow: uses: exercism/github-actions/.github/workflows/configlet-sync.yml@main + + create-sync-issues: + needs: call-gha-workflow + uses: ./.github/workflows/create-configlet-sync-issues.yml + secrets: inherit diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de4283ca1..56151b2c9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -209,7 +209,7 @@ Each problem/submodule has three source sets: ### Update/sync Gradle versions -Please read [How to Update Gradle](../reference/how-to-update-gradle.md) +Please read [How to Update Gradle](reference/how-to-update-gradle.md) ## Contributing to Concept Exercises diff --git a/POLICIES.md b/POLICIES.md index 09d803f04..c324b98bf 100644 --- a/POLICIES.md +++ b/POLICIES.md @@ -24,7 +24,6 @@ Our policies are not set-in-stone. They represent directions chosen at a point i | | [Ignore noninitial tests](#ignore-noninitial-tests) | | | [Multiple file submissions](#multiple-file-submissions) | | | [Name test class after class under test](#name-test-class-after-class-under-test) | -| | [Add hint for the first exercises without starter implementation](#add-hint-for-the-first-exercises-without-starter-implementation) | | | [Reference tutorial in the first exercises](#reference-tutorial-in-the-first-exercises) | | | [Avoid returning null](#avoid-returning-null) | | | [Prefer AssertJ assertions](#prefer-assertj-assertions) | @@ -44,16 +43,14 @@ References: [[1](https://github.com/exercism/java/issues/177#issuecomment-261291 ### Starter implementations -> - Exercises of difficulty 4 or lower: provide stubs for all required constructors and methods. This means that you need to provide stubs for those constructors or methods that are necessary to pass all tests. E.g. stubs for private methods may be skipped. -> Stubs should include the following body: +> Provide stubs for all required constructors and methods. This means that you need to provide stubs for those constructors or methods that are necessary to pass all tests. E.g. stubs for private methods may be skipped. +> Stubs should include the following body: > -> ```java -> throw new UnsupportedOperationException("Delete this statement and write your own implementation."); -> ``` -> -> - Exercises of difficulty 5 or higher: copy the StubTemplate.java file (provided in [this template file](https://github.com/exercism/java/blob/main/resources/exercise-template/src/main/java/ExerciseName.java)) and rename it to fit the exercise. For example, for the exercise linked-list the file could be named LinkedList.java. Then either (1) add hints to the hints.md file (which gets merged into the README.md for the exercise) or (2) provide stubs as above for exercises that demand complicated method signatures. +> ```java +> throw new UnsupportedOperationException("Delete this statement and write your own implementation."); +> ``` -References: [[1](https://github.com/exercism/java/issues/178)], [[2](https://github.com/exercism/java/pull/683#discussion_r125506930)], [[3](https://github.com/exercism/java/issues/977)], [[4](https://github.com/exercism/java/issues/1721)] +Reference: [[1](https://github.com/exercism/java/issues/2133)] ### Avoid using final @@ -126,27 +123,14 @@ References: [[1](https://github.com/exercism/java/issues/395#issue-215734887)] References: [[1](https://github.com/exercism/java/issues/697)] -### Add hint for the first exercises without starter implementation - -> According to the starter implementation policy, any exercise with difficulty 4 or lower should have starter implementation. -> Any exercise with difficulty 5 or above will have no starter implementation (unless its signature is very complicated). -> This could be confusing to users when tackling their first exercise with difficulty 5 when they are used to starter implementation being provided. -> -> Therefore a hints.md file should be added to the .meta directory for every exercise with difficulty 5. -> This file should explain what they need to do when there is no starter implementation. -> The files should all be the same so you can copy it from any other exercise with difficulty 5, e.g. [flatten-array](https://github.com/exercism/java/tree/main/exercises/pratice/flatten-array/.meta/hints.md). -> -> We add the file to every exercise with difficulty 5 because the structure of the track means that we don't know which exercise will be the first one without starter implementation that a user will be faced with. - -References: [[1](https://github.com/exercism/java/issues/1075)] - ### Reference tutorial in the first exercises > The hello world exercise has an extensive tutorial on how to solve exercism exercises. > This tutorial would probably be useful to have as a reference when solving some of the other earlier exercises as well. -> Therefore any exercise with difficulty less than 3 should have a hints.md file which references [the hello world tutorial](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial). +> Therefore any exercise with difficulty less than 3 should have a instructions.append.md file which references [the hello world tutorial](https://github.com/exercism/java/blob/main/exercises/practice/hello-world/.docs/instructions.append.md#tutorial). References: [[1](https://github.com/exercism/java/issues/1389)] +Note: The PRs in the referenced issue uses hints.md, but this is now instructions.append.md (see [commit 52617354](https://github.com/exercism/java/commit/5261735435192b5b10535b2fcf41c81b638e5de5)) ### Avoid returning null diff --git a/bin/build-changed-exercise b/bin/build-changed-exercise new file mode 100755 index 000000000..9238b6744 --- /dev/null +++ b/bin/build-changed-exercise @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -eo pipefail + +source "$(dirname "$0")/common.sh" + +# If any Gradle build file changed, run the full suite and exit +check_gradle_changes \ + "cd exercises && ./gradlew compileStarterTestJava --continue" \ + "Gradle build files changed, running full build suite..." + +if [ -z "$changed_exercises" ]; then + echo "No relevant exercises changed, skipping compile checks." + exit 0 +fi + +# Print exercises +echo "Changed exercises detected:" +echo "$changed_exercises" +echo "----------------------------------------" + +# Run build compile checks +exit_code=0 +for dir in $changed_exercises; do + slug=$(basename "$dir") + + echo "========================================" + echo "=== Running compileStarterTestJava for $slug ===" + echo "========================================" + + if [[ $dir == exercises/practice/* ]]; then + ./exercises/gradlew -p exercises ":practice:$slug:compileStarterTestJava" || exit_code=1 + elif [[ $dir == exercises/concept/* ]]; then + ./exercises/gradlew -p exercises ":concept:$slug:compileStarterTestJava" || exit_code=1 + fi +done + +exit $exit_code diff --git a/bin/common.sh b/bin/common.sh new file mode 100755 index 000000000..9a84eb6d8 --- /dev/null +++ b/bin/common.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -eo pipefail + +# Determine the base branch of the PR +BASE_BRANCH=${GITHUB_BASE_REF:-main} + +# Fetch full history for proper diff +git fetch origin "$BASE_BRANCH" + +# Compute merge base +MERGE_BASE=$(git merge-base HEAD origin/"$BASE_BRANCH") + +# Get changed files relative to merge base +changed_files=$(git diff --name-only "$MERGE_BASE" HEAD) + +# Function to check if Gradle build files changed and run a command +check_gradle_changes() { + local command="$1" + local message="$2" + + if echo "$changed_files" | grep -qE '(\.gradle|gradlew|\.bat|settings\.gradle|gradle-wrapper\.(properties|jar))$'; then + echo "$message" + eval "$command" + exit 0 + fi +} + +# Extract unique exercise directories +get_changed_exercises() { + echo "$changed_files" | \ + grep -E '^exercises/(practice|concept)/[^/]+/.+\.java$' | \ + cut -d/ -f1-3 | sort -u || true +} + +# Variable for reuse +changed_exercises=$(get_changed_exercises) diff --git a/bin/lint-changed-exercise b/bin/lint-changed-exercise new file mode 100755 index 000000000..bbb6efc26 --- /dev/null +++ b/bin/lint-changed-exercise @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -eo pipefail + +source "$(dirname "$0")/common.sh" + +# If any Gradle build file changed, run the full suite and exit +check_gradle_changes \ + "cd exercises && ./gradlew check --exclude-task test --continue" \ + "Gradle build files changed, running full lint suite..." + +if [ -z "$changed_exercises" ]; then + echo "No relevant exercises changed, skipping linting." + exit 0 +fi + +# Print exercises +echo "Changed exercises detected:" +echo "$changed_exercises" +echo "----------------------------------------" + +# Run lint checks +exit_code=0 +for dir in $changed_exercises; do + slug=$(basename "$dir") + + echo "========================================" + echo "=== Running checkstyle for $slug ===" + echo "========================================" + + if [[ $dir == exercises/practice/* ]]; then + ./exercises/gradlew -p exercises ":practice:$slug:check" --exclude-task test || exit_code=1 + elif [[ $dir == exercises/concept/* ]]; then + ./exercises/gradlew -p exercises ":concept:$slug:check" --exclude-task test || exit_code=1 + fi +done + +exit $exit_code diff --git a/bin/test-changed-exercise b/bin/test-changed-exercise index debefeba3..4e71b25a4 100755 --- a/bin/test-changed-exercise +++ b/bin/test-changed-exercise @@ -1,29 +1,12 @@ #!/usr/bin/env bash set -eo pipefail -# Determine the base branch of the PR -BASE_BRANCH=${GITHUB_BASE_REF:-main} - -# Fetch full history for proper diff -git fetch origin "$BASE_BRANCH" - -# Compute merge base -MERGE_BASE=$(git merge-base HEAD origin/"$BASE_BRANCH") - -# Get changed files relative to merge base -changed_files=$(git diff --name-only "$MERGE_BASE" HEAD) +source "$(dirname "$0")/common.sh" # If any Gradle build file changed, run the full suite and exit -if echo "$changed_files" | grep -qE '\.(gradle|gradlew|bat)$|settings\.gradle'; then - echo "Gradle build files changed, running full test suite..." - ./bin/test-with-test-runner - exit 0 -fi - -# Extract unique exercise directories -changed_exercises=$(echo "$changed_files" | \ - grep -E '^exercises/(practice|concept)/[^/]+/.+\.java$' | \ - cut -d/ -f1-3 | sort -u) +check_gradle_changes \ + "./bin/test-with-test-runner" \ + "Gradle build files changed, running full test suite..." if [ -z "$changed_exercises" ]; then echo "No relevant exercises changed, skipping tests." @@ -35,7 +18,12 @@ echo "Changed exercises detected:" echo "$changed_exercises" echo "----------------------------------------" +summary_dir="exercises/build" +summary_file="${summary_dir}/summary.txt" +mkdir -p "$summary_dir" + # Run tests +exit_code=0 for dir in $changed_exercises; do slug=$(basename "$dir") @@ -43,9 +31,31 @@ for dir in $changed_exercises; do echo "=== Running tests for $slug ===" echo "========================================" + results_path="$dir/build/results.txt" + mkdir -p "$(dirname "$results_path")" + if [[ $dir == exercises/practice/* ]]; then - ./exercises/gradlew -p exercises ":practice:$slug:test" + ./exercises/gradlew -p exercises ":practice:$slug:test" 2>&1 | tee "$results_path" || true elif [[ $dir == exercises/concept/* ]]; then - ./exercises/gradlew -p exercises ":concept:$slug:test" + ./exercises/gradlew -p exercises ":concept:$slug:test" 2>&1 | tee "$results_path" || true fi + + # Detect failure + if grep -q "FAILED" "$results_path"; then + exit_code=1 + + # Determine practice/slug or concept/slug + relative_path=$(echo "$dir" | sed 's|^exercises/||') + + # Create summary.txt with header only on first failure + if [ ! -f "$summary_file" ]; then + echo "The following exercises have test failures or test errors:" > "$summary_file" + fi + + # Append the correct path (practice/slug or concept/slug) + echo "$relative_path" >> "$summary_file" + fi + done + +exit $exit_code \ No newline at end of file diff --git a/bin/test-deprecated-exercises b/bin/test-deprecated-exercises new file mode 100755 index 000000000..5260d6b6c --- /dev/null +++ b/bin/test-deprecated-exercises @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -eo pipefail + +# Determine the base branch of the PR +BASE_BRANCH=${GITHUB_BASE_REF:-main} + +# Fetch full history for proper diff +git fetch origin "$BASE_BRANCH" + +# Compute merge base +MERGE_BASE=$(git merge-base HEAD origin/"$BASE_BRANCH") + +# Get changed files relative to merge base +changed_files=$(git diff --name-only "$MERGE_BASE" HEAD) + +# Extract unique exercise directories +changed_exercises=$(echo "$changed_files" | grep -E '^exercises/(practice|concept)/' || true) +changed_exercises=$(echo "$changed_exercises" | cut -d/ -f1-3 | sort -u) + +# Early exit if no exercise changed +if [ -z "$changed_exercises" ]; then + echo "No exercises changed!" + exit 0 +fi + +# Load deprecated exercises from config.json +deprecated_exercises=$(jq -r ' + [ + (.exercises.concept[]? | select(.status=="deprecated") | "exercises/concept/" + .slug), + (.exercises.practice[]? | select(.status=="deprecated") | "exercises/practice/" + .slug) + ] | .[] +' config.json) + +# Check for deprecated ones +for ex in $changed_exercises; do + if echo "$deprecated_exercises" | grep -qx "$ex"; then + echo "❌ Deprecated exercise changed: $ex" + exit 1 + fi +done + +echo "✅ No deprecated exercises changed!" diff --git a/bin/test-with-test-runner b/bin/test-with-test-runner index eed2d74b0..5e5dc8889 100755 --- a/bin/test-with-test-runner +++ b/bin/test-with-test-runner @@ -12,6 +12,10 @@ docker pull exercism/java-test-runner exit_code=0 +summary_dir="exercises/build" +summary_file="${summary_dir}/summary.txt" +mkdir -p "$summary_dir" + function run_test_runner() { local slug=$1 local solution_dir=$2 @@ -56,6 +60,18 @@ function verify_exercise() { if [[ $(jq -r '.status' "${results_file}") != "pass" ]]; then echo "${slug}: ${implementation_file_key} solution did not pass the tests" + + # Determine practice/slug or concept/slug + local relative_path=$(echo "$dir" | sed -E 's|.*/exercises/||') + + # Create summary.txt with header only on first failure + if [ ! -f "$summary_file" ]; then + echo "The following exercises have test failures or test errors:" > "$summary_file" + fi + + # Append the correct path (practice/slug or concept/slug) + echo "$relative_path" >> "$summary_file" + exit_code=1 fi diff --git a/concepts/datetime/.meta/config.json b/concepts/datetime/.meta/config.json index f68620354..e6bd977c0 100644 --- a/concepts/datetime/.meta/config.json +++ b/concepts/datetime/.meta/config.json @@ -1,5 +1,9 @@ { "blurb": "There are several classes in Java to work with dates and time.", - "authors": ["sanderploegsma"], - "contributors": [] + "authors": [ + "sanderploegsma" + ], + "contributors": [ + "kahgoh" + ] } diff --git a/concepts/datetime/about.md b/concepts/datetime/about.md index 8ab1fbad6..ebeb1b3a3 100644 --- a/concepts/datetime/about.md +++ b/concepts/datetime/about.md @@ -118,7 +118,18 @@ printer.format(date); // => "December 3, 2007" ``` +A [locale][locale] can also be specified when creating the custom format to format and parse for different regions: + +```java +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date); +// => décembre 3, 2007 + +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date); +// => dezembro 3, 2007 +``` + [iso-8601]: https://en.wikipedia.org/wiki/ISO_8601 [localdate-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html [localdatetime-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html +[locale]: https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html [datetimeformatter-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html diff --git a/concepts/datetime/introduction.md b/concepts/datetime/introduction.md index 2b9513189..d4fbd5960 100644 --- a/concepts/datetime/introduction.md +++ b/concepts/datetime/introduction.md @@ -86,4 +86,14 @@ printer.format(date); // => "December 3, 2007" ``` +A locale can also be specified when creating the custom format to format and parse for different regions: + +```java +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date); +// => décembre 3, 2007 + +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date); +// => dezembro 3, 2007 +``` + [iso-8601]: https://en.wikipedia.org/wiki/ISO_8601 diff --git a/concepts/nullability/about.md b/concepts/nullability/about.md index 0c12d8b4e..b20b77b35 100644 --- a/concepts/nullability/about.md +++ b/concepts/nullability/about.md @@ -28,7 +28,7 @@ Whilst accessing a reference variable which has a value of `null` will compile f int[] arr = null; // Throws NullPointerException at runtime -arr.Length; +arr.length; ``` A [`NullPointerException` is thrown][null-pointer-exception] when trying to access a reference variable which is null but requires an object. diff --git a/config.json b/config.json index 484d807d0..cfa24a7a8 100644 --- a/config.json +++ b/config.json @@ -95,7 +95,7 @@ "if-else-statements", "switch-statement" ], - "status": "beta" + "status": "active" }, { "slug": "squeaky-clean", @@ -233,7 +233,8 @@ "strings", "switch-statement", "constructors" - ] + ], + "status": "active" }, { "slug": "tim-from-marketing", @@ -245,7 +246,8 @@ "prerequisites": [ "if-else-statements", "strings" - ] + ], + "status": "active" }, { "slug": "captains-log", @@ -258,7 +260,8 @@ "arrays", "numbers", "strings" - ] + ], + "status": "active" }, { "slug": "booking-up-for-beauty", @@ -270,7 +273,8 @@ "prerequisites": [ "numbers", "strings" - ] + ], + "status": "active" }, { "slug": "wizards-and-warriors-2", @@ -295,7 +299,8 @@ ], "prerequisites": [ "numbers" - ] + ], + "status": "active" }, { "slug": "gotta-snatch-em-all", @@ -308,7 +313,7 @@ "lists", "generic-types" ], - "status": "beta" + "status": "active" }, { "slug": "international-calling-connoisseur", @@ -321,7 +326,8 @@ "classes", "foreach-loops", "generic-types" - ] + ], + "status": "active" } ], "practice": [ @@ -799,6 +805,16 @@ ], "difficulty": 4 }, + { + "slug": "prism", + "name": "Prism", + "uuid": "1fca8759-0236-493c-a4ef-2807cb33fd2b", + "practices": [], + "prerequisites": [ + "lists" + ], + "difficulty": 4 + }, { "slug": "proverb", "name": "Proverb", @@ -981,7 +997,7 @@ "practices": [], "prerequisites": [ "arrays", - "if-statements" + "if-else-statements" ], "difficulty": 5 }, @@ -1211,6 +1227,20 @@ ], "difficulty": 6 }, + { + "slug": "baffling-birthdays", + "name": "Baffling Birthdays", + "uuid": "b534049a-5920-4906-9091-0fa6d81a3636", + "practices": [], + "prerequisites": [ + "for-loops", + "lists", + "sets", + "randomness", + "datetime" + ], + "difficulty": 6 + }, { "slug": "bank-account", "name": "Bank Account", @@ -1261,6 +1291,19 @@ ], "difficulty": 6 }, + { + "slug": "camicia", + "name": "Camicia", + "uuid": "b4f7c3b0-6d3c-45e2-a328-05e09c7467f4", + "practices": [], + "prerequisites": [ + "strings", + "for-loops", + "arrays", + "if-else-statements" + ], + "difficulty": 6 + }, { "slug": "etl", "name": "ETL", diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 239409351..57cf6d012 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -9,7 +9,7 @@ Here at Exercism we recommend using [Eclipse Temurin by Adoptium][adoptium]. ## Supported Java versions -Exercism's Java track supports Java 21 LTS and earlier. +Exercism's Java track supports Java 25 LTS and earlier. ## Installing Eclipse Temurin diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index 42df6a4b0..e221cc3db 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -2,5 +2,5 @@ - [Stack Overflow](http://stackoverflow.com/questions/tagged/java). - [The Java subreddit](https://www.reddit.com/r/java) -- [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html) +- [Official Java documentation](https://docs.oracle.com/en/java/javase/25/docs/api/index.html) - [Java Programming Books](https://github.com/EbookFoundation/free-programming-books/blob/main/books/free-programming-books-langs.md#java) diff --git a/exercises/build.gradle b/exercises/build.gradle index 734815214..fbadb5369 100644 --- a/exercises/build.gradle +++ b/exercises/build.gradle @@ -78,8 +78,8 @@ subprojects { // configuration of the linter checkstyle { - toolVersion '10.7.0' - configFile file("checkstyle.xml") + toolVersion = '10.7.0' + configFile = file("$rootDir/checkstyle.xml") sourceSets = [project.sourceSets.main, project.sourceSets.test] } diff --git a/exercises/checkstyle.xml b/exercises/checkstyle.xml index aee09b5d8..8746c0e28 100644 --- a/exercises/checkstyle.xml +++ b/exercises/checkstyle.xml @@ -155,7 +155,7 @@ page at http://checkstyle.sourceforge.net/config.html --> - + diff --git a/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/annalyns-infiltration/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/annalyns-infiltration/gradlew b/exercises/concept/annalyns-infiltration/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/annalyns-infiltration/gradlew +++ b/exercises/concept/annalyns-infiltration/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/annalyns-infiltration/gradlew.bat b/exercises/concept/annalyns-infiltration/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/annalyns-infiltration/gradlew.bat +++ b/exercises/concept/annalyns-infiltration/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java b/exercises/concept/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java index 4f7fe3864..7514451bf 100644 --- a/exercises/concept/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java +++ b/exercises/concept/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java @@ -9,7 +9,7 @@ public class AnnalynsInfiltrationTest { @Test @Tag("task:1") @DisplayName("The canFastAttack method returns false when knight is awake") - public void cannot_execute_fast_attack_if_knight_is_awake() { + public void cannotExecuteFastAttackIfKnightIsAwake() { boolean knightIsAwake = true; assertThat(AnnalynsInfiltration.canFastAttack(knightIsAwake)).isFalse(); } @@ -17,7 +17,7 @@ public void cannot_execute_fast_attack_if_knight_is_awake() { @Test @Tag("task:1") @DisplayName("The canFastAttack method returns true when knight is sleeping") - public void can_execute_fast_attack_if_knight_is_sleeping() { + public void canExecuteFastAttackIfKnightIsSleeping() { boolean knightIsAwake = false; assertThat(AnnalynsInfiltration.canFastAttack(knightIsAwake)).isTrue(); } @@ -25,7 +25,7 @@ public void can_execute_fast_attack_if_knight_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns false when everyone is sleeping") - public void cannot_spy_if_everyone_is_sleeping() { + public void cannotSpyIfEveryoneIsSleeping() { boolean knightIsAwake = false; boolean archerIsAwake = false; boolean prisonerIsAwake = false; @@ -35,7 +35,7 @@ public void cannot_spy_if_everyone_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when everyone but knight is sleeping") - public void can_spy_if_everyone_but_knight_is_sleeping() { + public void canSpyIfEveryoneButKnightIsSleeping() { boolean knightIsAwake = true; boolean archerIsAwake = false; boolean prisonerIsAwake = false; @@ -45,7 +45,7 @@ public void can_spy_if_everyone_but_knight_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when everyone but archer is sleeping") - public void can_spy_if_everyone_but_archer_is_sleeping() { + public void canSpyIfEveryoneButArcherIsSleeping() { boolean knightIsAwake = false; boolean archerIsAwake = true; boolean prisonerIsAwake = false; @@ -55,7 +55,7 @@ public void can_spy_if_everyone_but_archer_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when everyone but prisoner is sleeping") - public void can_spy_if_everyone_but_prisoner_is_sleeping() { + public void canSpyIfEveryoneButPrisonerIsSleeping() { boolean knightIsAwake = false; boolean archerIsAwake = false; boolean prisonerIsAwake = true; @@ -65,7 +65,7 @@ public void can_spy_if_everyone_but_prisoner_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when only knight is sleeping") - public void can_spy_if_only_knight_is_sleeping() { + public void canSpyIfOnlyKnightIsSleeping() { boolean knightIsAwake = false; boolean archerIsAwake = true; boolean prisonerIsAwake = true; @@ -75,7 +75,7 @@ public void can_spy_if_only_knight_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when only archer is sleeping") - public void can_spy_if_only_archer_is_sleeping() { + public void canSpyIfOnlyArcherIsSleeping() { boolean knightIsAwake = true; boolean archerIsAwake = false; boolean prisonerIsAwake = true; @@ -85,7 +85,7 @@ public void can_spy_if_only_archer_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when only prisoner is sleeping") - public void can_spy_if_only_prisoner_is_sleeping() { + public void canSpyIfOnlyPrisonerIsSleeping() { boolean knightIsAwake = true; boolean archerIsAwake = true; boolean prisonerIsAwake = false; @@ -95,7 +95,7 @@ public void can_spy_if_only_prisoner_is_sleeping() { @Test @Tag("task:2") @DisplayName("The canSpy method returns true when everyone is awake") - public void can_spy_if_everyone_is_awake() { + public void canSpyIfEveryoneIsAwake() { boolean knightIsAwake = true; boolean archerIsAwake = true; boolean prisonerIsAwake = true; @@ -105,7 +105,7 @@ public void can_spy_if_everyone_is_awake() { @Test @Tag("task:3") @DisplayName("The canSignalPrisoner method returns true when prisoner is awake and archer is sleeping") - public void can_signal_prisoner_if_archer_is_sleeping_and_prisoner_is_awake() { + public void canSignalPrisonerIfArcherIsSleepingAndPrisonerIsAwake() { boolean archerIsAwake = false; boolean prisonerIsAwake = true; assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isTrue(); @@ -114,7 +114,7 @@ public void can_signal_prisoner_if_archer_is_sleeping_and_prisoner_is_awake() { @Test @Tag("task:3") @DisplayName("The canSignalPrisoner method returns false when prisoner is sleeping and archer is awake") - public void cannot_signal_prisoner_if_archer_is_awake_and_prisoner_is_sleeping() { + public void cannotSignalPrisonerIfArcherIsAwakeAndPrisonerIsSleeping() { boolean archerIsAwake = true; boolean prisonerIsAwake = false; assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse(); @@ -123,7 +123,7 @@ public void cannot_signal_prisoner_if_archer_is_awake_and_prisoner_is_sleeping() @Test @Tag("task:3") @DisplayName("The canSignalPrisoner method returns false when both prisoner and archer are sleeping") - public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_sleeping() { + public void cannotSignalPrisonerIfArcherAndPrisonerAreBothSleeping() { boolean archerIsAwake = false; boolean prisonerIsAwake = false; assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse(); @@ -132,7 +132,7 @@ public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_sleeping() { @Test @Tag("task:3") @DisplayName("The canSignalPrisoner method returns false when both prisoner and archer are awake") - public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_awake() { + public void cannotSignalPrisonerIfArcherAndPrisonerAreBothAwake() { boolean archerIsAwake = true; boolean prisonerIsAwake = true; assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse(); @@ -141,7 +141,7 @@ public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_awake() { @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when everyone is awake and pet dog is present") - public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_present() { + public void cannotReleasePrisonerIfEveryoneIsAwakeAndPetDogIsPresent() { boolean knightIsAwake = true; boolean archerIsAwake = true; boolean prisonerIsAwake = true; @@ -153,7 +153,7 @@ public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_present( @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when everyone is awake and pet dog is absent") - public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfEveryoneIsAwakeAndPetDogIsAbsent() { boolean knightIsAwake = true; boolean archerIsAwake = true; boolean prisonerIsAwake = true; @@ -165,7 +165,7 @@ public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_absent() @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns true when everyone is sleeping and pet dog is present") - public void can_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_present() { + public void canReleasePrisonerIfEveryoneIsAsleepAndPetDogIsPresent() { boolean knightIsAwake = false; boolean archerIsAwake = false; boolean prisonerIsAwake = false; @@ -177,7 +177,7 @@ public void can_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_present() @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when everyone is sleeping and pet dog is absent") - public void cannot_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfEveryoneIsAsleepAndPetDogIsAbsent() { boolean knightIsAwake = false; boolean archerIsAwake = false; boolean prisonerIsAwake = false; @@ -189,7 +189,7 @@ public void cannot_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_absent( @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns true when only prisoner is awake and pet dog is present") - public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_present() { + public void canReleasePrisonerIfOnlyPrisonerIsAwakeAndPetDogIsPresent() { boolean knightIsAwake = false; boolean archerIsAwake = false; boolean prisonerIsAwake = true; @@ -201,7 +201,7 @@ public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_presen @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns true when only prisoner is awake and pet dog is absent") - public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_absent() { + public void canReleasePrisonerIfOnlyPrisonerIsAwakeAndPetDogIsAbsent() { boolean knightIsAwake = false; boolean archerIsAwake = false; boolean prisonerIsAwake = true; @@ -213,7 +213,7 @@ public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_absent @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only archer is awake and pet dog is present") - public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_present() { + public void cannotReleasePrisonerIfOnlyArcherIsAwakeAndPetDogIsPresent() { boolean knightIsAwake = false; boolean archerIsAwake = true; boolean prisonerIsAwake = false; @@ -225,7 +225,7 @@ public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_prese @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only archer is awake and pet dog is absent") - public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfOnlyArcherIsAwakeAndPetDogIsAbsent() { boolean knightIsAwake = false; boolean archerIsAwake = true; boolean prisonerIsAwake = false; @@ -237,7 +237,7 @@ public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_absen @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns true when only knight is awake and pet dog is present") - public void can_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_present() { + public void canReleasePrisonerIfOnlyKnightIsAwakeAndPetDogIsPresent() { boolean knightIsAwake = true; boolean archerIsAwake = false; boolean prisonerIsAwake = false; @@ -249,7 +249,7 @@ public void can_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_present( @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only knight is awake and pet dog is absent") - public void cannot_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfOnlyKnightIsAwakeAndPetDogIsAbsent() { boolean knightIsAwake = true; boolean archerIsAwake = false; boolean prisonerIsAwake = false; @@ -261,7 +261,7 @@ public void cannot_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_absen @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only knight is sleeping and pet dog is present") - public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_present() { + public void cannotReleasePrisonerIfOnlyKnightIsAsleepAndPetDogIsPresent() { boolean knightIsAwake = false; boolean archerIsAwake = true; boolean prisonerIsAwake = true; @@ -273,7 +273,7 @@ public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_pres @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only knight is sleeping and pet dog is absent") - public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfOnlyKnightIsAsleepAndPetDogIsAbsent() { boolean knightIsAwake = false; boolean archerIsAwake = true; boolean prisonerIsAwake = true; @@ -285,7 +285,7 @@ public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_abse @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns true when only archer is sleeping and pet dog is present") - public void can_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_present() { + public void canReleasePrisonerIfOnlyArcherIsAsleepAndPetDogIsPresent() { boolean knightIsAwake = true; boolean archerIsAwake = false; boolean prisonerIsAwake = true; @@ -297,7 +297,7 @@ public void can_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_present @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only archer is sleeping and pet dog is absent") - public void cannot_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfOnlyArcherIsAsleepAndPetDogIsAbsent() { boolean knightIsAwake = true; boolean archerIsAwake = false; boolean prisonerIsAwake = true; @@ -309,7 +309,7 @@ public void cannot_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_abse @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only prisoner is sleeping and pet dog is present") - public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_present() { + public void cannotReleasePrisonerIfOnlyPrisonerIsAsleepAndPetDogIsPresent() { boolean knightIsAwake = true; boolean archerIsAwake = true; boolean prisonerIsAwake = false; @@ -321,7 +321,7 @@ public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_pr @Test @Tag("task:4") @DisplayName("The canFreePrisoner method returns false when only prisoner is sleeping and pet dog is absent") - public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_absent() { + public void cannotReleasePrisonerIfOnlyPrisonerIsAsleepAndPetDogIsAbsent() { boolean knightIsAwake = true; boolean archerIsAwake = true; boolean prisonerIsAwake = false; diff --git a/exercises/concept/bird-watcher/.meta/config.json b/exercises/concept/bird-watcher/.meta/config.json index d88246548..fcbd526bf 100644 --- a/exercises/concept/bird-watcher/.meta/config.json +++ b/exercises/concept/bird-watcher/.meta/config.json @@ -3,6 +3,9 @@ "samuelteixeiras", "ystromm" ], + "contributors": [ + "jagdish-15" + ], "files": { "solution": [ "src/main/java/BirdWatcher.java" diff --git a/exercises/concept/bird-watcher/.meta/src/reference/java/BirdWatcher.java b/exercises/concept/bird-watcher/.meta/src/reference/java/BirdWatcher.java index 027e38a4c..e0884d13e 100644 --- a/exercises/concept/bird-watcher/.meta/src/reference/java/BirdWatcher.java +++ b/exercises/concept/bird-watcher/.meta/src/reference/java/BirdWatcher.java @@ -6,7 +6,7 @@ public BirdWatcher(int[] birdsPerDay) { this.birdsPerDay = birdsPerDay.clone(); } - public int[] getLastWeek() { + public static int[] getLastWeek() { return new int[] { 0, 2, 5, 3, 7, 8, 4 }; } diff --git a/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/bird-watcher/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/bird-watcher/gradlew b/exercises/concept/bird-watcher/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/bird-watcher/gradlew +++ b/exercises/concept/bird-watcher/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/bird-watcher/gradlew.bat b/exercises/concept/bird-watcher/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/bird-watcher/gradlew.bat +++ b/exercises/concept/bird-watcher/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java b/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java index c19dd38e6..ccdd53ad2 100644 --- a/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java +++ b/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java @@ -6,7 +6,7 @@ public BirdWatcher(int[] birdsPerDay) { this.birdsPerDay = birdsPerDay.clone(); } - public int[] getLastWeek() { + public static int[] getLastWeek() { throw new UnsupportedOperationException("Please implement the BirdWatcher.getLastWeek() method"); } diff --git a/exercises/concept/bird-watcher/src/test/java/BirdWatcherTest.java b/exercises/concept/bird-watcher/src/test/java/BirdWatcherTest.java index 5b1746082..750329177 100644 --- a/exercises/concept/bird-watcher/src/test/java/BirdWatcherTest.java +++ b/exercises/concept/bird-watcher/src/test/java/BirdWatcherTest.java @@ -1,55 +1,43 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class BirdWatcherTest { - private static final int DAY1 = 0; - private static final int DAY2 = 2; - private static final int DAY3 = 5; - private static final int DAY4 = 3; - private static final int DAY5 = 7; - private static final int DAY6 = 8; - private static final int TODAY = 4; - - private BirdWatcher birdWatcher; - private final int[] lastWeek = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY}; - - @BeforeEach - public void setUp() { - birdWatcher = new BirdWatcher(lastWeek); - } - @Test @Tag("task:1") @DisplayName("The getLastWeek method correctly returns last week's counts") public void itTestGetLastWeek() { - assertThat(birdWatcher.getLastWeek()) - .containsExactly(DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY); + assertThat(BirdWatcher.getLastWeek()).isEqualTo(new int[] {0, 2, 5, 3, 7, 8, 4}); } @Test @Tag("task:2") @DisplayName("The getToday method correctly returns today's counts") public void itTestGetToday() { - assertThat(birdWatcher.getToday()).isEqualTo(TODAY); + int[] counts = new int[] {8, 8, 9, 5, 4, 7, 10}; + BirdWatcher birdWatcher = new BirdWatcher(counts); + assertThat(birdWatcher.getToday()).isEqualTo(10); } @Test @Tag("task:3") @DisplayName("The incrementTodaysCount method correctly increments today's counts") public void itIncrementTodaysCount() { + int[] counts = new int[] {8, 8, 9, 2, 1, 6, 4}; + BirdWatcher birdWatcher = new BirdWatcher(counts); birdWatcher.incrementTodaysCount(); - assertThat(birdWatcher.getToday()).isEqualTo(TODAY + 1); + assertThat(birdWatcher.getToday()).isEqualTo(5); } @Test @Tag("task:4") - @DisplayName("The hasDayWithoutBirds method returns true when day had no visits") + @DisplayName("The hasDayWithoutBirds method returns true when at least one day had no visits") public void itHasDayWithoutBirds() { + int[] counts = new int[] {5, 5, 4, 0, 7, 6, 7}; + BirdWatcher birdWatcher = new BirdWatcher(counts); assertThat(birdWatcher.hasDayWithoutBirds()).isTrue(); } @@ -57,7 +45,8 @@ public void itHasDayWithoutBirds() { @Tag("task:4") @DisplayName("The hasDayWithoutBirds method returns false when no day had zero visits") public void itShouldNotHaveDaysWithoutBirds() { - birdWatcher = new BirdWatcher(new int[]{1, 2, 5, 3, 7, 8, 4}); + int[] counts = new int[] {4, 5, 9, 10, 9, 4, 3}; + BirdWatcher birdWatcher = new BirdWatcher(counts); assertThat(birdWatcher.hasDayWithoutBirds()).isFalse(); } @@ -65,7 +54,8 @@ public void itShouldNotHaveDaysWithoutBirds() { @Tag("task:4") @DisplayName("The hasDayWithoutBirds method returns true if the last day has zero visits") public void itHasLastDayWithoutBirds() { - birdWatcher = new BirdWatcher(new int[]{1, 2, 5, 3, 7, 8, 0}); + int[] counts = new int[] {1, 2, 5, 3, 7, 8, 0}; + BirdWatcher birdWatcher = new BirdWatcher(counts); assertThat(birdWatcher.hasDayWithoutBirds()).isTrue(); } @@ -73,30 +63,50 @@ public void itHasLastDayWithoutBirds() { @Tag("task:5") @DisplayName("The getCountForFirstDays method returns correct visits' count for given number of days") public void itTestGetCountForFirstDays() { - assertThat(birdWatcher.getCountForFirstDays(4)).isEqualTo(DAY1 + DAY2 + DAY3 + DAY4); + int[] counts = new int[] {5, 9, 12, 6, 8, 8, 17}; + BirdWatcher birdWatcher = new BirdWatcher(counts); + assertThat(birdWatcher.getCountForFirstDays(4)).isEqualTo(32); } @Test @Tag("task:5") @DisplayName("The getCountForFirstDays method returns overall count when number of days is higher than array size") public void itTestGetCountForMoreDaysThanTheArraySize() { - assertThat(birdWatcher.getCountForFirstDays(10)) - .isEqualTo(DAY1 + DAY2 + DAY3 + DAY4 + DAY5 + DAY6 + TODAY); + int[] counts = new int[] {5, 9, 12, 6, 8, 8, 17}; + BirdWatcher birdWatcher = new BirdWatcher(counts); + assertThat(birdWatcher.getCountForFirstDays(10)).isEqualTo(65); + } + + @Test + @Tag("task:5") + @DisplayName("The incrementTodaysCount method adds one to getCountForFirstDays method") + public void itIncrementDoesNotChangeCountForOtherDays() { + int[] counts = new int[] {5, 1, 0, 4, 2, 3, 0}; + BirdWatcher birdWatcher = new BirdWatcher(counts); + + int countPriorIncrement = birdWatcher.getCountForFirstDays(7); + birdWatcher.incrementTodaysCount(); + int countAfterIncrement = birdWatcher.getCountForFirstDays(7); + + assertThat(countPriorIncrement).isEqualTo(15); + assertThat(countAfterIncrement).isEqualTo(16); } @Test @Tag("task:6") @DisplayName("The getBusyDays method returns the correct count of busy days") public void itTestGetCountForBusyDays() { - // DAY3, DAY5 and DAY6 are all >= 5 birds - assertThat(birdWatcher.getBusyDays()).isEqualTo(3); + int[] counts = new int[] {4, 9, 5, 7, 8, 8, 2}; + BirdWatcher birdWatcher = new BirdWatcher(counts); + assertThat(birdWatcher.getBusyDays()).isEqualTo(5); } @Test @Tag("task:6") @DisplayName("The getBusyDays method correctly returns zero in case of no busy days") public void itShouldNotHaveBusyDays() { - birdWatcher = new BirdWatcher(new int[]{1, 2, 3, 3, 2, 1, 4}); + int[] counts = new int[] {1, 2, 3, 3, 2, 1, 4}; + BirdWatcher birdWatcher = new BirdWatcher(counts); assertThat(birdWatcher.getBusyDays()).isEqualTo(0); } } diff --git a/exercises/concept/booking-up-for-beauty/.docs/introduction.md b/exercises/concept/booking-up-for-beauty/.docs/introduction.md index ed132331c..57768dafe 100644 --- a/exercises/concept/booking-up-for-beauty/.docs/introduction.md +++ b/exercises/concept/booking-up-for-beauty/.docs/introduction.md @@ -88,4 +88,14 @@ printer.format(date); // => "December 3, 2007" ``` +A locale can also be specified when creating the custom format to format and parse for different regions: + +```java +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date); +// => décembre 3, 2007 + +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date); +// => dezembro 3, 2007 +``` + [iso-8601]: https://en.wikipedia.org/wiki/ISO_8601 diff --git a/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/booking-up-for-beauty/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/booking-up-for-beauty/gradlew b/exercises/concept/booking-up-for-beauty/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/booking-up-for-beauty/gradlew +++ b/exercises/concept/booking-up-for-beauty/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/booking-up-for-beauty/gradlew.bat b/exercises/concept/booking-up-for-beauty/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/booking-up-for-beauty/gradlew.bat +++ b/exercises/concept/booking-up-for-beauty/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/calculator-conundrum/.meta/design.md b/exercises/concept/calculator-conundrum/.meta/design.md index 5163b002c..5134eb08a 100644 --- a/exercises/concept/calculator-conundrum/.meta/design.md +++ b/exercises/concept/calculator-conundrum/.meta/design.md @@ -18,3 +18,15 @@ - `conditionals-if`: know how to do conditional logic. - `switch-statement`: know how to work with a `switch` statement. + +## Analyzer + +This exercise could benefit from the following rules in the [analyzer]: + +- `essential`: Verify that the solution is using the try catch statement for the division. +- `actionable`: If the solution is wrapping all the code in a try catch statement, instruct the student to only use the `try catch` for the division statement +- `actionable`: If the solution uses only `if` statement, instruct the student that he/she can use the `switch case` statement to perform the operations. +- `informative`: If the solution does not throw the exception for `Operation cannot be null` and `Operation cannot be empty` at the beginning, suggest the fail-fast approach to the student. + Inform this way of implementation can be less error-prone and more readable as suggested by Martin Fowler: + +[analyzer]: https://github.com/exercism/java-analyzer diff --git a/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/calculator-conundrum/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/calculator-conundrum/gradlew b/exercises/concept/calculator-conundrum/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/calculator-conundrum/gradlew +++ b/exercises/concept/calculator-conundrum/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/calculator-conundrum/gradlew.bat b/exercises/concept/calculator-conundrum/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/calculator-conundrum/gradlew.bat +++ b/exercises/concept/calculator-conundrum/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/captains-log/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/captains-log/gradlew b/exercises/concept/captains-log/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/captains-log/gradlew +++ b/exercises/concept/captains-log/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/captains-log/gradlew.bat b/exercises/concept/captains-log/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/captains-log/gradlew.bat +++ b/exercises/concept/captains-log/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/cars-assemble/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/cars-assemble/gradlew b/exercises/concept/cars-assemble/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/cars-assemble/gradlew +++ b/exercises/concept/cars-assemble/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/cars-assemble/gradlew.bat b/exercises/concept/cars-assemble/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/cars-assemble/gradlew.bat +++ b/exercises/concept/cars-assemble/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/football-match-reports/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/football-match-reports/gradlew b/exercises/concept/football-match-reports/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/football-match-reports/gradlew +++ b/exercises/concept/football-match-reports/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/football-match-reports/gradlew.bat b/exercises/concept/football-match-reports/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/football-match-reports/gradlew.bat +++ b/exercises/concept/football-match-reports/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java b/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java index 7c45eb1a7..82024e6f5 100644 --- a/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java +++ b/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java @@ -9,28 +9,28 @@ public class FootballMatchReportsTest { @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of player with shirt number 1") - public void test_goal() { + public void testGoal() { assertThat(FootballMatchReports.onField(1)).isEqualTo("goalie"); } @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of player with shirt number 2") - public void test_left_back() { + public void testLeftBack() { assertThat(FootballMatchReports.onField(2)).isEqualTo("left back"); } @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of player with shirt number 5") - public void test_right_back() { + public void testRightBack() { assertThat(FootballMatchReports.onField(5)).isEqualTo("right back"); } @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of players with shirt numbers 3 and 4") - public void test_center_back() { + public void testCenterBack() { assertThat(FootballMatchReports.onField(3)).isEqualTo("center back"); assertThat(FootballMatchReports.onField(4)).isEqualTo("center back"); } @@ -38,7 +38,7 @@ public void test_center_back() { @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of players with shirt numbers 6, 7 and 8") - public void test_midfielder() { + public void testMidfielder() { assertThat(FootballMatchReports.onField(6)).isEqualTo("midfielder"); assertThat(FootballMatchReports.onField(7)).isEqualTo("midfielder"); assertThat(FootballMatchReports.onField(8)).isEqualTo("midfielder"); @@ -47,35 +47,35 @@ public void test_midfielder() { @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of player with shirt number 9") - public void test_left_wing() { + public void testLeftWing() { assertThat(FootballMatchReports.onField(9)).isEqualTo("left wing"); } @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of player with shirt number 10") - public void test_striker() { + public void testStriker() { assertThat(FootballMatchReports.onField(10)).isEqualTo("striker"); } @Test @Tag("task:1") @DisplayName("The onField method returns the correct description of player with shirt number 11") - public void test_right_wing() { + public void testRightWing() { assertThat(FootballMatchReports.onField(11)).isEqualTo("right wing"); } @Test @Tag("task:2") @DisplayName("The onField method returns 'invalid' for invalid shirt number") - public void test_exception() { + public void testException() { assertThat(FootballMatchReports.onField(13)).isEqualTo("invalid"); } @Test @Tag("task:2") @DisplayName("The onField method returns 'invalid' for negative shirt number") - public void test_exception_negative_number() { + public void testExceptionNegativeNumber() { assertThat(FootballMatchReports.onField(-1)).isEqualTo("invalid"); } } diff --git a/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/gotta-snatch-em-all/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/gotta-snatch-em-all/gradlew b/exercises/concept/gotta-snatch-em-all/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/gotta-snatch-em-all/gradlew +++ b/exercises/concept/gotta-snatch-em-all/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/gotta-snatch-em-all/gradlew.bat b/exercises/concept/gotta-snatch-em-all/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/gotta-snatch-em-all/gradlew.bat +++ b/exercises/concept/gotta-snatch-em-all/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/gotta-snatch-em-all/src/test/java/GottaSnatchEmAllTest.java b/exercises/concept/gotta-snatch-em-all/src/test/java/GottaSnatchEmAllTest.java index d2466e8a4..12b9961fd 100644 --- a/exercises/concept/gotta-snatch-em-all/src/test/java/GottaSnatchEmAllTest.java +++ b/exercises/concept/gotta-snatch-em-all/src/test/java/GottaSnatchEmAllTest.java @@ -182,8 +182,8 @@ void testCommonCardsSingleCollection() { void testCommonCardsMultipleCollections() { List> collections = List.of( Set.of("Veevee", "Wigglycream", "Mayofried"), - Set.of("Gyros", "Wigglycream", "Shazam"), - Set.of("Cooltentbro", "Mayofried", "Wigglycream") + Set.of("Cooltentbro", "Mayofried", "Wigglycream"), + Set.of("Gyros", "Wigglycream", "Shazam") ); Set expected = Set.of("Wigglycream"); assertThat(GottaSnatchEmAll.commonCards(collections)).isEqualTo(expected); diff --git a/exercises/concept/international-calling-connoisseur/.docs/instructions.md b/exercises/concept/international-calling-connoisseur/.docs/instructions.md index e8f728f0f..10b82546f 100644 --- a/exercises/concept/international-calling-connoisseur/.docs/instructions.md +++ b/exercises/concept/international-calling-connoisseur/.docs/instructions.md @@ -31,7 +31,7 @@ dialingCodes.setDialingCode(679, "Fiji"); ## 3. Lookup a dialing code's country -Implement the `getCountry` method that takes a map of dialing codes and a dialing code and returns the country name with the dialing code. +Implement the `getCountry` method that takes a dialing code and returns the country name with the dialing code. ```java DialingCodes dialingCodes = new DialingCodes(); @@ -51,7 +51,7 @@ However, unlike `setDialingCode`, it does nothing if the dialing code or the cou DialingCodes dialingCodes = new DialingCodes(); dialingCodes.addNewDialingCode(32, "Belgium"); dialingCodes.addNewDialingCode(379, "Vatican City"); -// => { 39 => "Italy", 379 => "Vatican City" } +// => { 32 => "Belgium", 379 => "Vatican City" } dialingCodes.addNewDialingCode(32, "Other"); @@ -63,7 +63,7 @@ dialingCodes.addNewDialingCode(39, "Vatican City"); Its rare, but mistakes can be made. To correct the mistake, we will need to know what dialing code the country is currently mapped to. -To find which dialing code needs to be corrected, implement the `findDialingCode` method that takes in a map of dialing codes and a country and returns the country's dialing code. +To find which dialing code needs to be corrected, implement the `findDialingCode` method that takes a country and returns the country's dialing code. Return `null` if the country is _not_ in the map. ```java diff --git a/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/international-calling-connoisseur/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/international-calling-connoisseur/gradlew b/exercises/concept/international-calling-connoisseur/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/international-calling-connoisseur/gradlew +++ b/exercises/concept/international-calling-connoisseur/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/international-calling-connoisseur/gradlew.bat b/exercises/concept/international-calling-connoisseur/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/international-calling-connoisseur/gradlew.bat +++ b/exercises/concept/international-calling-connoisseur/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/jedliks-toy-car/.meta/design.md b/exercises/concept/jedliks-toy-car/.meta/design.md index f99cef1f7..2a1b40eb1 100644 --- a/exercises/concept/jedliks-toy-car/.meta/design.md +++ b/exercises/concept/jedliks-toy-car/.meta/design.md @@ -28,3 +28,15 @@ - `strings`: know how to do basic string interpolation. - `numbers`: know how to compare numbers. - `conditionals`: know how to do conditional logic. + +## Analyzer + +This exercise could benefit from the following rules in the [analyzer]: + +- `essential`: Verify that the solution keeps the void type for the drive function. +- `essential`: Verify that the solution has fields in the class +- `actionable`: If the solution defines the fields as `public`, instruct the student to use `private` and explain the encapsulation principle. +- `informative`: If the solution does not use a primitive as a type for the fields, inform the student to use it. + Explain that the values cannot be null and it is less error-prone + +[analyzer]: https://github.com/exercism/java-analyzer diff --git a/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/jedliks-toy-car/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/jedliks-toy-car/gradlew b/exercises/concept/jedliks-toy-car/gradlew old mode 100644 new mode 100755 index 1aa94a426..b9bb139f7 --- a/exercises/concept/jedliks-toy-car/gradlew +++ b/exercises/concept/jedliks-toy-car/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/jedliks-toy-car/gradlew.bat b/exercises/concept/jedliks-toy-car/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/jedliks-toy-car/gradlew.bat +++ b/exercises/concept/jedliks-toy-car/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/jedliks-toy-car/src/test/java/JedliksToyCarTest.java b/exercises/concept/jedliks-toy-car/src/test/java/JedliksToyCarTest.java index 19db64391..279cf07a0 100644 --- a/exercises/concept/jedliks-toy-car/src/test/java/JedliksToyCarTest.java +++ b/exercises/concept/jedliks-toy-car/src/test/java/JedliksToyCarTest.java @@ -8,7 +8,7 @@ public class JedliksToyCarTest { @Test @Tag("task:1") @DisplayName("The static buy method returns a new remote controlled car instance") - public void buy_new_car_returns_instance() { + public void buyNewCarReturnsInstance() { JedliksToyCar car = JedliksToyCar.buy(); assertThat(car).isNotNull(); } @@ -16,7 +16,7 @@ public void buy_new_car_returns_instance() { @Test @Tag("task:1") @DisplayName("The static buy method returns each time a new remote controlled car instance") - public void buy_new_car_returns_new_car_each_time() { + public void buyNewCarReturnsNewCarEachTime() { JedliksToyCar car1 = JedliksToyCar.buy(); JedliksToyCar car2 = JedliksToyCar.buy(); assertThat(car1).isNotEqualTo(car2); @@ -25,7 +25,7 @@ public void buy_new_car_returns_new_car_each_time() { @Test @Tag("task:2") @DisplayName("The distanceDisplay method shows 0 meters message on a new car") - public void new_car_distance_display() { + public void newCarDistanceDisplay() { JedliksToyCar car = new JedliksToyCar(); assertThat(car.distanceDisplay()).isEqualTo("Driven 0 meters"); } @@ -33,7 +33,7 @@ public void new_car_distance_display() { @Test @Tag("task:3") @DisplayName("The batteryDisplay method shows full battery message on a new car") - public void new_car_battery_display() { + public void newCarBatteryDisplay() { JedliksToyCar car = new JedliksToyCar(); assertThat(car.batteryDisplay()).isEqualTo("Battery at 100%"); } @@ -41,7 +41,7 @@ public void new_car_battery_display() { @Test @Tag("task:4") @DisplayName("The distanceDisplay method shows the correct message after driving once") - public void distance_display_after_driving_once() { + public void distanceDisplayAfterDrivingOnce() { JedliksToyCar car = new JedliksToyCar(); car.drive(); assertThat(car.distanceDisplay()).isEqualTo("Driven 20 meters"); @@ -50,7 +50,7 @@ public void distance_display_after_driving_once() { @Test @Tag("task:4") @DisplayName("The distanceDisplay method shows the correct message after driving multiple times") - public void distance_display_after_driving_multiple_times() { + public void distanceDisplayAfterDrivingMultipleTimes() { JedliksToyCar car = new JedliksToyCar(); for (int i = 0; i < 17; i++) { @@ -63,7 +63,7 @@ public void distance_display_after_driving_multiple_times() { @Test @Tag("task:5") @DisplayName("The batteryDisplay method shows the correct message after driving once") - public void battery_display_after_driving_once() { + public void batteryDisplayAfterDrivingOnce() { JedliksToyCar car = new JedliksToyCar(); car.drive(); @@ -73,7 +73,7 @@ public void battery_display_after_driving_once() { @Test @Tag("task:5") @DisplayName("The batteryDisplay method shows the correct battery percentage after driving multiple times") - public void battery_display_after_driving_multiple_times() { + public void batteryDisplayAfterDrivingMultipleTimes() { JedliksToyCar car = new JedliksToyCar(); for (int i = 0; i < 23; i++) { @@ -86,7 +86,7 @@ public void battery_display_after_driving_multiple_times() { @Test @Tag("task:5") @DisplayName("The batteryDisplay method shows battery empty after draining all battery") - public void battery_display_when_battery_empty() { + public void batteryDisplayWhenBatteryEmpty() { JedliksToyCar car = new JedliksToyCar(); // Drain the battery @@ -103,7 +103,7 @@ public void battery_display_when_battery_empty() { @Test @Tag("task:6") @DisplayName("The distanceDisplay method shows the correct message after driving and draining all battery") - public void distance_display_when_battery_empty() { + public void distanceDisplayWhenBatteryEmpty() { JedliksToyCar car = new JedliksToyCar(); // Drain the battery diff --git a/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/karls-languages/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/karls-languages/gradlew b/exercises/concept/karls-languages/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/karls-languages/gradlew +++ b/exercises/concept/karls-languages/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/karls-languages/gradlew.bat b/exercises/concept/karls-languages/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/karls-languages/gradlew.bat +++ b/exercises/concept/karls-languages/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/lasagna/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/lasagna/gradlew b/exercises/concept/lasagna/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/lasagna/gradlew +++ b/exercises/concept/lasagna/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/lasagna/gradlew.bat b/exercises/concept/lasagna/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/lasagna/gradlew.bat +++ b/exercises/concept/lasagna/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/lasagna/src/test/java/LasagnaTest.java b/exercises/concept/lasagna/src/test/java/LasagnaTest.java index 7b1676129..6200d47c5 100644 --- a/exercises/concept/lasagna/src/test/java/LasagnaTest.java +++ b/exercises/concept/lasagna/src/test/java/LasagnaTest.java @@ -11,7 +11,7 @@ public class LasagnaTest { @Test @Tag("task:1") @DisplayName("Implemented the expectedMinutesInOven method") - public void implemented_expected_minutes_in_oven() { + public void implementedExpectedMinutesInOven() { assertThat(new Lasagna().hasMethod("expectedMinutesInOven")) .withFailMessage("Method expectedMinutesInOven must be created") .isTrue(); @@ -26,14 +26,14 @@ public void implemented_expected_minutes_in_oven() { @Test @Tag("task:1") @DisplayName("The expectedMinutesInOven method returns the correct value") - public void expected_minutes_in_oven() { + public void expectedMinutesInOven() { assertThat(new Lasagna().expectedMinutesInOven()).isEqualTo(40); } @Test @Tag("task:2") @DisplayName("Implemented the remainingMinutesInOven method") - public void implemented_remaining_minutes_in_oven() { + public void implementedRemainingMinutesInOven() { assertThat(new Lasagna().hasMethod("remainingMinutesInOven", int.class)) .withFailMessage("Method remainingMinutesInOven must be created") .isTrue(); @@ -48,14 +48,14 @@ public void implemented_remaining_minutes_in_oven() { @Test @Tag("task:2") @DisplayName("The remainingMinutesInOven method calculates and returns the correct value") - public void remaining_minutes_in_oven() { + public void remainingMinutesInOven() { assertThat(new Lasagna().remainingMinutesInOven(25)).isEqualTo(15); } @Test @Tag("task:3") @DisplayName("Implemented the preparationTimeInMinutes method") - public void implemented_preparation_time_in_minutes() { + public void implementedPreparationTimeInMinutes() { assertThat(new Lasagna().hasMethod("preparationTimeInMinutes", int.class)) .withFailMessage("Method preparationTimeInMinutes must be created") .isTrue(); @@ -70,21 +70,21 @@ public void implemented_preparation_time_in_minutes() { @Test @Tag("task:3") @DisplayName("The preparationTimeInMinutes method calculates the correct value for single layer") - public void preparation_time_in_minutes_for_one_layer() { + public void preparationTimeInMinutesForOneLayer() { assertThat(new Lasagna().preparationTimeInMinutes(1)).isEqualTo(2); } @Test @Tag("task:3") @DisplayName("The preparationTimeInMinutes method calculates the correct value for multiple layers") - public void preparation_time_in_minutes_for_multiple_layers() { + public void preparationTimeInMinutesForMultipleLayers() { assertThat(new Lasagna().preparationTimeInMinutes(4)).isEqualTo(8); } @Test @Tag("task:4") @DisplayName("Implemented the totalTimeInMinutes method") - public void implemented_total_time_in_minutes() { + public void implementedTotalTimeInMinutes() { assertThat(new Lasagna().hasMethod("totalTimeInMinutes", int.class, int.class)) .withFailMessage("Method totalTimeInMinutes must be created") .isTrue(); @@ -99,14 +99,14 @@ public void implemented_total_time_in_minutes() { @Test @Tag("task:4") @DisplayName("The totalTimeInMinutes method calculates the correct value for single layer") - public void total_time_in_minutes_for_one_layer() { + public void totalTimeInMinutesForOneLayer() { assertThat(new Lasagna().totalTimeInMinutes(1, 30)).isEqualTo(32); } @Test @Tag("task:4") @DisplayName("The totalTimeInMinutes method calculates the correct value for multiple layers") - public void total_time_in_minutes_for_multiple_layers() { + public void totalTimeInMinutesForMultipleLayers() { assertThat(new Lasagna().totalTimeInMinutes(4, 8)).isEqualTo(16); } } diff --git a/exercises/concept/lasagna/src/test/java/utils/Lasagna.java b/exercises/concept/lasagna/src/test/java/utils/Lasagna.java index 6cd32882c..ba2ac0aeb 100644 --- a/exercises/concept/lasagna/src/test/java/utils/Lasagna.java +++ b/exercises/concept/lasagna/src/test/java/utils/Lasagna.java @@ -8,18 +8,19 @@ public String getTargetClassName() { } public int expectedMinutesInOven() { - return invokeMethod("expectedMinutesInOven", new Class[]{}); + return invokeMethod("expectedMinutesInOven", Integer.class, new Class[]{}); } public int remainingMinutesInOven(int actualMinutes) { - return invokeMethod("remainingMinutesInOven", new Class[]{int.class}, actualMinutes); + return invokeMethod("remainingMinutesInOven", Integer.class, new Class[]{int.class}, actualMinutes); } public int preparationTimeInMinutes(int amountLayers) { - return invokeMethod("preparationTimeInMinutes", new Class[]{int.class}, amountLayers); + return invokeMethod("preparationTimeInMinutes", Integer.class, new Class[]{int.class}, amountLayers); } public int totalTimeInMinutes(int amountLayers, int actualMinutes) { - return invokeMethod("totalTimeInMinutes", new Class[]{int.class, int.class}, amountLayers, actualMinutes); + return invokeMethod("totalTimeInMinutes", Integer.class, new Class[]{int.class, int.class}, + amountLayers, actualMinutes); } } diff --git a/exercises/concept/lasagna/src/test/java/utils/ReflectionProxy.java b/exercises/concept/lasagna/src/test/java/utils/ReflectionProxy.java index 6405b525c..14810c9ef 100644 --- a/exercises/concept/lasagna/src/test/java/utils/ReflectionProxy.java +++ b/exercises/concept/lasagna/src/test/java/utils/ReflectionProxy.java @@ -101,12 +101,14 @@ public boolean isMethodReturnType(Class returnType, String name, Class... /** * Invokes a method from the target instance * @param methodName The name of the method + * @param returnType The class representing the expected return type * @param parameterTypes The list of parameter types * @param parameterValues The list with values for the method parameters * @param The result type we expect the method to be * @return The value returned by the method */ - protected T invokeMethod(String methodName, Class[] parameterTypes, Object... parameterValues) { + protected T invokeMethod(String methodName, Class returnType, Class[] parameterTypes, + Object... parameterValues) { if (target == null) { return null; } @@ -114,13 +116,13 @@ protected T invokeMethod(String methodName, Class[] parameterTypes, Obje // getDeclaredMethod is used to get protected/private methods Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); - return (T) method.invoke(target, parameterValues); + return returnType.cast(method.invoke(target, parameterValues)); } catch (NoSuchMethodException e) { try { // try getting it from parent class, but only public methods will work Method method = target.getClass().getMethod(methodName, parameterTypes); method.setAccessible(true); - return (T) method.invoke(target, parameterValues); + return returnType.cast(method.invoke(target, parameterValues)); } catch (Exception ex) { return null; } @@ -381,7 +383,7 @@ public int hashCode() { * @return The result of 'toString' from the target instance */ public String toString() { - return invokeMethod("toString", new Class[]{ }); + return invokeMethod("toString", String.class, new Class[]{ }); } /** @@ -390,14 +392,14 @@ public String toString() { * @param The type we are expecting it to be * @return The value of the property (if it exists) */ - protected T getPropertyValue(String propertyName) { + protected T getPropertyValue(String propertyName, Class propertyType) { if (target == null || !hasProperty(propertyName)) { return null; } try { Field field = target.getClass().getDeclaredField(propertyName); field.setAccessible(true); - return (T) field.get(target); + return propertyType.cast(field.get(target)); } catch (Exception e) { return null; } diff --git a/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/log-levels/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/log-levels/gradlew b/exercises/concept/log-levels/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/log-levels/gradlew +++ b/exercises/concept/log-levels/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/log-levels/gradlew.bat b/exercises/concept/log-levels/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/log-levels/gradlew.bat +++ b/exercises/concept/log-levels/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/log-levels/src/test/java/LogLevelsTest.java b/exercises/concept/log-levels/src/test/java/LogLevelsTest.java index 2fa83e375..65dd46629 100644 --- a/exercises/concept/log-levels/src/test/java/LogLevelsTest.java +++ b/exercises/concept/log-levels/src/test/java/LogLevelsTest.java @@ -8,56 +8,56 @@ public class LogLevelsTest { @Test @Tag("task:1") @DisplayName("The message method returns the log line's message of an error log") - public void error_message() { + public void errorMessage() { assertThat(LogLevels.message("[ERROR]: Stack overflow")).isEqualTo("Stack overflow"); } @Test @Tag("task:1") @DisplayName("The message method returns the log line's message of a warning log") - public void warning_message() { + public void warningMessage() { assertThat(LogLevels.message("[WARNING]: Disk almost full")).isEqualTo("Disk almost full"); } @Test @Tag("task:1") @DisplayName("The message method returns the log line's message of an info log") - public void info_message() { + public void infoMessage() { assertThat(LogLevels.message("[INFO]: File moved")).isEqualTo("File moved"); } @Test @Tag("task:1") @DisplayName("The message method returns the log line's message after removing leading and trailing spaces") - public void message_with_leading_and_trailing_white_space() { + public void messageWithLeadingAndTrailingWhiteSpace() { assertThat(LogLevels.message("[WARNING]: \tTimezone not set \r\n")).isEqualTo("Timezone not set"); } @Test @Tag("task:2") @DisplayName("The logLevel method returns the log level of an error log line") - public void error_log_level() { + public void errorLogLevel() { assertThat(LogLevels.logLevel("[ERROR]: Disk full")).isEqualTo("error"); } @Test @Tag("task:2") @DisplayName("The logLevel method returns the log level of a warning log line") - public void warning_log_level() { + public void warningLogLevel() { assertThat(LogLevels.logLevel("[WARNING]: Unsafe password")).isEqualTo("warning"); } @Test @Tag("task:2") @DisplayName("The logLevel method returns the log level of an info log line") - public void info_log_level() { + public void infoLogLevel() { assertThat(LogLevels.logLevel("[INFO]: Timezone changed")).isEqualTo("info"); } @Test @Tag("task:3") @DisplayName("The reformat method correctly reformats an error log line") - public void error_reformat() { + public void errorReformat() { assertThat(LogLevels.reformat("[ERROR]: Segmentation fault")) .isEqualTo("Segmentation fault (error)"); } @@ -65,7 +65,7 @@ public void error_reformat() { @Test @Tag("task:3") @DisplayName("The reformat method correctly reformats a warning log line") - public void warning_reformat() { + public void warningReformat() { assertThat(LogLevels.reformat("[WARNING]: Decreased performance")) .isEqualTo("Decreased performance (warning)"); } @@ -73,7 +73,7 @@ public void warning_reformat() { @Test @Tag("task:3") @DisplayName("The reformat method correctly reformats an info log line") - public void info_reformat() { + public void infoReformat() { assertThat(LogLevels.reformat("[INFO]: Disk defragmented")) .isEqualTo("Disk defragmented (info)"); } @@ -81,7 +81,7 @@ public void info_reformat() { @Test @Tag("task:3") @DisplayName("The reformat method correctly reformats an error log line removing spaces") - public void reformat_with_leading_and_trailing_white_space() { + public void reformatWithLeadingAndTrailingWhiteSpace() { assertThat(LogLevels.reformat("[ERROR]: \t Corrupt disk\t \t \r\n")) .isEqualTo("Corrupt disk (error)"); } diff --git a/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/logs-logs-logs/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/logs-logs-logs/gradlew b/exercises/concept/logs-logs-logs/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/logs-logs-logs/gradlew +++ b/exercises/concept/logs-logs-logs/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/logs-logs-logs/gradlew.bat b/exercises/concept/logs-logs-logs/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/logs-logs-logs/gradlew.bat +++ b/exercises/concept/logs-logs-logs/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/need-for-speed/.docs/instructions.md b/exercises/concept/need-for-speed/.docs/instructions.md index e5c478efa..298408aea 100644 --- a/exercises/concept/need-for-speed/.docs/instructions.md +++ b/exercises/concept/need-for-speed/.docs/instructions.md @@ -45,7 +45,7 @@ car.distanceDriven(); ## 4. Check for a drained battery -Update the `NeedForSpeed.drive()` method to drain the battery based on the car's battery drain. Also, implement the `NeedForSpeed.batteryDrained()` method that indicates if the battery is drained: +Update the `NeedForSpeed.drive()` method to drain the battery based on the car's battery drain. Also, implement the `NeedForSpeed.batteryDrained()` method that indicates if the battery is too drained to drive: ```java int speed = 5; diff --git a/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/need-for-speed/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/need-for-speed/gradlew b/exercises/concept/need-for-speed/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/need-for-speed/gradlew +++ b/exercises/concept/need-for-speed/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/need-for-speed/gradlew.bat b/exercises/concept/need-for-speed/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/need-for-speed/gradlew.bat +++ b/exercises/concept/need-for-speed/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/need-for-speed/src/test/java/NeedForSpeedTest.java b/exercises/concept/need-for-speed/src/test/java/NeedForSpeedTest.java index a5f130e3f..2848f34fb 100644 --- a/exercises/concept/need-for-speed/src/test/java/NeedForSpeedTest.java +++ b/exercises/concept/need-for-speed/src/test/java/NeedForSpeedTest.java @@ -10,7 +10,7 @@ public class NeedForSpeedTest { @Test @Tag("task:3") @DisplayName("The distanceDriven method returns 0 on a new car") - public void new_remote_control_car_has_not_driven_any_distance() { + public void newRemoteControlCarHasNotDrivenAnyDistance() { int speed = 10; int batteryDrain = 2; var car = new NeedForSpeed(speed, batteryDrain); @@ -21,7 +21,7 @@ public void new_remote_control_car_has_not_driven_any_distance() { @Test @Tag("task:3") @DisplayName("The distanceDriven method returns 5 after driving once") - public void drive_increases_distance_driven_with_speed() { + public void driveIncreasesDistanceDrivenWithSpeed() { int speed = 5; int batteryDrain = 1; var car = new NeedForSpeed(speed, batteryDrain); @@ -34,7 +34,7 @@ public void drive_increases_distance_driven_with_speed() { @Test @Tag("task:3") @DisplayName("The distanceDriven method returns the correct distance after driving multiple times") - public void drive_does_not_increase_distance_driven_when_battery_drained() { + public void driveDoesNotIncreaseDistanceDrivenWhenBatteryDrained() { int speed = 9; int batteryDrain = 50; var car = new NeedForSpeed(speed, batteryDrain); @@ -52,7 +52,7 @@ public void drive_does_not_increase_distance_driven_when_battery_drained() { @Test @Tag("task:4") @DisplayName("The batteryDrained method returns false when car never drove") - public void new_remote_control_car_battery_is_not_drained() { + public void newRemoteControlCarBatteryIsNotDrained() { int speed = 15; int batteryDrain = 3; var car = new NeedForSpeed(speed, batteryDrain); @@ -63,7 +63,7 @@ public void new_remote_control_car_battery_is_not_drained() { @Test @Tag("task:4") @DisplayName("The batteryDrained method returns false when there's not enough battery") - public void new_remote_control_car_that_can_only_drive_once() { + public void newRemoteControlCarThatCanOnlyDriveOnce() { var car = new NeedForSpeed(1, 99); car.drive(); assertThat(car.batteryDrained()).isTrue(); @@ -74,7 +74,7 @@ public void new_remote_control_car_that_can_only_drive_once() { @Test @Tag("task:4") @DisplayName("The batteryDrained method returns false when car battery did not completely drain after driving") - public void drive_to_almost_drain_battery() { + public void driveToAlmostDrainBattery() { int speed = 2; int batteryDrain = 1; var car = new NeedForSpeed(speed, batteryDrain); @@ -90,7 +90,7 @@ public void drive_to_almost_drain_battery() { @Test @Tag("task:4") @DisplayName("The batteryDrained method returns true when battery completely drained after driving") - public void drive_until_battery_is_drained() { + public void driveUntilBatteryIsDrained() { int speed = 2; int batteryDrain = 1; var car = new NeedForSpeed(speed, batteryDrain); @@ -106,7 +106,7 @@ public void drive_until_battery_is_drained() { @Test @Tag("task:5") @DisplayName("The distanceDriven method returns 0 on a new nitro car") - public void nitro_car_has_not_driven_any_distance() { + public void nitroCarHasNotDrivenAnyDistance() { var car = NeedForSpeed.nitro(); assertThat(car.distanceDriven()).isEqualTo(0); } @@ -114,7 +114,7 @@ public void nitro_car_has_not_driven_any_distance() { @Test @Tag("task:5") @DisplayName("The batteryDrained method returns false when nitro car never drove") - public void nitro_car_has_battery_not_drained() { + public void nitroCarHasBatteryNotDrained() { var car = NeedForSpeed.nitro(); assertThat(car.batteryDrained()).isFalse(); } @@ -122,7 +122,7 @@ public void nitro_car_has_battery_not_drained() { @Test @Tag("task:5") @DisplayName("The distanceDriven method returns the correct distance after driving a nitro car") - public void nitro_car_has_correct_speed() { + public void nitroCarHasCorrectSpeed() { var car = NeedForSpeed.nitro(); car.drive(); assertThat(car.distanceDriven()).isEqualTo(50); @@ -131,7 +131,7 @@ public void nitro_car_has_correct_speed() { @Test @Tag("task:5") @DisplayName("The batteryDrained method returns false when nitro battery did not completely drain after driving") - public void nitro_has_correct_battery_drain() { + public void nitroHasCorrectBatteryDrain() { var car = NeedForSpeed.nitro(); // The battery is almost drained @@ -145,7 +145,7 @@ public void nitro_has_correct_battery_drain() { @Test @Tag("task:5") @DisplayName("The batteryDrained method returns true when nitro battery completely drained after driving") - public void nitro_battery_completely_drains() { + public void nitroBatteryCompletelyDrains() { var car = NeedForSpeed.nitro(); // The battery is drained @@ -159,7 +159,7 @@ public void nitro_battery_completely_drains() { @Test @Tag("task:6") @DisplayName("The canFinishRace method returns true when car can finish a race") - public void car_can_finish_with_car_that_can_easily_finish() { + public void carCanFinishWithCarThatCanEasilyFinish() { int speed = 10; int batteryDrain = 2; var car = new NeedForSpeed(speed, batteryDrain); @@ -173,7 +173,7 @@ public void car_can_finish_with_car_that_can_easily_finish() { @Test @Tag("task:6") @DisplayName("The canFinishRace method returns true when car can just finish a race") - public void car_can_finish_with_car_that_can_just_finish() { + public void carCanFinishWithCarThatCanJustFinish() { int speed = 2; int batteryDrain = 10; var car = new NeedForSpeed(speed, batteryDrain); @@ -187,7 +187,7 @@ public void car_can_finish_with_car_that_can_just_finish() { @Test @Tag("task:6") @DisplayName("The canFinishRace method returns false when car just cannot finish a race") - public void car_can_finish_with_car_that_just_cannot_finish() { + public void carCanFinishWithCarThatJustCannotFinish() { int speed = 3; int batteryDrain = 20; var car = new NeedForSpeed(speed, batteryDrain); @@ -201,7 +201,7 @@ public void car_can_finish_with_car_that_just_cannot_finish() { @Test @Tag("task:6") @DisplayName("The canFinishRace method returns false when car cannot finish a race") - public void car_can_finish_with_car_that_cannot_finish() { + public void carCanFinishWithCarThatCannotFinish() { int speed = 1; int batteryDrain = 20; var car = new NeedForSpeed(speed, batteryDrain); diff --git a/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/remote-control-competition/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/remote-control-competition/gradlew b/exercises/concept/remote-control-competition/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/remote-control-competition/gradlew +++ b/exercises/concept/remote-control-competition/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/remote-control-competition/gradlew.bat b/exercises/concept/remote-control-competition/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/remote-control-competition/gradlew.bat +++ b/exercises/concept/remote-control-competition/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/salary-calculator/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/salary-calculator/gradlew b/exercises/concept/salary-calculator/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/salary-calculator/gradlew +++ b/exercises/concept/salary-calculator/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/salary-calculator/gradlew.bat b/exercises/concept/salary-calculator/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/salary-calculator/gradlew.bat +++ b/exercises/concept/salary-calculator/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/secrets/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/secrets/gradlew b/exercises/concept/secrets/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/secrets/gradlew +++ b/exercises/concept/secrets/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/secrets/gradlew.bat b/exercises/concept/secrets/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/secrets/gradlew.bat +++ b/exercises/concept/secrets/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/squeaky-clean/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/squeaky-clean/gradlew b/exercises/concept/squeaky-clean/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/squeaky-clean/gradlew +++ b/exercises/concept/squeaky-clean/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/squeaky-clean/gradlew.bat b/exercises/concept/squeaky-clean/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/squeaky-clean/gradlew.bat +++ b/exercises/concept/squeaky-clean/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/squeaky-clean/src/test/java/SqueakyCleanTest.java b/exercises/concept/squeaky-clean/src/test/java/SqueakyCleanTest.java index 19688de55..e85a60495 100644 --- a/exercises/concept/squeaky-clean/src/test/java/SqueakyCleanTest.java +++ b/exercises/concept/squeaky-clean/src/test/java/SqueakyCleanTest.java @@ -16,7 +16,7 @@ public void empty() { @Test @Tag("task:1") @DisplayName("The clean method returns the same string when invoked on a single letter string") - public void single_letter() { + public void singleLetter() { assertThat(SqueakyClean.clean("A")).isEqualTo("A"); } @@ -37,56 +37,56 @@ public void spaces() { @Test @Tag("task:1") @DisplayName("The clean method replaces leading and trailing whitespaces with underscores") - public void leading_and_trailing_spaces() { + public void leadingAndTrailingSpaces() { assertThat(SqueakyClean.clean(" myId ")).isEqualTo("_myId_"); } @Test @Tag("task:2") @DisplayName("The clean method converts kebab to camel case after removing a dash") - public void kebab_to_camel_case() { + public void kebabToCamelCase() { assertThat(SqueakyClean.clean("a-bc")).isEqualTo("aBc"); } @Test @Tag("task:2") @DisplayName("The clean method returns a string in camel case after removing a dash and replaces a whitespace") - public void kebab_to_camel_case_and_number() { + public void kebabToCamelCaseAndNumber() { assertThat(SqueakyClean.clean("a-C ")).isEqualTo("aC_"); } @Test @Tag("task:2") @DisplayName("The clean method returns a string in camel case and replaces leading and trailing whitespaces") - public void kebab_to_camel_case_and_spaces() { + public void kebabToCamelCaseAndSpaces() { assertThat(SqueakyClean.clean(" hello-world ")).isEqualTo("_helloWorld_"); } @Test @Tag("task:3") @DisplayName("The clean method converts leetspeak to normal text after replacing numbers with chars") - public void leetspeak_to_normal_text() { + public void leetspeakToNormalText() { assertThat(SqueakyClean.clean("H3ll0 W0rld")).isEqualTo("Hello_World"); } @Test @Tag("task:3") @DisplayName("The clean method converts leetspeak to normal text with spaces and special characters") - public void leetspeak_to_normal_text_with_spaces_and_special_characters() { + public void leetspeakToNormalTextWithSpacesAndSpecialCharacters() { assertThat(SqueakyClean.clean("¡1337sp34k is fun!")).isEqualTo("leetspeak_is_fun"); } @Test @Tag("task:4") @DisplayName("The clean method removes all characters that are not letters") - public void special_characters() { + public void specialCharacters() { assertThat(SqueakyClean.clean("a$#.b")).isEqualTo("ab"); } @Test @Tag("task:4") @DisplayName("The clean method removes all characters that are not letters and replaces spaces") - public void special_characters_and_spaces() { + public void specialCharactersAndSpaces() { assertThat(SqueakyClean.clean("¡hello world!. ")).isEqualTo("hello_world_"); } } diff --git a/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/tim-from-marketing/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/tim-from-marketing/gradlew b/exercises/concept/tim-from-marketing/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/tim-from-marketing/gradlew +++ b/exercises/concept/tim-from-marketing/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/tim-from-marketing/gradlew.bat b/exercises/concept/tim-from-marketing/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/tim-from-marketing/gradlew.bat +++ b/exercises/concept/tim-from-marketing/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/wizards-and-warriors-2/.meta/config.json b/exercises/concept/wizards-and-warriors-2/.meta/config.json index ec5eca2b8..86632e575 100644 --- a/exercises/concept/wizards-and-warriors-2/.meta/config.json +++ b/exercises/concept/wizards-and-warriors-2/.meta/config.json @@ -8,7 +8,8 @@ ], "files": { "solution": [ - "src/main/java/GameMaster.java" + "src/main/java/GameMaster.java", + "src/main/java/TravelMethod.java" ], "test": [ "src/test/java/GameMasterTest.java" @@ -18,8 +19,7 @@ ], "editor": [ "src/main/java/Character.java", - "src/main/java/Destination.java", - "src/main/java/TravelMethod.java" + "src/main/java/Destination.java" ], "invalidator": [ "build.gradle" diff --git a/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/wizards-and-warriors-2/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/wizards-and-warriors-2/gradlew b/exercises/concept/wizards-and-warriors-2/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/wizards-and-warriors-2/gradlew +++ b/exercises/concept/wizards-and-warriors-2/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/wizards-and-warriors-2/gradlew.bat b/exercises/concept/wizards-and-warriors-2/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/wizards-and-warriors-2/gradlew.bat +++ b/exercises/concept/wizards-and-warriors-2/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/wizards-and-warriors-2/src/main/java/Character.java b/exercises/concept/wizards-and-warriors-2/src/main/java/Character.java index d7a4a4add..9278ba5ed 100644 --- a/exercises/concept/wizards-and-warriors-2/src/main/java/Character.java +++ b/exercises/concept/wizards-and-warriors-2/src/main/java/Character.java @@ -1,3 +1,8 @@ +/** + * Represents a Character in the game. + * + * NOTE: There is no need to change this file and is treated as read only by the Exercism test runners. + */ public class Character { private String characterClass; private int level; diff --git a/exercises/concept/wizards-and-warriors-2/src/main/java/Destination.java b/exercises/concept/wizards-and-warriors-2/src/main/java/Destination.java index 09f2ce4e3..29d0d4fc1 100644 --- a/exercises/concept/wizards-and-warriors-2/src/main/java/Destination.java +++ b/exercises/concept/wizards-and-warriors-2/src/main/java/Destination.java @@ -1,3 +1,8 @@ +/** + * Represents a Destination. + * + * NOTE: There is no need to change this file and is treated as read only by the Exercism test runners. + */ public class Destination { private String name; private int inhabitants; diff --git a/exercises/concept/wizards-and-warriors-2/src/test/java/GameMasterProxy.java b/exercises/concept/wizards-and-warriors-2/src/test/java/GameMasterProxy.java index c747a34d3..ca555b883 100644 --- a/exercises/concept/wizards-and-warriors-2/src/test/java/GameMasterProxy.java +++ b/exercises/concept/wizards-and-warriors-2/src/test/java/GameMasterProxy.java @@ -12,23 +12,25 @@ public String getTargetClassName() { } public String describe(Character character) { - return invokeMethod("describe", new Class[] { Character.class }, character); + return invokeMethod("describe", String.class, new Class[] { Character.class }, character); } public String describe(Destination character) { - return invokeMethod("describe", new Class[] { Destination.class }, character); + return invokeMethod("describe", String.class, new Class[] { Destination.class }, character); } public String describe(TravelMethod character) { - return invokeMethod("describe", new Class[] { TravelMethod.class }, character); + return invokeMethod("describe", String.class, new Class[] { TravelMethod.class }, character); } public String describe(Character character, Destination destination, TravelMethod travelMethod) { - return invokeMethod("describe", new Class[] { Character.class, Destination.class, TravelMethod.class }, + return invokeMethod("describe", String.class, + new Class[] { Character.class, Destination.class, TravelMethod.class }, character, destination, travelMethod); } public String describe(Character character, Destination destination) { - return invokeMethod("describe", new Class[] { Character.class, Destination.class }, character, destination); + return invokeMethod("describe", String.class, new Class[] { Character.class, Destination.class }, + character, destination); } } diff --git a/exercises/concept/wizards-and-warriors-2/src/test/java/ReflectionProxy.java b/exercises/concept/wizards-and-warriors-2/src/test/java/ReflectionProxy.java index 730f26fa0..ff21b5527 100644 --- a/exercises/concept/wizards-and-warriors-2/src/test/java/ReflectionProxy.java +++ b/exercises/concept/wizards-and-warriors-2/src/test/java/ReflectionProxy.java @@ -117,12 +117,14 @@ public boolean isMethodReturnType(Class returnType, String name, Class... * Invokes a method from the target instance * * @param methodName The name of the method + * @param returnType The class representing the expected return type * @param parameterTypes The list of parameter types * @param parameterValues The list with values for the method parameters * @param The result type we expect the method to be * @return The value returned by the method */ - protected T invokeMethod(String methodName, Class[] parameterTypes, Object... parameterValues) { + protected T invokeMethod(String methodName, Class returnType, Class[] parameterTypes, + Object... parameterValues) { if (target == null) { throw new UnsupportedOperationException(); } @@ -131,12 +133,12 @@ protected T invokeMethod(String methodName, Class[] parameterTypes, Objec // getDeclaredMethod is used to get protected/private methods Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); - return (T) method.invoke(target, parameterValues); + return returnType.cast(method.invoke(target, parameterValues)); } catch (NoSuchMethodException e) { // try getting it from parent class, but only public methods will work Method method = target.getClass().getMethod(methodName, parameterTypes); method.setAccessible(true); - return (T) method.invoke(target, parameterValues); + return returnType.cast(method.invoke(target, parameterValues)); } } catch (Exception e) { throw new UnsupportedOperationException(e); @@ -360,7 +362,6 @@ public boolean isConstructorPublic(Class... parameterTypes) { /** * Proxy for the 'equals' method - * * @param obj The ReflexionProxy object you want to compare against * @return True if both targets are equal, false otherwise */ @@ -379,7 +380,6 @@ public boolean equals(Object obj) { /** * Proxy for the 'hashCode' method - * * @return The hashCode from the target class */ public int hashCode() { @@ -397,28 +397,26 @@ public int hashCode() { /** * Proxy for the 'toString' method from the target class - * * @return The result of 'toString' from the target instance */ public String toString() { - return invokeMethod("toString", new Class[]{}); + return invokeMethod("toString", String.class, new Class[]{ }); } /** * Gets a property value from the target instance (if it exists) - * * @param propertyName The name of the property - * @param The type we are expecting it to be + * @param The type we are expecting it to be * @return The value of the property (if it exists) */ - protected T getPropertyValue(String propertyName) { + protected T getPropertyValue(String propertyName, Class propertyType) { if (target == null || !hasProperty(propertyName)) { return null; } try { Field field = target.getClass().getDeclaredField(propertyName); field.setAccessible(true); - return (T) field.get(target); + return propertyType.cast(field.get(target)); } catch (Exception e) { return null; } @@ -426,7 +424,6 @@ protected T getPropertyValue(String propertyName) { /** * Checks if the target class is abstract - * * @return True if the target class exists and is abstract, false otherwise */ public boolean isAbstract() { @@ -439,7 +436,6 @@ public boolean isAbstract() { /** * Checks if the target class extends another - * * @param className The fully qualified name of the class it should extend * @return True if the target class extends the specified one, false otherwise */ @@ -458,7 +454,6 @@ public boolean extendsClass(String className) { /** * Checks if the target class is an interface - * * @return True if the target class exists and is an interface, false otherwise */ public boolean isInterface() { @@ -471,8 +466,7 @@ public boolean isInterface() { /** * Checks if a method is abstract - * - * @param name The name of the method + * @param name The name of the method * @param parameterTypes The list of method parameter types * @return True if the method exists and is abstract, false otherwise */ @@ -491,8 +485,7 @@ public boolean isMethodAbstract(String name, Class... parameterTypes) { /** * Checks if a method is protected - * - * @param name The name of the method + * @param name The name of the method * @param parameterTypes The list of method parameter types * @return True if the method exists and is protected, false otherwise */ @@ -511,3 +504,4 @@ public boolean isMethodProtected(String name, Class... parameterTypes) { //endregion } + diff --git a/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.jar b/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.jar and b/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.properties b/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/concept/wizards-and-warriors/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/concept/wizards-and-warriors/gradlew b/exercises/concept/wizards-and-warriors/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/concept/wizards-and-warriors/gradlew +++ b/exercises/concept/wizards-and-warriors/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/concept/wizards-and-warriors/gradlew.bat b/exercises/concept/wizards-and-warriors/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/concept/wizards-and-warriors/gradlew.bat +++ b/exercises/concept/wizards-and-warriors/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/concept/wizards-and-warriors/src/test/java/ReflectionProxy.java b/exercises/concept/wizards-and-warriors/src/test/java/ReflectionProxy.java index a3183fc87..02a6460c7 100644 --- a/exercises/concept/wizards-and-warriors/src/test/java/ReflectionProxy.java +++ b/exercises/concept/wizards-and-warriors/src/test/java/ReflectionProxy.java @@ -99,12 +99,14 @@ public boolean isMethodReturnType(Class returnType, String name, Class... /** * Invokes a method from the target instance * @param methodName The name of the method + * @param returnType The class representing the expected return type * @param parameterTypes The list of parameter types * @param parameterValues The list with values for the method parameters * @param The result type we expect the method to be * @return The value returned by the method */ - protected T invokeMethod(String methodName, Class[] parameterTypes, Object... parameterValues) { + protected T invokeMethod(String methodName, Class returnType, Class[] parameterTypes, + Object... parameterValues) { if (target == null) { return null; } @@ -112,13 +114,13 @@ protected T invokeMethod(String methodName, Class[] parameterTypes, Obje // getDeclaredMethod is used to get protected/private methods Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); - return (T) method.invoke(target, parameterValues); + return returnType.cast(method.invoke(target, parameterValues)); } catch (NoSuchMethodException e) { try { // try getting it from parent class, but only public methods will work Method method = target.getClass().getMethod(methodName, parameterTypes); method.setAccessible(true); - return (T) method.invoke(target, parameterValues); + return returnType.cast(method.invoke(target, parameterValues)); } catch (Exception ex) { return null; } @@ -379,23 +381,24 @@ public int hashCode() { * @return The result of 'toString' from the target instance */ public String toString() { - return invokeMethod("toString", new Class[]{ }); + return invokeMethod("toString", String.class, new Class[]{ }); } /** * Gets a property value from the target instance (if it exists) * @param propertyName The name of the property + * @param propertyType The class representing the property's type * @param The type we are expecting it to be * @return The value of the property (if it exists) */ - protected T getPropertyValue(String propertyName) { + protected T getPropertyValue(String propertyName, Class propertyType) { if (target == null || !hasProperty(propertyName)) { return null; } try { Field field = target.getClass().getDeclaredField(propertyName); field.setAccessible(true); - return (T) field.get(target); + return propertyType.cast(field.get(target)); } catch (Exception e) { return null; } diff --git a/exercises/concept/wizards-and-warriors/src/test/java/WarriorProxy.java b/exercises/concept/wizards-and-warriors/src/test/java/WarriorProxy.java index 821ae9837..2b6540578 100644 --- a/exercises/concept/wizards-and-warriors/src/test/java/WarriorProxy.java +++ b/exercises/concept/wizards-and-warriors/src/test/java/WarriorProxy.java @@ -6,14 +6,14 @@ public String getTargetClassName() { } public String toString() { - return invokeMethod("toString", new Class[0]); + return invokeMethod("toString", String.class, new Class[0]); } boolean isVulnerable() { - return invokeMethod("isVulnerable", new Class[0]); + return invokeMethod("isVulnerable", Boolean.class, new Class[0]); } int getDamagePoints(Fighter target) { - return invokeMethod("getDamagePoints", new Class[]{Fighter.class}, target); + return invokeMethod("getDamagePoints", Integer.class, new Class[]{Fighter.class}, target); } } diff --git a/exercises/concept/wizards-and-warriors/src/test/java/WizardProxy.java b/exercises/concept/wizards-and-warriors/src/test/java/WizardProxy.java index 2069472c2..5e47bf0ea 100644 --- a/exercises/concept/wizards-and-warriors/src/test/java/WizardProxy.java +++ b/exercises/concept/wizards-and-warriors/src/test/java/WizardProxy.java @@ -6,18 +6,18 @@ public String getTargetClassName() { } public String toString() { - return invokeMethod("toString", new Class[0]); + return invokeMethod("toString", String.class, new Class[0]); } boolean isVulnerable() { - return invokeMethod("isVulnerable", new Class[0]); + return invokeMethod("isVulnerable", Boolean.class, new Class[0]); } int getDamagePoints(Fighter target) { - return invokeMethod("getDamagePoints", new Class[]{Fighter.class}, target); + return invokeMethod("getDamagePoints", Integer.class, new Class[]{Fighter.class}, target); } void prepareSpell() { - invokeMethod("prepareSpell", new Class[0]); + invokeMethod("prepareSpell", Void.class, new Class[0]); } } diff --git a/exercises/gradle/wrapper/gradle-wrapper.jar b/exercises/gradle/wrapper/gradle-wrapper.jar index e6441136f..61285a659 100644 Binary files a/exercises/gradle/wrapper/gradle-wrapper.jar and b/exercises/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/gradle/wrapper/gradle-wrapper.properties b/exercises/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..1a704683a 100644 --- a/exercises/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/exercises/gradlew b/exercises/gradlew index 1aa94a426..adff685a0 100755 --- a/exercises/gradlew +++ b/exercises/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/gradlew.bat b/exercises/gradlew.bat index 93e3f59f1..c4bdd3ab8 100644 --- a/exercises/gradlew.bat +++ b/exercises/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,21 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/acronym/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/acronym/gradlew b/exercises/practice/acronym/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/acronym/gradlew +++ b/exercises/practice/acronym/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/acronym/gradlew.bat b/exercises/practice/acronym/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/acronym/gradlew.bat +++ b/exercises/practice/acronym/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/affine-cipher/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/affine-cipher/gradlew b/exercises/practice/affine-cipher/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/affine-cipher/gradlew +++ b/exercises/practice/affine-cipher/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/affine-cipher/gradlew.bat b/exercises/practice/affine-cipher/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/affine-cipher/gradlew.bat +++ b/exercises/practice/affine-cipher/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/affine-cipher/src/test/java/AffineCipherTest.java b/exercises/practice/affine-cipher/src/test/java/AffineCipherTest.java index 668631a5c..25bad1a0b 100644 --- a/exercises/practice/affine-cipher/src/test/java/AffineCipherTest.java +++ b/exercises/practice/affine-cipher/src/test/java/AffineCipherTest.java @@ -32,7 +32,7 @@ public void testEncodeOMG() { @Disabled("Remove to run test") @Test @DisplayName("encode O M G") - public void testEncodeO_M_G() { + public void testEncodeOMGWithSpaces() { assertThat(affineCipher.encode("O M G", 25, 47)).isEqualTo("hjp"); } diff --git a/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/all-your-base/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/all-your-base/gradlew b/exercises/practice/all-your-base/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/all-your-base/gradlew +++ b/exercises/practice/all-your-base/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/all-your-base/gradlew.bat b/exercises/practice/all-your-base/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/all-your-base/gradlew.bat +++ b/exercises/practice/all-your-base/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/allergies/.meta/config.json b/exercises/practice/allergies/.meta/config.json index 5131edc5e..b879415dd 100644 --- a/exercises/practice/allergies/.meta/config.json +++ b/exercises/practice/allergies/.meta/config.json @@ -45,5 +45,5 @@ }, "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", - "source_url": "https://turing.edu" + "source_url": "https://www.turing.edu/" } diff --git a/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/allergies/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/allergies/gradlew b/exercises/practice/allergies/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/allergies/gradlew +++ b/exercises/practice/allergies/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/allergies/gradlew.bat b/exercises/practice/allergies/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/allergies/gradlew.bat +++ b/exercises/practice/allergies/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/alphametics/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/alphametics/gradlew b/exercises/practice/alphametics/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/alphametics/gradlew +++ b/exercises/practice/alphametics/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/alphametics/gradlew.bat b/exercises/practice/alphametics/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/alphametics/gradlew.bat +++ b/exercises/practice/alphametics/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/anagram/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/anagram/gradlew b/exercises/practice/anagram/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/anagram/gradlew +++ b/exercises/practice/anagram/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/anagram/gradlew.bat b/exercises/practice/anagram/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/anagram/gradlew.bat +++ b/exercises/practice/anagram/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/armstrong-numbers/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/armstrong-numbers/gradlew b/exercises/practice/armstrong-numbers/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/armstrong-numbers/gradlew +++ b/exercises/practice/armstrong-numbers/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/armstrong-numbers/gradlew.bat b/exercises/practice/armstrong-numbers/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/armstrong-numbers/gradlew.bat +++ b/exercises/practice/armstrong-numbers/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/atbash-cipher/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/atbash-cipher/gradlew b/exercises/practice/atbash-cipher/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/atbash-cipher/gradlew +++ b/exercises/practice/atbash-cipher/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/atbash-cipher/gradlew.bat b/exercises/practice/atbash-cipher/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/atbash-cipher/gradlew.bat +++ b/exercises/practice/atbash-cipher/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/baffling-birthdays/.docs/instructions.md b/exercises/practice/baffling-birthdays/.docs/instructions.md new file mode 100644 index 000000000..a01ec8679 --- /dev/null +++ b/exercises/practice/baffling-birthdays/.docs/instructions.md @@ -0,0 +1,23 @@ +# Instructions + +Your task is to estimate the birthday paradox's probabilities. + +To do this, you need to: + +- Generate random birthdates. +- Check if a collection of randomly generated birthdates contains at least two with the same birthday. +- Estimate the probability that at least two people in a group share the same birthday for different group sizes. + +~~~~exercism/note +A birthdate includes the full date of birth (year, month, and day), whereas a birthday refers only to the month and day, which repeat each year. +Two birthdates with the same month and day correspond to the same birthday. +~~~~ + +~~~~exercism/caution +The birthday paradox assumes that: + +- There are 365 possible birthdays (no leap years). +- Each birthday is equally likely (uniform distribution). + +Your implementation must follow these assumptions. +~~~~ diff --git a/exercises/practice/baffling-birthdays/.docs/introduction.md b/exercises/practice/baffling-birthdays/.docs/introduction.md new file mode 100644 index 000000000..97dabd1e6 --- /dev/null +++ b/exercises/practice/baffling-birthdays/.docs/introduction.md @@ -0,0 +1,25 @@ +# Introduction + +Fresh out of college, you're throwing a huge party to celebrate with friends and family. +Over 70 people have shown up, including your mildly eccentric Uncle Ted. + +In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. +That sounds ridiculous — there are many more possible birthdays than there are guests, so you confidently accept. + +To your astonishment, after collecting the birthdays of just 32 guests, you've already found two guests that share the same birthday. +Accepting your loss, you hand Uncle Ted his £100, but something feels off. + +The next day, curiosity gets the better of you. +A quick web search leads you to the [birthday paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. + +Ah. So _that's_ why Uncle Ted was so confident. + +Determined to turn the tables, you start looking up other paradoxes; next time, _you'll_ be the one making the bets. + +~~~~exercism/note +The birthday paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. + +[veridical-paradox]: https://en.wikipedia.org/wiki/Paradox#Quine's_classification +~~~~ + +[birthday-problem]: https://en.wikipedia.org/wiki/Birthday_problem diff --git a/exercises/practice/baffling-birthdays/.meta/config.json b/exercises/practice/baffling-birthdays/.meta/config.json new file mode 100644 index 000000000..6e401cb62 --- /dev/null +++ b/exercises/practice/baffling-birthdays/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "Baboushka" + ], + "files": { + "solution": [ + "src/main/java/BafflingBirthdays.java" + ], + "test": [ + "src/test/java/BafflingBirthdaysTest.java" + ], + "example": [ + ".meta/src/reference/java/BafflingBirthdays.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Estimate the birthday paradox's probabilities.", + "source": "Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/pull/2539" +} diff --git a/exercises/practice/baffling-birthdays/.meta/src/reference/java/BafflingBirthdays.java b/exercises/practice/baffling-birthdays/.meta/src/reference/java/BafflingBirthdays.java new file mode 100644 index 000000000..ef58bc2c0 --- /dev/null +++ b/exercises/practice/baffling-birthdays/.meta/src/reference/java/BafflingBirthdays.java @@ -0,0 +1,48 @@ +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.concurrent.ThreadLocalRandom; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +class BafflingBirthdays { + private static final int nonLeapYear = 2001; + private static final int daysInYear = 365; + + boolean sharedBirthday(List birthdates) { + Set seen = new HashSet<>(); + for (LocalDate birthdate : birthdates) { + if (!seen.add(birthdate.getMonth().toString() + birthdate.getDayOfMonth())) { + return true; + } + } + return false; + } + + List randomBirthdates(int groupSize) { + if (groupSize <= 0) { + return List.of(); + } + List birthdates = new ArrayList<>(groupSize); + ThreadLocalRandom random = ThreadLocalRandom.current(); + for (int i = 0; i < groupSize; i++) { + int dayOfYear = random.nextInt(1, daysInYear + 1); + birthdates.add(LocalDate.ofYearDay(nonLeapYear, dayOfYear)); + } + return birthdates; + } + + double estimatedProbabilityOfSharedBirthday(int groupSize) { + if (groupSize <= 1) { + return 0.0; + } + if (groupSize > daysInYear) { + return 100.0; + } + double probabilityNoSharedBirthday = 1.0; + for (int k = 0; k < groupSize; k++) { + probabilityNoSharedBirthday *= (daysInYear - k) / (double) daysInYear; + } + return (1 - probabilityNoSharedBirthday) * 100.0; + } +} diff --git a/exercises/practice/baffling-birthdays/.meta/tests.toml b/exercises/practice/baffling-birthdays/.meta/tests.toml new file mode 100644 index 000000000..c76afb466 --- /dev/null +++ b/exercises/practice/baffling-birthdays/.meta/tests.toml @@ -0,0 +1,61 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[716dcc2b-8fe4-4fc9-8c48-cbe70d8e6b67] +description = "shared birthday -> one birthdate" + +[f7b3eb26-bcfc-4c1e-a2de-af07afc33f45] +description = "shared birthday -> two birthdates with same year, month, and day" + +[7193409a-6e16-4bcb-b4cc-9ffe55f79b25] +description = "shared birthday -> two birthdates with same year and month, but different day" + +[d04db648-121b-4b72-93e8-d7d2dced4495] +description = "shared birthday -> two birthdates with same month and day, but different year" + +[3c8bd0f0-14c6-4d4c-975a-4c636bfdc233] +description = "shared birthday -> two birthdates with same year, but different month and day" + +[df5daba6-0879-4480-883c-e855c99cdaa3] +description = "shared birthday -> two birthdates with different year, month, and day" + +[0c17b220-cbb9-4bd7-872f-373044c7b406] +description = "shared birthday -> multiple birthdates without shared birthday" + +[966d6b0b-5c0a-4b8c-bc2d-64939ada49f8] +description = "shared birthday -> multiple birthdates with one shared birthday" + +[b7937d28-403b-4500-acce-4d9fe3a9620d] +description = "shared birthday -> multiple birthdates with more than one shared birthday" + +[70b38cea-d234-4697-b146-7d130cd4ee12] +description = "random birthdates -> generate requested number of birthdates" + +[d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03] +description = "random birthdates -> years are not leap years" + +[d1074327-f68c-4c8a-b0ff-e3730d0f0521] +description = "random birthdates -> months are random" + +[7df706b3-c3f5-471d-9563-23a4d0577940] +description = "random birthdates -> days are random" + +[89a462a4-4265-4912-9506-fb027913f221] +description = "estimated probability of at least one shared birthday -> for one person" + +[ec31c787-0ebb-4548-970c-5dcb4eadfb5f] +description = "estimated probability of at least one shared birthday -> among ten people" + +[b548afac-a451-46a3-9bb0-cb1f60c48e2f] +description = "estimated probability of at least one shared birthday -> among twenty-three people" + +[e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5] +description = "estimated probability of at least one shared birthday -> among seventy people" diff --git a/exercises/practice/baffling-birthdays/build.gradle b/exercises/practice/baffling-birthdays/build.gradle new file mode 100644 index 000000000..d28f35dee --- /dev/null +++ b/exercises/practice/baffling-birthdays/build.gradle @@ -0,0 +1,25 @@ +plugins { + id "java" +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation platform("org.junit:junit-bom:5.10.0") + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "org.assertj:assertj-core:3.25.1" + + testRuntimeOnly "org.junit.platform:junit-platform-launcher" +} + +test { + useJUnitPlatform() + + testLogging { + exceptionFormat = "full" + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/exercises/practice/baffling-birthdays/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/baffling-birthdays/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..b1b8ef56b Binary files /dev/null and b/exercises/practice/baffling-birthdays/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/baffling-birthdays/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/baffling-birthdays/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..6394b4647 --- /dev/null +++ b/exercises/practice/baffling-birthdays/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/exercises/practice/baffling-birthdays/gradlew b/exercises/practice/baffling-birthdays/gradlew new file mode 100755 index 000000000..b9bb139f7 --- /dev/null +++ b/exercises/practice/baffling-birthdays/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/exercises/practice/baffling-birthdays/gradlew.bat b/exercises/practice/baffling-birthdays/gradlew.bat new file mode 100644 index 000000000..24c62d56f --- /dev/null +++ b/exercises/practice/baffling-birthdays/gradlew.bat @@ -0,0 +1,82 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/baffling-birthdays/src/main/java/BafflingBirthdays.java b/exercises/practice/baffling-birthdays/src/main/java/BafflingBirthdays.java new file mode 100644 index 000000000..5e1925081 --- /dev/null +++ b/exercises/practice/baffling-birthdays/src/main/java/BafflingBirthdays.java @@ -0,0 +1,16 @@ +import java.time.LocalDate; +import java.util.List; + +class BafflingBirthdays { + boolean sharedBirthday(List birthdates) { + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); + } + + List randomBirthdates(int groupSize) { + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); + } + + double estimatedProbabilityOfSharedBirthday(int groupSize) { + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); + } +} \ No newline at end of file diff --git a/exercises/practice/baffling-birthdays/src/test/java/BafflingBirthdaysTest.java b/exercises/practice/baffling-birthdays/src/test/java/BafflingBirthdaysTest.java new file mode 100644 index 000000000..0726301dc --- /dev/null +++ b/exercises/practice/baffling-birthdays/src/test/java/BafflingBirthdaysTest.java @@ -0,0 +1,176 @@ +import java.time.LocalDate; +import java.util.List; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static java.time.Month.APRIL; +import static java.time.Month.AUGUST; +import static java.time.Month.DECEMBER; +import static java.time.Month.FEBRUARY; +import static java.time.Month.JANUARY; +import static java.time.Month.JULY; +import static java.time.Month.MAY; +import static java.time.Month.NOVEMBER; +import static java.time.Month.OCTOBER; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.data.Offset.offset; + +public class BafflingBirthdaysTest { + private BafflingBirthdays birthdays = new BafflingBirthdays(); + + @Test + @DisplayName("one birthdate") + public void oneBirthdateTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(2000, JANUARY, 1) + ))).isFalse(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("two birthdates with same year, month, and day") + public void twoBirthdatesWithSameYearMonthAndDayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(2000, JANUARY, 1), + LocalDate.of(2000, JANUARY, 1) + ))).isTrue(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("two birthdates with same year and month, but different day") + public void twoBirthdatesWithSameYearAndMonthButDifferentDayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(2012, MAY, 9), + LocalDate.of(2012, MAY, 17) + ))).isFalse(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("two birthdates with same month and day, but different year") + public void twoBirthdatesWithSameMonthAndDayButDifferentYearTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(1999, OCTOBER, 23), + LocalDate.of(1988, OCTOBER, 23) + ))).isTrue(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("two birthdates with same year, but different month and day") + public void twoBirthdatesWithSameYearButDifferentMonthAndDayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(2007, DECEMBER, 19), + LocalDate.of(2007, APRIL, 27) + ))).isFalse(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("two birthdates with different year, month, and day") + public void twoBirthdatesWithDifferentYearMonthAndDayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(1997, AUGUST, 4), + LocalDate.of(1963, NOVEMBER, 23) + ))).isFalse(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("multiple birthdates without shared birthday") + public void multipleBirthdatesWithoutSharedBirthdayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(1966, AUGUST, 29), + LocalDate.of(1977, FEBRUARY, 12), + LocalDate.of(2001, DECEMBER, 25), + LocalDate.of(1980, NOVEMBER, 10) + ))).isFalse(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("multiple birthdates with one shared birthday") + public void multipleBirthdatesWithOneSharedBirthdayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(1966, AUGUST, 29), + LocalDate.of(1977, FEBRUARY, 12), + LocalDate.of(2001, AUGUST, 29), + LocalDate.of(1980, NOVEMBER, 10) + ))).isTrue(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("multiple birthdates with more than one shared birthday") + public void multipleBirthdatesWithMoreThanOneSharedBirthdayTest() { + assertThat(birthdays.sharedBirthday(List.of( + LocalDate.of(1966, JULY, 29), + LocalDate.of(1977, FEBRUARY, 12), + LocalDate.of(2001, DECEMBER, 25), + LocalDate.of(1980, JULY, 29), + LocalDate.of(2019, FEBRUARY, 12) + ))).isTrue(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("generate requested number of birthdates") + public void generateRequestedNumberOfBirthdatesTest() { + int groupSize = 50; + assertThat(birthdays.randomBirthdates(groupSize).size()).isEqualTo(groupSize); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("years are not leap years") + public void yearsAreNotLeapYearsTest() { + assertThat(birthdays.randomBirthdates(100)).noneMatch(LocalDate::isLeapYear); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("months are random") + public void monthsAreRandomTest() { + assertThat(birthdays.randomBirthdates(500).stream().map(LocalDate::getMonth).distinct()) + .hasSizeGreaterThanOrEqualTo(7); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("days are random") + public void daysAreRandomTest() { + assertThat(birthdays.randomBirthdates(500).stream().map(LocalDate::getDayOfMonth).distinct()) + .hasSizeGreaterThanOrEqualTo(11); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("estimated probability of at least one shared birthday case for one person") + public void estimatedProbabilityOfAtLeastOneSharedBirthdayForOnePersonTest() { + assertThat(birthdays.estimatedProbabilityOfSharedBirthday(1)).isEqualTo(0.0); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("estimated probability of at least one shared birthday case among ten people") + public void estimatedProbabilityOfAtLeastOneSharedBirthdayAmongTenPeopleTest() { + assertThat(birthdays.estimatedProbabilityOfSharedBirthday(10)).isCloseTo(11.694818, offset(1.0)); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("estimated probability of at least one shared birthday case among twenty-three people") + public void estimatedProbabilityOfAtLeastOneSharedBirthdayAmongTwentyThreePeopleTest() { + assertThat(birthdays.estimatedProbabilityOfSharedBirthday(23)).isCloseTo(50.729723, offset(1.0)); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("estimated probability of at least one shared birthday case among seventy people") + public void estimatedProbabilityOfAtLeastOneSharedBirthdayAmongSeventyPeopleTest() { + assertThat(birthdays.estimatedProbabilityOfSharedBirthday(70)).isCloseTo(99.915958, offset(1.0)); + } +} diff --git a/exercises/practice/bank-account/.approaches/config.json b/exercises/practice/bank-account/.approaches/config.json new file mode 100644 index 000000000..1739dcd4a --- /dev/null +++ b/exercises/practice/bank-account/.approaches/config.json @@ -0,0 +1,45 @@ +{ + "introduction": { + "authors": [ + "kahgoh" + ] + }, + "approaches": [ + { + "uuid": "78d753b0-aa58-43dc-83c0-9ea41496de84", + "slug": "synchronized-methods", + "title": "Synchronized methods", + "blurb": "Use synchronized methods to prevent methods from running simultaneously in different threads", + "authors": [ + "kahgoh" + ] + }, + { + "uuid": "5f3b0152-02eb-40d5-9104-5edc30b4447e", + "slug": "synchronized-statements", + "title": "Synchronized statements", + "blurb": "Use an object to prevent threads from running blocks of code at the same time", + "authors": [ + "kahgoh" + ] + }, + { + "uuid": "0acd6f2b-27d0-4ae6-9c22-22b0b2047039", + "slug": "reentrant-lock", + "title": "Reentrant lock", + "blurb": "Use an ReentrantLock to explicitly acquire and release locks", + "authors": [ + "kahgoh" + ] + }, + { + "uuid": "4ad42f88-f750-4af9-bbbd-d8b2dc5e8078", + "slug": "readwrite-lock", + "title": "Readwrite lock", + "blurb": "Use separate read and write locks to achieve greater concurrency", + "authors": [ + "kahgoh" + ] + } + ] +} diff --git a/exercises/practice/bank-account/.approaches/introduction.md b/exercises/practice/bank-account/.approaches/introduction.md new file mode 100644 index 000000000..ac8d3c506 --- /dev/null +++ b/exercises/practice/bank-account/.approaches/introduction.md @@ -0,0 +1,351 @@ +# Introduction + +In Bank Account, you are tasked with implementing a number of operations that can be performed on a bank account. +However, these operations may be performed by multiple threads at the same time. + +## General guidance + +The key to solving Bank Account is to prevent an account from being updated from multiple threads at the same time. +For example, consider an account that begins with $0. +A $10 deposit is made twice. +Each transaction starts a thread. +If the threads happen to start simultaneously, they might both see the account starting $0. +They each add $10 to this amount and update the account accordingly. +In this case, each thread sets the amount to $10 even though the transaction was made twice. + +The problem here is that both threads saw that there was $0 in the account prior to adding the deposit. +Instead, each thread needs to take turns to process the deposit for the account so that they can process the transaction one at a time. +This way, the later thread can "see" the deposited amount from the first thread. + +## Approach: Synchronized methods + +```java +class BankAccount { + private int balance = 0; + private boolean isClosed = true; + + synchronized void open() throws BankAccountActionInvalidException { + if (!isClosed) { + throw new BankAccountActionInvalidException("Account already open"); + } + isClosed = false; + balance = 0; + } + + synchronized void close() throws BankAccountActionInvalidException { + if (isClosed) { + throw new BankAccountActionInvalidException("Account not open"); + } + isClosed = true; + } + + synchronized int getBalance() throws BankAccountActionInvalidException { + checkIfClosed(); + return balance; + } + + synchronized void deposit(int amount) throws BankAccountActionInvalidException { + checkIfClosed(); + checkIfValidAmount(amount); + + balance += amount; + } + + synchronized void withdraw(int amount) throws BankAccountActionInvalidException { + checkIfClosed(); + checkIfValidAmount(amount); + checkIfEnoughMoneyInAccount(amount); + + balance -= amount; + } + + private void checkIfValidAmount(int amount) throws BankAccountActionInvalidException { + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + } + + private void checkIfEnoughMoneyInAccount(int amount) throws BankAccountActionInvalidException { + if (balance == 0) { + throw new BankAccountActionInvalidException("Cannot withdraw money from an empty account"); + } + if (balance - amount < 0) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + } + + private void checkIfClosed() throws BankAccountActionInvalidException { + if (isClosed) { + throw new BankAccountActionInvalidException("Account closed"); + } + } +} +``` + +For more information, check the [Synchronized methods approach][approach-synchronized-methods]. + +## Approach: Synchronized statements + +```java +class BankAccount { + private final Object lock = new Object(); + private int balance = 0; + private boolean isClosed = true; + + void open() throws BankAccountActionInvalidException { + synchronized(lock) { + if (!isClosed) { + throw new BankAccountActionInvalidException("Account already open"); + } + isClosed = false; + balance = 0; + } + } + + void close() throws BankAccountActionInvalidException { + synchronized(lock) { + if (isClosed) { + throw new BankAccountActionInvalidException("Account not open"); + } + isClosed = true; + } + } + + int getBalance() throws BankAccountActionInvalidException { + synchronized(lock) { + checkIfClosed(); + return balance; + } + } + + void deposit(int amount) throws BankAccountActionInvalidException { + synchronized(lock) { + checkIfClosed(); + checkIfValidAmount(amount); + + balance += amount; + } + } + + void withdraw(int amount) throws BankAccountActionInvalidException { + synchronized(lock) { + checkIfClosed(); + checkIfValidAmount(amount); + checkIfEnoughMoneyInAccount(amount); + + balance -= amount; + } + } + + private void checkIfValidAmount(int amount) throws BankAccountActionInvalidException { + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + } + + private void checkIfEnoughMoneyInAccount(int amount) throws BankAccountActionInvalidException { + if (balance == 0) { + throw new BankAccountActionInvalidException("Cannot withdraw money from an empty account"); + } + if (balance - amount < 0) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + } + + private void checkIfClosed() throws BankAccountActionInvalidException { + if (isClosed) { + throw new BankAccountActionInvalidException("Account closed"); + } + } +} +``` + +For more information, check the [Synchronized statements approach][approach-synchronized-statements]. + +## Approach: Reentrant lock + +```java +import java.util.concurrent.locks.ReentrantLock; + +class BankAccount { + + private final ReentrantLock lock = new ReentrantLock(); + + private boolean isOpen = false; + private int balance = 0; + + void open() throws BankAccountActionInvalidException { + lock.lock(); + try { + if (isOpen) { + throw new BankAccountActionInvalidException("Account already open"); + } + isOpen = true; + balance = 0; + } finally { + lock.unlock(); + } + } + + void close() throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account not open"); + } + isOpen = false; + } finally { + lock.unlock(); + } + } + + int getBalance() throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + return balance; + } finally { + lock.unlock(); + } + } + + void deposit(int amount) throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance += amount; + } finally { + lock.unlock(); + } + } + + void withdraw(int amount) throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount > balance) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance -= amount; + } finally { + lock.unlock(); + } + } + +} +``` + +For more information, check the [Reentrant lock approach][approach-reentrant-lock]. + +## Approach: Read write lock + +```java +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +class BankAccount { + + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + private boolean isOpen = false; + + private int balance = 0; + + void open() throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (isOpen) { + throw new BankAccountActionInvalidException("Account already open"); + } + isOpen = true; + balance = 0; + } finally { + lock.writeLock().unlock(); + } + } + + void close() throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account not open"); + } + isOpen = false; + } finally { + lock.writeLock().unlock(); + } + } + + int getBalance() throws BankAccountActionInvalidException { + lock.readLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + return balance; + } finally { + lock.readLock().unlock(); + } + } + + void deposit(int amount) throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance += amount; + } finally { + lock.writeLock().unlock(); + } + } + + void withdraw(int amount) throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount > balance) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance -= amount; + } finally { + lock.writeLock().unlock(); + } + } +} +``` + +For more information, check the [Read write lock approach][approach-read-write-lock]. + +## Which approach to use? + +- The synchronized methods is the simplest, requiring no extra objects to be created. +- Synchronized statements provide greater control over which code statements are performed with a lock and which object is to be used as the lock. +- The read write lock allows greater concurrency by letting multiple read operations, such as `getBalance`, run in parallel. + However, it requires the lock to be explicitly released. + +[approach-read-write-lock]: https://exercism.org/tracks/java/exercises/bank-account/approaches/readwrite-lock +[approach-reentrant-lock]: https://exercism.org/tracks/java/exercises/bank-acconuunt/approaches/reentrant-lock +[approach-synchronized-methods]: https://exercism.org/tracks/java/exercises/bank-account/approaches/synchronized-methods +[approach-synchronized-statements]: https://exercism.org/tracks/java/exercises/bank-account/approaches/synchronzied-statements diff --git a/exercises/practice/bank-account/.approaches/readwrite-lock/content.md b/exercises/practice/bank-account/.approaches/readwrite-lock/content.md new file mode 100644 index 000000000..5db33cc0a --- /dev/null +++ b/exercises/practice/bank-account/.approaches/readwrite-lock/content.md @@ -0,0 +1,108 @@ +# Readwrite Lock + +```java +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +class BankAccount { + + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + private boolean isOpen = false; + + private int balance = 0; + + void open() throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (isOpen) { + throw new BankAccountActionInvalidException("Account already open"); + } + isOpen = true; + balance = 0; + } finally { + lock.writeLock().unlock(); + } + } + + void close() throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account not open"); + } + isOpen = false; + } finally { + lock.writeLock().unlock(); + } + } + + int getBalance() throws BankAccountActionInvalidException { + lock.readLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + return balance; + } finally { + lock.readLock().unlock(); + } + } + + void deposit(int amount) throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance += amount; + } finally { + lock.writeLock().unlock(); + } + } + + void withdraw(int amount) throws BankAccountActionInvalidException { + lock.writeLock().lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount > balance) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance -= amount; + } finally { + lock.writeLock().unlock(); + } + } +} +``` + +A [ReadWriteLock][docs-readwritelock] provides two types of locks - one for reading, the other for writing. +[ReentrantReadWriteLock][docs-reentrantreadwritelock] is an implementation of a [ReadWriteLock][docs-readwritelock]. + +Read locks are intended for read-only type operations, such as `getBalance`, and are acquired by calling `readLock().lock()` on the [ReadWriteLock][docs-readwritelock]. +Multiple threads are allowed to acquire read locks at the same time because they are expected to only read data. +This means multiple threads can run `getBalance` at the same time. + +Write locks are for write operations, such as `withdraw` and `deposit`. +It is also used in `open` and `close` as they change the state of the `BankAccount` (they "write" to the `isOpen` field). +Write locks are acquired by calling `writeLock().lock()` on the [ReadWriteLock][docs-readwritelock]. + +Only one thread can hold a write lock at a time. +Therefore, `withdraw`, `deposit`, `open` and `close` can not run at the same time. +Additionally, a thread must _also_ wait for _all_ read locks to be released to obtain a write lock. +Similarly, threads must wait for write locks to be released before they are granted a read lock. +This means `getBalance` also can not run at the same time as any of the `withdraw`, `deposit`, `open` and `close` methods. + +The locks are released in the `finally` block to ensure they are released, even when an exception is thrown. + +[docs-readwritelock]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReadWriteLock.html +[docs-reentrantreadwritelock]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReentrantReadWriteLock.html diff --git a/exercises/practice/bank-account/.approaches/readwrite-lock/snippet.txt b/exercises/practice/bank-account/.approaches/readwrite-lock/snippet.txt new file mode 100644 index 000000000..45fcdf98d --- /dev/null +++ b/exercises/practice/bank-account/.approaches/readwrite-lock/snippet.txt @@ -0,0 +1,7 @@ +private final ReadWriteLock lock = new ReentrantReadWriteLock(); +lock.readLock().lock(); +try { + balance += amount; +} finally { + lock.readLock().unlock(); +} \ No newline at end of file diff --git a/exercises/practice/bank-account/.approaches/reentrant-lock/content.md b/exercises/practice/bank-account/.approaches/reentrant-lock/content.md new file mode 100644 index 000000000..efa9f9512 --- /dev/null +++ b/exercises/practice/bank-account/.approaches/reentrant-lock/content.md @@ -0,0 +1,96 @@ +# Reentrant Lock + +```java +import java.util.concurrent.locks.ReentrantLock; + +class BankAccount { + + private final ReentrantLock lock = new ReentrantLock(); + + private boolean isOpen = false; + private int balance = 0; + + void open() throws BankAccountActionInvalidException { + lock.lock(); + try { + if (isOpen) { + throw new BankAccountActionInvalidException("Account already open"); + } + isOpen = true; + balance = 0; + } finally { + lock.unlock(); + } + } + + void close() throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account not open"); + } + isOpen = false; + } finally { + lock.unlock(); + } + } + + int getBalance() throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + return balance; + } finally { + lock.unlock(); + } + } + + void deposit(int amount) throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance += amount; + } finally { + lock.unlock(); + } + } + + void withdraw(int amount) throws BankAccountActionInvalidException { + lock.lock(); + try { + if (!isOpen) { + throw new BankAccountActionInvalidException("Account closed"); + } + if (amount > balance) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + balance -= amount; + } finally { + lock.unlock(); + } + } + +} +``` + +A [ReentrantLock][docs-reentrantlock] object represents a lock that threads must acquire to perform certain operations. +It is used here by the operation methods to ensure they are not trying to update the bank account at the same time. + +The lock is requested by calling [lock][docs-reentrantlock-lock]. +The lock is released at the end of the operation by calling [unlock][docs-reentrantlock-unlock] in a `finally` block. +This is important to ensure that the lock is released when it is no longer needed, especially if an exception is thrown. +The re-entrant nature of the lock means a thread will be granted a lock again if it already has the lock. + +[docs-reentrantlock]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReentrantLock.html +[docs-reentrantlock-lock]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReentrantLock.html#lock() +[docs-reentrantlock-unlock]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReentrantLock.html#unlock() diff --git a/exercises/practice/bank-account/.approaches/reentrant-lock/snippet.txt b/exercises/practice/bank-account/.approaches/reentrant-lock/snippet.txt new file mode 100644 index 000000000..2014610f8 --- /dev/null +++ b/exercises/practice/bank-account/.approaches/reentrant-lock/snippet.txt @@ -0,0 +1,7 @@ +private final ReentrantLock lock = new ReentrantLock(); +lock.lock(); +try { + balance += amount; +} finally { + lock.unlock(); +} \ No newline at end of file diff --git a/exercises/practice/bank-account/.approaches/synchronized-methods/content.md b/exercises/practice/bank-account/.approaches/synchronized-methods/content.md new file mode 100644 index 000000000..7c1730694 --- /dev/null +++ b/exercises/practice/bank-account/.approaches/synchronized-methods/content.md @@ -0,0 +1,77 @@ +# Synchronized methods + +```java +class BankAccount { + private int balance = 0; + private boolean isClosed = true; + + synchronized void open() throws BankAccountActionInvalidException { + if (!isClosed) { + throw new BankAccountActionInvalidException("Account already open"); + } + isClosed = false; + balance = 0; + } + + synchronized void close() throws BankAccountActionInvalidException { + if (isClosed) { + throw new BankAccountActionInvalidException("Account not open"); + } + isClosed = true; + } + + synchronized int getBalance() throws BankAccountActionInvalidException { + checkIfClosed(); + return balance; + } + + synchronized void deposit(int amount) throws BankAccountActionInvalidException { + checkIfClosed(); + checkIfValidAmount(amount); + + balance += amount; + } + + synchronized void withdraw(int amount) throws BankAccountActionInvalidException { + checkIfClosed(); + checkIfValidAmount(amount); + checkIfEnoughMoneyInAccount(amount); + + balance -= amount; + } + + private void checkIfValidAmount(int amount) throws BankAccountActionInvalidException { + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + } + + private void checkIfEnoughMoneyInAccount(int amount) throws BankAccountActionInvalidException { + if (balance == 0) { + throw new BankAccountActionInvalidException("Cannot withdraw money from an empty account"); + } + if (balance - amount < 0) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + } + + private void checkIfClosed() throws BankAccountActionInvalidException { + if (isClosed) { + throw new BankAccountActionInvalidException("Account closed"); + } + } +} +``` + +Each operation method is marked `synchronized`. +This tells the thread to acquire a lock on the `BankAccount` object _before_ executing the method. +If any other thread holds a lock on the `BankAccount` object, it must wait for the other thread to release the lock. + +~~~~exercism/note +In Java, the is one other way to acquire a lock on the `BankAccount` object - [synchronized statements][approach-synchronized-statements]. +Since synchronized methods use a lock on the `BankAccount` object, it will also have to wait for locks on the `BankAccount` that are used by [synchronized statements][approach-synchronized-statements] to be reused. + +[approach-synchronized-statements]: https://exercism.org/tracks/java/exercises/bank-account/approaches/synchronzied-statements +~~~~ + +The lock is automatically released when the method finishes. diff --git a/exercises/practice/bank-account/.approaches/synchronized-methods/snippet.txt b/exercises/practice/bank-account/.approaches/synchronized-methods/snippet.txt new file mode 100644 index 000000000..61ca7d4ec --- /dev/null +++ b/exercises/practice/bank-account/.approaches/synchronized-methods/snippet.txt @@ -0,0 +1,3 @@ +synchronized void deposit(int amount) throws BankAccountActionInvalidException { + balance += amount; +} \ No newline at end of file diff --git a/exercises/practice/bank-account/.approaches/synchronized-statements/content.md b/exercises/practice/bank-account/.approaches/synchronized-statements/content.md new file mode 100644 index 000000000..8d17806b1 --- /dev/null +++ b/exercises/practice/bank-account/.approaches/synchronized-statements/content.md @@ -0,0 +1,123 @@ +# Synchronized statements + +```java +class BankAccount { + private final Object lock = new Object(); + private int balance = 0; + private boolean isClosed = true; + + void open() throws BankAccountActionInvalidException { + synchronized(lock) { + if (!isClosed) { + throw new BankAccountActionInvalidException("Account already open"); + } + isClosed = false; + balance = 0; + } + } + + void close() throws BankAccountActionInvalidException { + synchronized(lock) { + if (isClosed) { + throw new BankAccountActionInvalidException("Account not open"); + } + isClosed = true; + } + } + + int getBalance() throws BankAccountActionInvalidException { + synchronized(lock) { + checkIfClosed(); + return balance; + } + } + + void deposit(int amount) throws BankAccountActionInvalidException { + synchronized(lock) { + checkIfClosed(); + checkIfValidAmount(amount); + + balance += amount; + } + } + + void withdraw(int amount) throws BankAccountActionInvalidException { + synchronized(lock) { + checkIfClosed(); + checkIfValidAmount(amount); + checkIfEnoughMoneyInAccount(amount); + + balance -= amount; + } + } + + private void checkIfValidAmount(int amount) throws BankAccountActionInvalidException { + if (amount < 0) { + throw new BankAccountActionInvalidException("Cannot deposit or withdraw negative amount"); + } + } + + private void checkIfEnoughMoneyInAccount(int amount) throws BankAccountActionInvalidException { + if (balance == 0) { + throw new BankAccountActionInvalidException("Cannot withdraw money from an empty account"); + } + if (balance - amount < 0) { + throw new BankAccountActionInvalidException("Cannot withdraw more money than is currently in the account"); + } + } + + private void checkIfClosed() throws BankAccountActionInvalidException { + if (isClosed) { + throw new BankAccountActionInvalidException("Account closed"); + } + } +} +``` + +In this approach, the operation methods, such as `open`, `close`, `deposit` and `withdraw`, perform their operations in a `synchronized` code block. +A lock is acquired on the synchronized object (`lock`) before the statements inside the block are executed. +If another thread has a lock on the object, it must wait for it to be released. +The lock is released after the block is executed. + +## Using `this` as the synchronized object + +Any object can be used as the lock, including `this`. +For example: + +```java +int getBalance() throws BankAccountActionInvalidException { + synchronized(this) { + checkIfClosed(); + return balance; + } +} +``` + +This is the same as using a [synchronized method][approach-synchronized-methods], which requires a lock on the same `this` object to run the method. +For example: + +```java +synchronized int getBalance() throws BankAccountActionInvalidException { + checkIfClosed(); + return balance; +} +``` + +When using [synchronized methods][approach-synchronized-methods] and `synchronized(this)`, it is important to keep in mind that it may be trying to acquire a lock on the same instance. +For example: + +```java +BankAccount account = new BankAccount(); + +Thread thread1 = new Thread(() -> { + account.withdraw(5); +}); + +Thread thread2 = new Thread(() -> { + synchronized (account) { + // Code in here can not run at same time as account.withdraw in thread1. + } +}); +``` + +[approach-synchronized-methods]: https://exercism.org/tracks/java/exercises/bank-account/approaches/synchronized-methods diff --git a/exercises/practice/bank-account/.approaches/synchronized-statements/snippet.txt b/exercises/practice/bank-account/.approaches/synchronized-statements/snippet.txt new file mode 100644 index 000000000..6b3a368fb --- /dev/null +++ b/exercises/practice/bank-account/.approaches/synchronized-statements/snippet.txt @@ -0,0 +1,7 @@ +private final Object lock = new Object(); + +void deposit(int amount) throws BankAccountActionInvalidException { + synchronized(lock) { + balance += amount; + } +} \ No newline at end of file diff --git a/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/bank-account/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/bank-account/gradlew b/exercises/practice/bank-account/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/bank-account/gradlew +++ b/exercises/practice/bank-account/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/bank-account/gradlew.bat b/exercises/practice/bank-account/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/bank-account/gradlew.bat +++ b/exercises/practice/bank-account/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/binary-search-tree/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/binary-search-tree/gradlew b/exercises/practice/binary-search-tree/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/binary-search-tree/gradlew +++ b/exercises/practice/binary-search-tree/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/binary-search-tree/gradlew.bat b/exercises/practice/binary-search-tree/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/binary-search-tree/gradlew.bat +++ b/exercises/practice/binary-search-tree/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/binary-search/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/binary-search/gradlew b/exercises/practice/binary-search/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/binary-search/gradlew +++ b/exercises/practice/binary-search/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/binary-search/gradlew.bat b/exercises/practice/binary-search/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/binary-search/gradlew.bat +++ b/exercises/practice/binary-search/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/bob/.meta/config.json b/exercises/practice/bob/.meta/config.json index a86461574..9ca96efa4 100644 --- a/exercises/practice/bob/.meta/config.json +++ b/exercises/practice/bob/.meta/config.json @@ -42,5 +42,5 @@ }, "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", - "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" + "source_url": "https://pine.fm/LearnToProgram/chap_06.html" } diff --git a/exercises/practice/bob/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/bob/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/bob/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/bob/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/bob/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/bob/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/bob/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/bob/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/bob/gradlew b/exercises/practice/bob/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/bob/gradlew +++ b/exercises/practice/bob/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/bob/gradlew.bat b/exercises/practice/bob/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/bob/gradlew.bat +++ b/exercises/practice/bob/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/book-store/.meta/config.json b/exercises/practice/book-store/.meta/config.json index 229853057..2f53eaa88 100644 --- a/exercises/practice/book-store/.meta/config.json +++ b/exercises/practice/book-store/.meta/config.json @@ -37,5 +37,5 @@ }, "blurb": "To try and encourage more sales of different books from a popular 5 book series, a bookshop has decided to offer discounts of multiple-book purchases.", "source": "Inspired by the harry potter kata from Cyber-Dojo.", - "source_url": "https://cyber-dojo.org" + "source_url": "https://cyber-dojo.org/creator/home" } diff --git a/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/book-store/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/book-store/gradlew b/exercises/practice/book-store/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/book-store/gradlew +++ b/exercises/practice/book-store/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/book-store/gradlew.bat b/exercises/practice/book-store/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/book-store/gradlew.bat +++ b/exercises/practice/book-store/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/bottle-song/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/bottle-song/gradlew b/exercises/practice/bottle-song/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/bottle-song/gradlew +++ b/exercises/practice/bottle-song/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/bottle-song/gradlew.bat b/exercises/practice/bottle-song/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/bottle-song/gradlew.bat +++ b/exercises/practice/bottle-song/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/bowling/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/bowling/gradlew b/exercises/practice/bowling/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/bowling/gradlew +++ b/exercises/practice/bowling/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/bowling/gradlew.bat b/exercises/practice/bowling/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/bowling/gradlew.bat +++ b/exercises/practice/bowling/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/camicia/.docs/instructions.md b/exercises/practice/camicia/.docs/instructions.md new file mode 100644 index 000000000..db62fcef2 --- /dev/null +++ b/exercises/practice/camicia/.docs/instructions.md @@ -0,0 +1,84 @@ +# Instructions + +In this exercise, you will simulate a game very similar to the classic card game **Camicia**. +Your program will receive the initial configuration of two players' decks and must simulate the game until it ends (or detect that it will never end). + +## Rules + +- The deck is split between **two players**. + The player's cards are read from left to right, where the leftmost card is the top of the deck. +- A round consists of both players playing at least one card. +- Players take turns placing the **top card** of their deck onto a central pile. +- If the card is a **number card** (2-10), play simply passes to the other player. +- If the card is a **payment card**, a penalty must be paid: + - **J** → opponent must pay 1 card + - **Q** → opponent must pay 2 cards + - **K** → opponent must pay 3 cards + - **A** → opponent must pay 4 cards +- If the player paying a penalty reveals another payment card, that player stops paying the penalty. + The other player must then pay a penalty based on the new payment card. +- If the penalty is fully paid without interruption, the player who placed the **last payment card** collects the central pile and places it at the bottom of their deck. + That player then starts the next round. +- If a player runs out of cards and is unable to play a card (either while paying a penalty or when it is their turn), the other player collects the central pile. +- The moment when a player collects cards from the central pile is called a **trick**. +- If a player has all the cards in their possession after a trick, the game **ends**. +- The game **enters a loop** as soon as the decks are identical to what they were earlier during the game, **not** counting number cards! + +## Examples + +A small example of a match that ends. + +| Round | Player A | Player B | Pile | Penalty Due | +| :---- | :----------- | :------------------------- | :------------------------- | :---------- | +| 1 | 2 A 7 8 Q 10 | 3 4 5 6 K 9 J | | - | +| 1 | A 7 8 Q 10 | 3 4 5 6 K 9 J | 2 | - | +| 1 | A 7 8 Q 10 | 4 5 6 K 9 J | 2 3 | - | +| 1 | 7 8 Q 10 | 4 5 6 K 9 J | 2 3 A | Player B: 4 | +| 1 | 7 8 Q 10 | 5 6 K 9 J | 2 3 A 4 | Player B: 3 | +| 1 | 7 8 Q 10 | 6 K 9 J | 2 3 A 4 5 | Player B: 2 | +| 1 | 7 8 Q 10 | K 9 J | 2 3 A 4 5 6 | Player B: 1 | +| 1 | 7 8 Q 10 | 9 J | 2 3 A 4 5 6 K | Player A: 3 | +| 1 | 8 Q 10 | 9 J | 2 3 A 4 5 6 K 7 | Player A: 2 | +| 1 | Q 10 | 9 J | 2 3 A 4 5 6 K 7 8 | Player A: 1 | +| 1 | 10 | 9 J | 2 3 A 4 5 6 K 7 8 Q | Player B: 2 | +| 1 | 10 | J | 2 3 A 4 5 6 K 7 8 Q 9 | Player B: 1 | +| 1 | 10 | - | 2 3 A 4 5 6 K 7 8 Q 9 J | Player A: 1 | +| 1 | - | - | 2 3 A 4 5 6 K 7 8 Q 9 J 10 | - | +| 2 | - | 2 3 A 4 5 6 K 7 8 Q 9 J 10 | - | - | + +status: `"finished"`, cards: 13, tricks: 1 + +This is a small example of a match that loops. + +| Round | Player A | Player B | Pile | Penalty Due | +| :---- | :------- | :------- | :---- | :---------- | +| 1 | J 2 3 | 4 J 5 | - | - | +| 1 | 2 3 | 4 J 5 | J | Player B: 1 | +| 1 | 2 3 | J 5 | J 4 | - | +| 2 | 2 3 J 4 | J 5 | - | - | +| 2 | 3 J 4 | J 5 | 2 | - | +| 2 | 3 J 4 | 5 | 2 J | Player A: 1 | +| 2 | J 4 | 5 | 2 J 3 | - | +| 3 | J 4 | 5 2 J 3 | - | - | +| 3 | J 4 | 2 J 3 | 5 | - | +| 3 | 4 | 2 J 3 | 5 J | Player B: 1 | +| 3 | 4 | J 3 | 5 J 2 | - | +| 4 | 4 5 J 2 | J 3 | - | - | + +The start of round 4 matches the start of round 2. +Recall, the value of the number cards does not matter. + +status: `"loop"`, cards: 8, tricks: 3 + +## Your Task + +- Using the input, simulate the game following the rules above. +- Determine the following information regarding the game: + - **Status**: `"finished"` or `"loop"` + - **Cards**: total number of cards played throughout the game + - **Tricks**: number of times the central pile was collected + +~~~~exercism/advanced +For those who want to take on a more exciting challenge, the hunt for other records for the longest game with an end is still open. +There are 653,534,134,886,878,245,000 (approximately 654 quintillion) possibilities, and we haven't calculated them all yet! +~~~~ diff --git a/exercises/practice/camicia/.docs/introduction.md b/exercises/practice/camicia/.docs/introduction.md new file mode 100644 index 000000000..761d8a82c --- /dev/null +++ b/exercises/practice/camicia/.docs/introduction.md @@ -0,0 +1,24 @@ +# Introduction + +One rainy afternoon, you sit at the kitchen table playing cards with your grandmother. +The game is her take on [Camicia][bmn]. + +At first it feels like just another friendly match: cards slapped down, laughter across the table, the occasional victorious grin from Nonna. +But as the game stretches on, something strange happens. +The same cards keep cycling back. +You play card after card, yet the end never seems to come. + +You start to wonder. +_Will this game ever finish? +Or could we keep playing forever?_ + +Later, driven by curiosity, you search online and to your surprise you discover that what happened wasn't just bad luck. +You and your grandmother may have stumbled upon one of the longest possible sequences! +Suddenly, you're hooked. +What began as a casual game has turned into a quest: _how long can such a game really last?_ +_Can you find a sequence even longer than the one you played at the kitchen table?_ +_Perhaps even long enough to set a new world record?_ + +And so, armed with nothing but a deck of cards and some algorithmic ingenuity, you decide to investigate... + +[bmn]: https://en.wikipedia.org/wiki/Beggar-my-neighbour diff --git a/exercises/practice/camicia/.meta/config.json b/exercises/practice/camicia/.meta/config.json new file mode 100644 index 000000000..ea3ae3242 --- /dev/null +++ b/exercises/practice/camicia/.meta/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "thibault2705" + ], + "files": { + "solution": [ + "src/main/java/Camicia.java", + "src/main/java/CamiciaResult.java" + ], + "test": [ + "src/test/java/CamiciaTest.java" + ], + "example": [ + ".meta/src/reference/java/Camicia.java", + ".meta/src/reference/java/CamiciaResult.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Simulate the card game and determine whether the match ends or enters an infinite loop.", + "source": "Beggar-My-Neighbour", + "source_url": "https://www.richardpmann.com/beggar-my-neighbour-records.html" +} diff --git a/exercises/practice/camicia/.meta/src/reference/java/Camicia.java b/exercises/practice/camicia/.meta/src/reference/java/Camicia.java new file mode 100644 index 000000000..610558665 --- /dev/null +++ b/exercises/practice/camicia/.meta/src/reference/java/Camicia.java @@ -0,0 +1,156 @@ +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class Camicia { + + private Status status; + private int cards; + private int tricks; + + private enum Player { + PLAYER_A, PLAYER_B + } + + private enum Status { + FINISHED, LOOP + } + + private static int penaltyOf(String card) { + return switch (card) { + case "J" -> 1; + case "Q" -> 2; + case "K" -> 3; + case "A" -> 4; + default -> 0; + }; + } + + private static boolean isPaymentCard(String card) { + return penaltyOf(card) > 0; + } + + /** + * Return a snapshot of the current state + */ + private static String stateKey(Deque deckA, Deque deckB) { + StringBuilder sb = new StringBuilder(); + + for (String card : deckA) { + sb.append(isPaymentCard(card) ? card : "N"); + } + + sb.append('|'); + + for (String card : deckB) { + sb.append(isPaymentCard(card) ? card : "N"); + } + + return sb.toString(); + } + + private static Player otherPlayer(Player player) { + return player == Player.PLAYER_A ? Player.PLAYER_B : Player.PLAYER_A; + } + + private static Deque deckOf(Player player, Deque deckA, Deque deckB) { + return player == Player.PLAYER_A ? deckA : deckB; + } + + public static CamiciaResult simulateGame(List playerA, List playerB) { + Deque deckA = new ArrayDeque<>(playerA); + Deque deckB = new ArrayDeque<>(playerB); + + int cardsPlayed = 0; + int tricksCount = 0; + Player current = Player.PLAYER_A; + + Set seenStates = new HashSet<>(); + + while (true) { + String key = stateKey(deckA, deckB); + // Key already exists, which means this is a loop + if (!seenStates.add(key)) { + return finishGame(Status.LOOP, cardsPlayed, tricksCount); + } + + // Otherwise, play next round + RoundResult result = playRound(deckA, deckB, current); + + cardsPlayed += result.pileSize(); + tricksCount++; + + // Check if someone wins and finish the game + if (hasWinner(deckA, deckB)) { + return finishGame(Status.FINISHED, cardsPlayed, tricksCount); + } + + // Otherwise, play next round + current = result.nextStarter(); + } + } + + private static RoundResult playRound(Deque deckA, Deque deckB, Player startingPlayer) { + Deque pile = new ArrayDeque<>(); // cards played in this round + Player currentPlayer = startingPlayer; + int pendingPenalty = 0; + + while (true) { + Deque currentPlayerDeck = deckOf(currentPlayer, deckA, deckB); + Player opponent = otherPlayer(currentPlayer); + Deque opponentDeck = deckOf(opponent, deckA, deckB); + + // Current player deck is empty, opponent collects all pile, end this round + if (currentPlayerDeck.isEmpty()) { + opponentDeck.addAll(pile); + return new RoundResult(opponent, pile.size()); + } + + // Otherwise, current player plays 1 card, add to pile + String card = currentPlayerDeck.poll(); + pile.addLast(card); + + // Current player must pay off pending penalty + if (pendingPenalty > 0) { + // And player reveals a payment card + if (isPaymentCard(card)) { + // reset penalty based on new card, switch turn + pendingPenalty = penaltyOf(card); + currentPlayer = opponent; + } else { + // Otherwise, deduct penalty + pendingPenalty--; + // No pending penalty + if (pendingPenalty == 0) { + // Opponent collects all pile and win the round + deckOf(opponent, deckA, deckB).addAll(pile); + return new RoundResult(opponent, pile.size()); + } + } + } else { + // Normal gameplay, without pending penalty + // If player reveals a payment card, update penalty + if (isPaymentCard(card)) { + pendingPenalty = penaltyOf(card); + } + currentPlayer = opponent; + } + } + } + + private static CamiciaResult finishGame(Status status, int cardsPlayed, int tricksCount) { + return new CamiciaResult(status == null ? null : status.toString().toLowerCase(), cardsPlayed, tricksCount); + } + + private static boolean hasWinner(Deque deckA, Deque deckB) { + return deckA.isEmpty() || deckB.isEmpty(); + } + + /** + * Immutable round result + */ + private record RoundResult(Player nextStarter, int pileSize) { + } +} diff --git a/exercises/practice/camicia/.meta/src/reference/java/CamiciaResult.java b/exercises/practice/camicia/.meta/src/reference/java/CamiciaResult.java new file mode 100644 index 000000000..d064dc3ba --- /dev/null +++ b/exercises/practice/camicia/.meta/src/reference/java/CamiciaResult.java @@ -0,0 +1,6 @@ +/** + * {@link CamiciaResult} shows the result of a Camicia game + */ +public record CamiciaResult(String status, int cards, int tricks) { + +} diff --git a/exercises/practice/camicia/.meta/tests.toml b/exercises/practice/camicia/.meta/tests.toml new file mode 100644 index 000000000..18d3fdd99 --- /dev/null +++ b/exercises/practice/camicia/.meta/tests.toml @@ -0,0 +1,94 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[0b7f737c-3ecd-4a55-b34d-e65c62a85c28] +description = "two cards, one trick" + +[27c19d75-53a5-48e5-b33b-232c3884d4f3] +description = "three cards, one trick" + +[9b02dd49-efaf-4b71-adca-a05c18a7c5b0] +description = "four cards, one trick" + +[fa3f4479-466a-4734-a001-ab79bfe27260] +description = "the ace reigns supreme" + +[07629689-f589-4f54-a6d1-8ce22776ce72] +description = "the king beats ace" + +[54d4a1c5-76fb-4d1e-8358-0e0296ac0601] +description = "the queen seduces the king" + +[c875500c-ff3d-47a4-bd1e-b60b90da80aa] +description = "the jack betrays the queen" + +[436875da-96ca-4149-be22-0b78173b8125] +description = "the 10 just wants to put on a show" + +[5be39bb6-1b34-4ce6-a1cd-0fcc142bb272] +description = "simple loop with decks of 3 cards" + +[2795dc21-0a2a-4c38-87c2-5a42e1ff15eb] +description = "the story is starting to get a bit complicated" + +[6999dfac-3fdc-41e2-b64b-38f4be228712] +description = "two tricks" + +[83dcd4f3-e089-4d54-855a-73f5346543a3] +description = "more tricks" + +[3107985a-f43e-486a-9ce8-db51547a9941] +description = "simple loop with decks of 4 cards" + +[dca32c31-11ed-49f6-b078-79ab912c1f7b] +description = "easy card combination" + +[1f8488d0-48d3-45ae-b819-59cedad0a5f4] +description = "easy card combination, inverted decks" + +[98878d35-623a-4d05-b81a-7bdc569eb88d] +description = "mirrored decks" + +[3e0ba597-ca10-484b-87a3-31a7df7d6da3] +description = "opposite decks" + +[92334ddb-aaa7-47fa-ab36-e928a8a6a67c] +description = "random decks #1" + +[30477523-9651-4860-84a3-e1ac461bb7fa] +description = "random decks #2" + +[20967de8-9e94-4e0e-9010-14bc1c157432] +description = "Kleber 1999" + +[9f2fdfe8-27f3-4323-816d-6bce98a9c6f7] +description = "Collins 2006" + +[c90b6f8d-7013-49f3-b5cb-14ea006cca1d] +description = "Mann and Wu 2007" + +[a3f1fbc5-1d0b-499a-92a5-22932dfc6bc8] +description = "Nessler 2012" + +[9cefb1ba-e6d1-4ab7-9d8f-76d8e0976d5f] +description = "Anderson 2013" + +[d37c0318-5be6-48d0-ab72-a7aaaff86179] +description = "Rucklidge 2014" + +[4305e479-ba87-432f-8a29-cd2bd75d2f05] +description = "Nessler 2021" + +[252f5cc3-b86d-4251-87ce-f920b7a6a559] +description = "Nessler 2022" + +[b9efcfa4-842f-4542-8112-8389c714d958] +description = "Casella 2024, first infinite game found" diff --git a/exercises/practice/camicia/build.gradle b/exercises/practice/camicia/build.gradle new file mode 100644 index 000000000..d28f35dee --- /dev/null +++ b/exercises/practice/camicia/build.gradle @@ -0,0 +1,25 @@ +plugins { + id "java" +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation platform("org.junit:junit-bom:5.10.0") + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "org.assertj:assertj-core:3.25.1" + + testRuntimeOnly "org.junit.platform:junit-platform-launcher" +} + +test { + useJUnitPlatform() + + testLogging { + exceptionFormat = "full" + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/exercises/practice/camicia/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/camicia/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..b1b8ef56b Binary files /dev/null and b/exercises/practice/camicia/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/camicia/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/camicia/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..6394b4647 --- /dev/null +++ b/exercises/practice/camicia/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/exercises/practice/camicia/gradlew b/exercises/practice/camicia/gradlew new file mode 100755 index 000000000..b9bb139f7 --- /dev/null +++ b/exercises/practice/camicia/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/exercises/practice/camicia/gradlew.bat b/exercises/practice/camicia/gradlew.bat new file mode 100644 index 000000000..24c62d56f --- /dev/null +++ b/exercises/practice/camicia/gradlew.bat @@ -0,0 +1,82 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/camicia/src/main/java/Camicia.java b/exercises/practice/camicia/src/main/java/Camicia.java new file mode 100644 index 000000000..33688ace3 --- /dev/null +++ b/exercises/practice/camicia/src/main/java/Camicia.java @@ -0,0 +1,9 @@ +import java.util.List; + +public class Camicia { + + static CamiciaResult simulateGame(List playerA, List playerB) { + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); + } + +} diff --git a/exercises/practice/camicia/src/main/java/CamiciaResult.java b/exercises/practice/camicia/src/main/java/CamiciaResult.java new file mode 100644 index 000000000..d064dc3ba --- /dev/null +++ b/exercises/practice/camicia/src/main/java/CamiciaResult.java @@ -0,0 +1,6 @@ +/** + * {@link CamiciaResult} shows the result of a Camicia game + */ +public record CamiciaResult(String status, int cards, int tricks) { + +} diff --git a/exercises/practice/camicia/src/test/java/CamiciaTest.java b/exercises/practice/camicia/src/test/java/CamiciaTest.java new file mode 100644 index 000000000..f4f2b8e85 --- /dev/null +++ b/exercises/practice/camicia/src/test/java/CamiciaTest.java @@ -0,0 +1,514 @@ +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class CamiciaTest { + private static final String FINISHED = "finished"; + private static final String LOOP = "loop"; + + @Test + @DisplayName("two cards, one trick") + public void twoCardsOneTrick() { + List playerA = List.of("2"); + List playerB = List.of("3"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(2, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("three cards, one trick") + public void threeCardsOneTrick() { + List playerA = List.of("2", "4"); + List playerB = List.of("3"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(3, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("four cards, one trick") + public void fourCardsOneTrick() { + List playerA = List.of("2", "4"); + List playerB = List.of("3", "5", "6"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(4, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("the ace reigns supreme") + public void theAceReignsSupreme() { + List playerA = List.of("2", "A"); + List playerB = List.of("3", "4", "5", "6", "7"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("the king beats ace") + public void theKingBeatsAce() { + List playerA = List.of("2", "A"); + List playerB = List.of("3", "4", "5", "6", "K"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("the queen seduces the king") + public void theQueenSeducesTheKing() { + List playerA = List.of("2", "A", "7", "8", "Q"); + List playerB = List.of("3", "4", "5", "6", "K"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(10, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("the jack betrays the queen") + public void theJackBetraysTheQueen() { + List playerA = List.of("2", "A", "7", "8", "Q"); + List playerB = List.of("3", "4", "5", "6", "K", "9", "J"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(12, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("the 10 just wants to put on a show") + public void theTenJustWantsToPutOnAShow() { + List playerA = List.of("2", "A", "7", "8", "Q", "10"); + List playerB = List.of("3", "4", "5", "6", "K", "9", "J"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(13, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("simple loop with decks of 3 cards") + public void simpleLoopWithDecksOfThreeCards() { + List playerA = List.of("J", "2", "3"); + List playerB = List.of("4", "J", "5"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(LOOP, result.status()); + assertEquals(8, result.cards()); + assertEquals(3, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("the story is starting to get a bit complicated") + public void theStoryIsStartingToGetAbitComplicated() { + List playerA = List.of( + "2", "6", "6", "J", "4", "K", "Q", "10", "K", "J", "Q", "2", "3", "K", "5", "6", "Q", "Q", "A", "A", + "6", "9", "K", "A", "8", "K", "2", "A", "9", "A", "Q", "4", "K", "K", "K", "3", "5", "K", "8", "Q", + "3", "Q", "7", "J", "K", "J", "9", "J", "3", "3", "K", "K", "Q", "A", "K", "7", "10", "A", "Q", "7", + "10", "J", "4", "5", "J", "9", "10", "Q", "J", "J", "K", "6", "10", "J", "6", "Q", "J", "5", "J", "Q", + "Q", "8", "3", "8", "A", "2", "6", "9", "K", "7", "J", "K", "K", "8", "K", "Q", "6", "10", "J", "10", + "J", "Q", "J", "10", "3", "8", "K", "A", "6", "9", "K", "2", "A", "A", "10", "J", "6", "A", "4", "J", + "A", "J", "J", "6", "2", "J", "3", "K", "2", "5", "9", "J", "9", "6", "K", "A", "5", "Q", "J", "2", + "Q", "K", "A", "3", "K", "J", "K", "2", "5", "6", "Q", "J", "Q", "Q", "J", "2", "J", "9", "Q", "7", + "7", "A", "Q", "7", "Q", "J", "K", "J", "A", "7", "7", "8", "Q", "10", "J", "10", "J", "J", "9", "2", + "A", "2" + ); + List playerB = List.of( + "7", "2", "10", "K", "8", "2", "J", "9", "A", "5", "6", "J", "Q", "6", "K", "6", "5", "A", "4", "Q", + "7", "J", "7", "10", "2", "Q", "8", "2", "2", "K", "J", "A", "5", "5", "A", "4", "Q", "6", "Q", "K", + "10", "8", "Q", "2", "10", "J", "A", "Q", "8", "Q", "Q", "J", "J", "A", "A", "9", "10", "J", "K", "4", + "Q", "10", "10", "J", "K", "10", "2", "J", "7", "A", "K", "K", "J", "A", "J", "10", "8", "K", "A", "7", + "Q", "Q", "J", "3", "Q", "4", "A", "3", "A", "Q", "Q", "Q", "5", "4", "K", "J", "10", "A", "Q", "J", + "6", "J", "A", "10", "A", "5", "8", "3", "K", "5", "9", "Q", "8", "7", "7", "J", "7", "Q", "Q", "Q", + "A", "7", "8", "9", "A", "Q", "A", "K", "8", "A", "A", "J", "8", "4", "8", "K", "J", "A", "10", "Q", + "8", "J", "8", "6", "10", "Q", "J", "J", "A", "A", "J", "5", "Q", "6", "J", "K", "Q", "8", "K", "4", + "Q", "Q", "6", "J", "K", "4", "7", "J", "J", "9", "9", "A", "Q", "Q", "K", "A", "6", "5", "K" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(361, result.cards()); + assertEquals(1, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("two tricks") + public void twoTricks() { + List playerA = List.of("J"); + List playerB = List.of("3", "J"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(5, result.cards()); + assertEquals(2, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("more tricks") + public void moreTricks() { + List playerA = List.of("J", "2", "4"); + List playerB = List.of("3", "J", "A"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(12, result.cards()); + assertEquals(4, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("simple loop with decks of 4 cards") + public void simpleLoopWithDecksOfFourCards() { + List playerA = List.of("2", "3", "J", "6"); + List playerB = List.of("K", "5", "J", "7"); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(LOOP, result.status()); + assertEquals(16, result.cards()); + assertEquals(4, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("easy card combination") + public void easyCardCombination() { + List playerA = List.of( + "4", "8", "7", "5", "4", "10", "3", "9", "7", "3", "10", "10", "6", "8", "2", "8", "5", "4", "5", + "9", "6", "5", "2", "8", "10", "9" + ); + List playerB = List.of( + "6", "9", "4", "7", "2", "2", "3", "6", "7", "3", "A", "A", "A", "A", "K", "K", "K", "K", "Q", "Q", + "Q", "Q", "J", "J", "J", "J" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(40, result.cards()); + assertEquals(4, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("easy card combination, inverted decks") + public void easyCardCombinationInvertedDecks() { + List playerA = List.of( + "3", "3", "5", "7", "3", "2", "10", "7", "6", "7", "A", "A", "A", "A", "K", "K", "K", "K", "Q", + "Q", "Q", "Q", "J", "J", "J", "J" + ); + List playerB = List.of( + "5", "10", "8", "2", "6", "7", "2", "4", "9", "2", "6", "10", "10", "5", "4", "8", "4", "8", "6", + "9", "8", "5", "9", "3", "4", "9" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(40, result.cards()); + assertEquals(4, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("mirrored decks") + public void mirroredDecks() { + List playerA = List.of( + "2", "A", "3", "A", "3", "K", "4", "K", "2", "Q", "2", "Q", "10", "J", "5", "J", "6", "10", "2", + "9", "10", "7", "3", "9", "6", "9" + ); + List playerB = List.of( + "6", "A", "4", "A", "7", "K", "4", "K", "7", "Q", "7", "Q", "5", "J", "8", "J", "4", "5", "8", + "9", "10", "6", "8", "3", "8", "5" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(59, result.cards()); + assertEquals(4, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("opposite decks") + public void oppositeDecks() { + List playerA = List.of( + "4", "A", "9", "A", "4", "K", "9", "K", "6", "Q", "8", "Q", "8", "J", "10", "J", "9", "8", "4", + "6", "3", "6", "5", "2", "4", "3" + ); + List playerB = List.of( + "10", "7", "3", "2", "9", "2", "7", "8", "7", "5", "J", "7", "J", "10", "Q", "10", "Q", "3", "K", + "5", "K", "6", "A", "2", "A", "5" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(151, result.cards()); + assertEquals(21, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("random decks #1") + public void randomDecksOne() { + List playerA = List.of( + "K", "10", "9", "8", "J", "8", "6", "9", "7", "A", "K", "5", "4", "4", "J", "5", "J", "4", "3", + "5", "8", "6", "7", "7", "4", "9" + ); + List playerB = List.of( + "6", "3", "K", "A", "Q", "10", "A", "2", "Q", "8", "2", "10", "10", "2", "Q", "3", "K", "9", "7", + "A", "3", "Q", "5", "J", "2", "6" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(542, result.cards()); + assertEquals(76, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("random decks #2") + public void randomDecksTwo() { + List playerA = List.of( + "8", "A", "4", "8", "5", "Q", "J", "2", "6", "2", "9", "7", "K", "A", "8", "10", "K", "8", "10", + "9", "K", "6", "7", "3", "K", "9" + ); + List playerB = List.of( + "10", "5", "2", "6", "Q", "J", "A", "9", "5", "5", "3", "7", "3", "J", "A", "2", "Q", "3", "J", + "Q", "4", "10", "4", "7", "4", "6" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(327, result.cards()); + assertEquals(42, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Kleber 1999") + public void kleber1999() { + List playerA = List.of( + "4", "8", "9", "J", "Q", "8", "5", "5", "K", "2", "A", "9", "8", "5", "10", "A", "4", "J", "3", + "K", "6", "9", "2", "Q", "K", "7" + ); + List playerB = List.of( + "10", "J", "3", "2", "4", "10", "4", "7", "5", "3", "6", "6", "7", "A", "J", "Q", "A", "7", "2", + "10", "3", "K", "9", "6", "8", "Q" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(5790, result.cards()); + assertEquals(805, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Collins 2006") + public void collins2006() { + List playerA = List.of( + "A", "8", "Q", "K", "9", "10", "3", "7", "4", "2", "Q", "3", "2", "10", "9", "K", "A", "8", "7", + "7", "4", "5", "J", "9", "2", "10" + ); + List playerB = List.of( + "4", "J", "A", "K", "8", "5", "6", "6", "A", "6", "5", "Q", "4", "6", "10", "8", "J", "2", "5", + "7", "Q", "J", "3", "3", "K", "9" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(6913, result.cards()); + assertEquals(960, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Mann and Wu 2007") + public void mannAndWu2007() { + List playerA = List.of( + "K", "2", "K", "K", "3", "3", "6", "10", "K", "6", "A", "2", "5", "5", "7", "9", "J", "A", "A", + "3", "4", "Q", "4", "8", "J", "6" + ); + List playerB = List.of( + "4", "5", "2", "Q", "7", "9", "9", "Q", "7", "J", "9", "8", "10", "3", "10", "J", "4", "10", "8", + "6", "8", "7", "A", "Q", "5", "2" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7157, result.cards()); + assertEquals(1007, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Nessler 2012") + public void nessler2012() { + List playerA = List.of( + "10", "3", "6", "7", "Q", "2", "9", "8", "2", "8", "4", "A", "10", "6", "K", "2", "10", "A", "5", + "A", "2", "4", "Q", "J", "K", "4" + ); + List playerB = List.of( + "10", "Q", "4", "6", "J", "9", "3", "J", "9", "3", "3", "Q", "K", "5", "9", "5", "K", "6", "5", + "7", "8", "J", "A", "7", "8", "7" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7207, result.cards()); + assertEquals(1015, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Anderson 2013") + public void anderson2013() { + List playerA = List.of( + "6", "7", "A", "3", "Q", "3", "5", "J", "3", "2", "J", "7", "4", "5", "Q", "10", "5", "A", "J", + "2", "K", "8", "9", "9", "K", "3" + ); + List playerB = List.of( + "4", "J", "6", "9", "8", "5", "10", "7", "9", "Q", "2", "7", "10", "8", "4", "10", "A", "6", "4", + "A", "6", "8", "Q", "K", "K", "2" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7225, result.cards()); + assertEquals(1016, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Rucklidge 2014") + public void rucklidge2014() { + List playerA = List.of( + "8", "J", "2", "9", "4", "4", "5", "8", "Q", "3", "9", "3", "6", "2", "8", "A", "A", "A", "9", + "4", "7", "2", "5", "Q", "Q", "3" + ); + List playerB = List.of( + "K", "7", "10", "6", "3", "J", "A", "7", "6", "5", "5", "8", "10", "9", "10", "4", "2", "7", "K", + "Q", "10", "K", "6", "J", "J", "K" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7959, result.cards()); + assertEquals(1122, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Nessler 2021") + public void nessler2021() { + List playerA = List.of( + "7", "2", "3", "4", "K", "9", "6", "10", "A", "8", "9", "Q", "7", "A", "4", "8", "J", "J", "A", + "4", "3", "2", "5", "6", "6", "J" + ); + List playerB = List.of( + "3", "10", "8", "9", "8", "K", "K", "2", "5", "5", "7", "6", "4", "3", "5", "7", "A", "9", "J", + "K", "2", "Q", "10", "Q", "10", "Q" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(7972, result.cards()); + assertEquals(1106, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Nessler 2022") + public void nessler2022() { + List playerA = List.of( + "2", "10", "10", "A", "J", "3", "8", "Q", "2", "5", "5", "5", "9", "2", "4", "3", "10", "Q", "A", + "K", "Q", "J", "J", "9", "Q", "K" + ); + List playerB = List.of( + "10", "7", "6", "3", "6", "A", "8", "9", "4", "3", "K", "J", "6", "K", "4", "9", "7", "8", "5", + "7", "8", "2", "A", "7", "4", "6" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(FINISHED, result.status()); + assertEquals(8344, result.cards()); + assertEquals(1164, result.tricks()); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Casella 2024, first infinite game found") + public void casella2024FirstInfiniteGameFound() { + List playerA = List.of( + "2", "8", "4", "K", "5", "2", "3", "Q", "6", "K", "Q", "A", "J", "3", "5", "9", "8", "3", "A", + "A", "J", "4", "4", "J", "7", "5" + ); + List playerB = List.of( + "7", "7", "8", "6", "10", "10", "6", "10", "7", "2", "Q", "6", "3", "2", "4", "K", "Q", "10", "J", + "5", "9", "8", "9", "9", "K", "A" + ); + + CamiciaResult result = Camicia.simulateGame(playerA, playerB); + + assertEquals(LOOP, result.status()); + assertEquals(474, result.cards()); + assertEquals(66, result.tricks()); + } +} diff --git a/exercises/practice/change/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/change/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/change/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/change/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/change/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/change/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/change/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/change/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/change/gradlew b/exercises/practice/change/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/change/gradlew +++ b/exercises/practice/change/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/change/gradlew.bat b/exercises/practice/change/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/change/gradlew.bat +++ b/exercises/practice/change/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/circular-buffer/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/circular-buffer/gradlew b/exercises/practice/circular-buffer/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/circular-buffer/gradlew +++ b/exercises/practice/circular-buffer/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/circular-buffer/gradlew.bat b/exercises/practice/circular-buffer/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/circular-buffer/gradlew.bat +++ b/exercises/practice/circular-buffer/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/clock/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/clock/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/clock/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/clock/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/clock/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/clock/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/clock/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/clock/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/clock/gradlew b/exercises/practice/clock/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/clock/gradlew +++ b/exercises/practice/clock/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/clock/gradlew.bat b/exercises/practice/clock/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/clock/gradlew.bat +++ b/exercises/practice/clock/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/collatz-conjecture/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/collatz-conjecture/gradlew b/exercises/practice/collatz-conjecture/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/collatz-conjecture/gradlew +++ b/exercises/practice/collatz-conjecture/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/collatz-conjecture/gradlew.bat b/exercises/practice/collatz-conjecture/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/collatz-conjecture/gradlew.bat +++ b/exercises/practice/collatz-conjecture/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/complex-numbers/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/complex-numbers/gradlew b/exercises/practice/complex-numbers/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/complex-numbers/gradlew +++ b/exercises/practice/complex-numbers/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/complex-numbers/gradlew.bat b/exercises/practice/complex-numbers/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/complex-numbers/gradlew.bat +++ b/exercises/practice/complex-numbers/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/connect/.meta/config.json b/exercises/practice/connect/.meta/config.json index 6674cd090..8731e2c8b 100644 --- a/exercises/practice/connect/.meta/config.json +++ b/exercises/practice/connect/.meta/config.json @@ -2,6 +2,9 @@ "authors": [ "kkyb123" ], + "contributors": [ + "thibault2705" + ], "files": { "solution": [ "src/main/java/Connect.java" diff --git a/exercises/practice/connect/.meta/tests.toml b/exercises/practice/connect/.meta/tests.toml index 6ada87732..951b87e5c 100644 --- a/exercises/practice/connect/.meta/tests.toml +++ b/exercises/practice/connect/.meta/tests.toml @@ -30,6 +30,12 @@ description = "nobody wins crossing adjacent angles" [cd61c143-92f6-4a8d-84d9-cb2b359e226b] description = "X wins crossing from left to right" +[495e33ed-30a9-4012-b46e-d7c4d5fe13c3] +description = "X wins with left-hand dead end fork" + +[ab167ab0-4a98-4d0f-a1c0-e1cddddc3d58] +description = "X wins with right-hand dead end fork" + [73d1eda6-16ab-4460-9904-b5f5dd401d0b] description = "O wins crossing from top to bottom" diff --git a/exercises/practice/connect/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/connect/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/connect/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/connect/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/connect/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/connect/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/connect/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/connect/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/connect/gradlew b/exercises/practice/connect/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/connect/gradlew +++ b/exercises/practice/connect/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/connect/gradlew.bat b/exercises/practice/connect/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/connect/gradlew.bat +++ b/exercises/practice/connect/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/connect/src/test/java/ConnectTest.java b/exercises/practice/connect/src/test/java/ConnectTest.java index 0bc3a12a2..ae32c9920 100644 --- a/exercises/practice/connect/src/test/java/ConnectTest.java +++ b/exercises/practice/connect/src/test/java/ConnectTest.java @@ -156,6 +156,50 @@ public void xWinsCrossingFromLeftToRight() { } + @Disabled("Remove to run test") + @Test + @DisplayName("X wins with left-hand dead end fork") + public void xWinsWithLeftHandDeadEndFork() { + + //GIVEN + var board = new String[]{ + ". . X .", + " X X . .", + " . X X X", + " O O O O" + }; + Connect cut = new Connect(board); + + //WHEN + var winner = cut.computeWinner(); + + //THEN + assertThat(winner).isEqualTo(Winner.PLAYER_X); + + } + + @Disabled("Remove to run test") + @Test + @DisplayName("X wins with right-hand dead end fork") + public void xWinsWithRightHandDeadEndFork() { + + //GIVEN + var board = new String[]{ + ". . X X", + " X X . .", + " . X X .", + " O O O O" + }; + Connect cut = new Connect(board); + + //WHEN + var winner = cut.computeWinner(); + + //THEN + assertThat(winner).isEqualTo(Winner.PLAYER_X); + + } + @Disabled("Remove to run test") @Test @DisplayName("O wins crossing from top to bottom") diff --git a/exercises/practice/crypto-square/.meta/config.json b/exercises/practice/crypto-square/.meta/config.json index 83572a7b4..5f8c77cc7 100644 --- a/exercises/practice/crypto-square/.meta/config.json +++ b/exercises/practice/crypto-square/.meta/config.json @@ -21,6 +21,7 @@ "sshine", "stkent", "vdemeester", + "Xinri", "Zaldrick" ], "files": { diff --git a/exercises/practice/crypto-square/.meta/tests.toml b/exercises/practice/crypto-square/.meta/tests.toml index 085d142ea..94ef0819f 100644 --- a/exercises/practice/crypto-square/.meta/tests.toml +++ b/exercises/practice/crypto-square/.meta/tests.toml @@ -32,3 +32,8 @@ description = "8 character plaintext results in 3 chunks, the last one with a tr [fbcb0c6d-4c39-4a31-83f6-c473baa6af80] description = "54 character plaintext results in 7 chunks, the last two with trailing spaces" +include = false + +[33fd914e-fa44-445b-8f38-ff8fbc9fe6e6] +description = "54 character plaintext results in 8 chunks, the last two with trailing spaces" +reimplements = "fbcb0c6d-4c39-4a31-83f6-c473baa6af80" diff --git a/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/crypto-square/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/crypto-square/gradlew b/exercises/practice/crypto-square/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/crypto-square/gradlew +++ b/exercises/practice/crypto-square/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/crypto-square/gradlew.bat b/exercises/practice/crypto-square/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/crypto-square/gradlew.bat +++ b/exercises/practice/crypto-square/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/crypto-square/src/test/java/CryptoSquareTest.java b/exercises/practice/crypto-square/src/test/java/CryptoSquareTest.java index b9a668a7a..9b9225487 100644 --- a/exercises/practice/crypto-square/src/test/java/CryptoSquareTest.java +++ b/exercises/practice/crypto-square/src/test/java/CryptoSquareTest.java @@ -77,8 +77,8 @@ public void eightCharacterPlaintextResultsInThreeChunksWithATrailingSpace() { @Disabled("Remove to run test") @Test - @DisplayName("54 character plaintext results in 7 chunks, the last two with trailing spaces") - public void fiftyFourCharacterPlaintextResultsInSevenChunksWithTrailingSpaces() { + @DisplayName("54 character plaintext results in 8 chunks, the last two with trailing spaces") + public void fiftyFourCharacterPlaintextResultsInEightChunksWithTrailingSpaces() { CryptoSquare cryptoSquare = new CryptoSquare("If man was meant to stay on the ground, god would have " + "given us roots."); String expectedOutput = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau "; diff --git a/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/custom-set/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/custom-set/gradlew b/exercises/practice/custom-set/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/custom-set/gradlew +++ b/exercises/practice/custom-set/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/custom-set/gradlew.bat b/exercises/practice/custom-set/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/custom-set/gradlew.bat +++ b/exercises/practice/custom-set/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/darts/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/darts/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/darts/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/darts/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/darts/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/darts/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/darts/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/darts/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/darts/gradlew b/exercises/practice/darts/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/darts/gradlew +++ b/exercises/practice/darts/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/darts/gradlew.bat b/exercises/practice/darts/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/darts/gradlew.bat +++ b/exercises/practice/darts/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/diamond/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/diamond/gradlew b/exercises/practice/diamond/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/diamond/gradlew +++ b/exercises/practice/diamond/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/diamond/gradlew.bat b/exercises/practice/diamond/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/diamond/gradlew.bat +++ b/exercises/practice/diamond/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/difference-of-squares/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/difference-of-squares/gradlew b/exercises/practice/difference-of-squares/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/difference-of-squares/gradlew +++ b/exercises/practice/difference-of-squares/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/difference-of-squares/gradlew.bat b/exercises/practice/difference-of-squares/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/difference-of-squares/gradlew.bat +++ b/exercises/practice/difference-of-squares/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/dnd-character/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/dnd-character/gradlew b/exercises/practice/dnd-character/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/dnd-character/gradlew +++ b/exercises/practice/dnd-character/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/dnd-character/gradlew.bat b/exercises/practice/dnd-character/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/dnd-character/gradlew.bat +++ b/exercises/practice/dnd-character/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/dnd-character/src/test/java/DnDCharacterTest.java b/exercises/practice/dnd-character/src/test/java/DnDCharacterTest.java index 1c9afc921..c54ad52ac 100644 --- a/exercises/practice/dnd-character/src/test/java/DnDCharacterTest.java +++ b/exercises/practice/dnd-character/src/test/java/DnDCharacterTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.List; @@ -10,150 +11,175 @@ public class DnDCharacterTest { private DnDCharacter dndCharacter = new DnDCharacter(); @Test + @DisplayName("ability modifier for score 3 is -4") public void testAbilityModifierForScore3IsNegative4() { assertThat(dndCharacter.modifier(3)).isEqualTo(-4); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 4 is -3") public void testAbilityModifierForScore4IsNegative3() { assertThat(dndCharacter.modifier(4)).isEqualTo(-3); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 5 is -3") public void testAbilityModifierForScore5IsNegative3() { assertThat(dndCharacter.modifier(5)).isEqualTo(-3); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 6 is -2") public void testAbilityModifierForScore6IsNegative2() { assertThat(dndCharacter.modifier(6)).isEqualTo(-2); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 7 is -2") public void testAbilityModifierForScore7IsNegative2() { assertThat(dndCharacter.modifier(7)).isEqualTo(-2); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 8 is -1") public void testAbilityModifierForScore8IsNegative1() { assertThat(dndCharacter.modifier(8)).isEqualTo(-1); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 9 is -1") public void testAbilityModifierForScore9IsNegative1() { assertThat(dndCharacter.modifier(9)).isEqualTo(-1); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 10 is 0") public void testAbilityModifierForScore10Is0() { assertThat(dndCharacter.modifier(10)).isEqualTo(0); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 11 is 0") public void testAbilityModifierForScore11Is0() { assertThat(dndCharacter.modifier(11)).isEqualTo(0); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 12 is +1") public void testAbilityModifierForScore12Is1() { assertThat(dndCharacter.modifier(12)).isEqualTo(1); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 13 is +1") public void testAbilityModifierForScore13Is1() { assertThat(dndCharacter.modifier(13)).isEqualTo(1); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 14 is +2") public void testAbilityModifierForScore14Is2() { assertThat(dndCharacter.modifier(14)).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 15 is +2") public void testAbilityModifierForScore15Is2() { assertThat(dndCharacter.modifier(15)).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 16 is +3") public void testAbilityModifierForScore16Is3() { assertThat(dndCharacter.modifier(16)).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 17 is +3") public void testAbilityModifierForScore17Is3() { assertThat(dndCharacter.modifier(17)).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("ability modifier for score 18 is +4") public void testAbilityModifierForScore18Is4() { assertThat(dndCharacter.modifier(18)).isEqualTo(4); } @Disabled("Remove to run test") @Test + @DisplayName("Rolling uses 4 dice") public void test4DiceWereUsedForRollingScores() { assertThat(dndCharacter.rollDice().size()).isEqualTo(4); } @Disabled("Remove to run test") @Test + @DisplayName("Dice values are between 1 and 6 inclusive") public void testDiceValuesBetween1And6() { assertThat(dndCharacter.rollDice()).allMatch(d -> d >= 1 && d <= 6); } @Disabled("Remove to run test") @Test + @DisplayName("Ability uses 3 largest numbers from scores in descending order") public void testAbilityCalculationsUses3LargestNumbersFromScoresInDescendingOrder() { assertThat(dndCharacter.ability(List.of(4, 3, 2, 1))).isEqualTo(9); } @Disabled("Remove to run test") @Test + @DisplayName("Ability uses 3 largest numbers from scores in ascending order") public void testAbilityCalculationsUses3LargestNumbersFromFromScoresInAscendingOrder() { assertThat(dndCharacter.ability(List.of(1, 2, 3, 4))).isEqualTo(9); } @Disabled("Remove to run test") @Test + @DisplayName("Ability uses 3 largest numbers from scores in random order") public void testAbilityCalculationsUses3LargestNumbersFromScoresInRandomOrder() { assertThat(dndCharacter.ability(List.of(2, 4, 3, 1))).isEqualTo(9); } @Disabled("Remove to run test") @Test + @DisplayName("Ability with all lowest equal numbers yields 3") public void testAbilityCalculationsWithLowestEqualNumbers() { assertThat(dndCharacter.ability(List.of(1, 1, 1, 1))).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("Ability with all highest equal numbers yields 18") public void testAbilityCalculationsWithHighestEqualNumbers() { assertThat(dndCharacter.ability(List.of(6, 6, 6, 6))).isEqualTo(18); } @Disabled("Remove to run test") @Test + @DisplayName("Ability calculation with two lowest numbers") public void testAbilityCalculationsWithTwoLowestNumbers() { assertThat(dndCharacter.ability(List.of(3, 5, 3, 4))).isEqualTo(12); } @Disabled("Remove to run test") @Test + @DisplayName("Ability calculation does not mutate input scores") public void testAbilityCalculationDoesNotChangeInputScores() { List scores = List.of(1, 2, 3, 4); dndCharacter.ability(scores); @@ -164,6 +190,7 @@ public void testAbilityCalculationDoesNotChangeInputScores() { @Disabled("Remove to run test") @Test + @DisplayName("random character is valid") public void testRandomCharacterIsValid() { for (int i = 0; i < 1000; i++) { DnDCharacter character = new DnDCharacter(); @@ -179,6 +206,7 @@ public void testRandomCharacterIsValid() { @Disabled("Remove to run test") @Test + @DisplayName("each ability is only calculated once") public void testEachAbilityIsOnlyCalculatedOnce() { assertThat(dndCharacter.getStrength()).isEqualTo(dndCharacter.getStrength()); assertThat(dndCharacter.getDexterity()).isEqualTo(dndCharacter.getDexterity()); @@ -190,6 +218,7 @@ public void testEachAbilityIsOnlyCalculatedOnce() { @Disabled("Remove to run test") @Test + @DisplayName("Each randomly created character should be unique in attributes") public void testUniqueCharacterIsCreated() { DnDCharacter uniqueDnDCharacter = new DnDCharacter(); for (int i = 0; i < 1000; i++) { diff --git a/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/dominoes/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/dominoes/gradlew b/exercises/practice/dominoes/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/dominoes/gradlew +++ b/exercises/practice/dominoes/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/dominoes/gradlew.bat b/exercises/practice/dominoes/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/dominoes/gradlew.bat +++ b/exercises/practice/dominoes/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/dot-dsl/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/dot-dsl/gradlew b/exercises/practice/dot-dsl/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/dot-dsl/gradlew +++ b/exercises/practice/dot-dsl/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/dot-dsl/gradlew.bat b/exercises/practice/dot-dsl/gradlew.bat index 93e3f59f1..24c62d56f 100644 --- a/exercises/practice/dot-dsl/gradlew.bat +++ b/exercises/practice/dot-dsl/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -43,13 +45,13 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -57,36 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/eliuds-eggs/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/eliuds-eggs/gradlew b/exercises/practice/eliuds-eggs/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/eliuds-eggs/gradlew +++ b/exercises/practice/eliuds-eggs/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/eliuds-eggs/gradlew.bat b/exercises/practice/eliuds-eggs/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/eliuds-eggs/gradlew.bat +++ b/exercises/practice/eliuds-eggs/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/error-handling/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/error-handling/gradlew b/exercises/practice/error-handling/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/error-handling/gradlew +++ b/exercises/practice/error-handling/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/error-handling/gradlew.bat b/exercises/practice/error-handling/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/error-handling/gradlew.bat +++ b/exercises/practice/error-handling/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/error-handling/src/test/java/ErrorHandlingTest.java b/exercises/practice/error-handling/src/test/java/ErrorHandlingTest.java index c7864c7ad..7459b687f 100644 --- a/exercises/practice/error-handling/src/test/java/ErrorHandlingTest.java +++ b/exercises/practice/error-handling/src/test/java/ErrorHandlingTest.java @@ -1,16 +1,18 @@ -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public class ErrorHandlingTest { private ErrorHandling errorHandling = new ErrorHandling(); @Test + @DisplayName("Throws IllegalArgumentException") public void testThrowIllegalArgumentException() { assertThatExceptionOfType(Exception.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingIllegalArgumentException()); @@ -18,6 +20,7 @@ public void testThrowIllegalArgumentException() { @Disabled("Remove to run test") @Test + @DisplayName("Throws IllegalArgumentException with provided detail message") public void testThrowIllegalArgumentExceptionWithDetailMessage() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingIllegalArgumentExceptionWithDetailMessage( @@ -27,6 +30,7 @@ public void testThrowIllegalArgumentExceptionWithDetailMessage() { @Disabled("Remove to run test") @Test + @DisplayName("Throws any checked exception") public void testThrowAnyCheckedException() { assertThatExceptionOfType(Exception.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyCheckedException()) @@ -35,6 +39,7 @@ public void testThrowAnyCheckedException() { @Disabled("Remove to run test") @Test + @DisplayName("Throws any checked exception with provided detail message") public void testThrowAnyCheckedExceptionWithDetailMessage() { assertThatExceptionOfType(Exception.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyCheckedExceptionWithDetailMessage( @@ -45,6 +50,7 @@ public void testThrowAnyCheckedExceptionWithDetailMessage() { @Disabled("Remove to run test") @Test + @DisplayName("Throws any unchecked exception") public void testThrowAnyUncheckedException() { assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyUncheckedException()); @@ -52,6 +58,7 @@ public void testThrowAnyUncheckedException() { @Disabled("Remove to run test") @Test + @DisplayName("Throws any unchecked exception with provided detail message") public void testThrowAnyUncheckedExceptionWithDetailMessage() { assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyUncheckedExceptionWithDetailMessage( @@ -61,6 +68,7 @@ public void testThrowAnyUncheckedExceptionWithDetailMessage() { @Disabled("Remove to run test") @Test + @DisplayName("Throws custom checked exception") public void testThrowCustomCheckedException() { assertThatExceptionOfType(CustomCheckedException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomCheckedException()); @@ -68,6 +76,7 @@ public void testThrowCustomCheckedException() { @Disabled("Remove to run test") @Test + @DisplayName("Throws custom checked exception with provided detail message") public void testThrowCustomCheckedExceptionWithDetailMessage() { assertThatExceptionOfType(CustomCheckedException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomCheckedExceptionWithDetailMessage( @@ -77,6 +86,7 @@ public void testThrowCustomCheckedExceptionWithDetailMessage() { @Disabled("Remove to run test") @Test + @DisplayName("Throws custom unchecked exception") public void testThrowCustomUncheckedException() { assertThatExceptionOfType(CustomUncheckedException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomUncheckedException()); @@ -84,6 +94,7 @@ public void testThrowCustomUncheckedException() { @Disabled("Remove to run test") @Test + @DisplayName("Throws custom unchecked exception with provided detail message") public void testThrowCustomUncheckedExceptionWithDetailMessage() { assertThatExceptionOfType(CustomUncheckedException.class) .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomUncheckedExceptionWithDetailMessage( @@ -93,6 +104,7 @@ public void testThrowCustomUncheckedExceptionWithDetailMessage() { @Disabled("Remove to run test") @Test + @DisplayName("Handles error by throwing Optional instance") public void testReturnOptionalInstance() { Optional successfulResult = errorHandling.handleErrorByReturningOptionalInstance("1"); assertThat(successfulResult).isPresent().hasValue(1); diff --git a/exercises/practice/etl/.meta/config.json b/exercises/practice/etl/.meta/config.json index a83e9ed7b..c23bd0ef1 100644 --- a/exercises/practice/etl/.meta/config.json +++ b/exercises/practice/etl/.meta/config.json @@ -42,5 +42,5 @@ }, "blurb": "Change the data format for scoring a game to more easily add other languages.", "source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.", - "source_url": "https://turing.edu" + "source_url": "https://www.turing.edu/" } diff --git a/exercises/practice/etl/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/etl/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/etl/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/etl/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/etl/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/etl/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/etl/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/etl/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/etl/gradlew b/exercises/practice/etl/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/etl/gradlew +++ b/exercises/practice/etl/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/etl/gradlew.bat b/exercises/practice/etl/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/etl/gradlew.bat +++ b/exercises/practice/etl/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/flatten-array/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/flatten-array/gradlew b/exercises/practice/flatten-array/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/flatten-array/gradlew +++ b/exercises/practice/flatten-array/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/flatten-array/gradlew.bat b/exercises/practice/flatten-array/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/flatten-array/gradlew.bat +++ b/exercises/practice/flatten-array/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/flower-field/.meta/tests.toml b/exercises/practice/flower-field/.meta/tests.toml index c2b24fdaf..965ba8fd4 100644 --- a/exercises/practice/flower-field/.meta/tests.toml +++ b/exercises/practice/flower-field/.meta/tests.toml @@ -44,3 +44,6 @@ description = "cross" [dd9d4ca8-9e68-4f78-a677-a2a70fd7a7b8] description = "large garden" + +[6e4ac13a-3e43-4728-a2e3-3551d4b1a996] +description = "multiple adjacent flowers" diff --git a/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/flower-field/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/flower-field/gradlew b/exercises/practice/flower-field/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/flower-field/gradlew +++ b/exercises/practice/flower-field/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/flower-field/gradlew.bat b/exercises/practice/flower-field/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/flower-field/gradlew.bat +++ b/exercises/practice/flower-field/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/flower-field/src/test/java/FlowerFieldBoardTest.java b/exercises/practice/flower-field/src/test/java/FlowerFieldBoardTest.java index 3eba013f6..58f995293 100644 --- a/exercises/practice/flower-field/src/test/java/FlowerFieldBoardTest.java +++ b/exercises/practice/flower-field/src/test/java/FlowerFieldBoardTest.java @@ -2,7 +2,6 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -24,8 +23,8 @@ public void testInputBoardWithNoRowsAndNoColumns() { @Test @DisplayName("no columns") public void testInputBoardWithOneRowAndNoColumns() { - List inputBoard = Collections.singletonList(""); - List expectedNumberedBoard = Collections.singletonList(""); + List inputBoard = List.of(""); + List expectedNumberedBoard = List.of(""); List actualNumberedBoard = new FlowerFieldBoard(inputBoard).withNumbers(); assertThat(actualNumberedBoard).isEqualTo(expectedNumberedBoard); @@ -35,13 +34,13 @@ public void testInputBoardWithOneRowAndNoColumns() { @Test @DisplayName("no flowers") public void testInputBoardWithNoFlowers() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( " ", " ", " " ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( " ", " ", " " @@ -56,13 +55,13 @@ public void testInputBoardWithNoFlowers() { @Test @DisplayName("garden full of flowers") public void testInputBoardWithOnlyFlowers() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( "***", "***", "***" ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( "***", "***", "***" @@ -77,13 +76,13 @@ public void testInputBoardWithOnlyFlowers() { @Test @DisplayName("flower surrounded by spaces") public void testInputBoardWithSingleFlowerAtCenter() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( " ", " * ", " " ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( "111", "1*1", "111" @@ -98,13 +97,13 @@ public void testInputBoardWithSingleFlowerAtCenter() { @Test @DisplayName("space surrounded by flowers") public void testInputBoardWithFlowersAroundPerimeter() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( "***", "* *", "***" ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( "***", "*8*", "***" @@ -119,11 +118,11 @@ public void testInputBoardWithFlowersAroundPerimeter() { @Test @DisplayName("horizontal line") public void testInputBoardWithSingleRowAndTwoFlowers() { - List inputBoard = Collections.singletonList( + List inputBoard = List.of( " * * " ); - List expectedNumberedBoard = Collections.singletonList( + List expectedNumberedBoard = List.of( "1*2*1" ); @@ -136,11 +135,11 @@ public void testInputBoardWithSingleRowAndTwoFlowers() { @Test @DisplayName("horizontal line, flowers at edges") public void testInputBoardWithSingleRowAndTwoFlowersAtEdges() { - List inputBoard = Collections.singletonList( + List inputBoard = List.of( "* *" ); - List expectedNumberedBoard = Collections.singletonList( + List expectedNumberedBoard = List.of( "*1 1*" ); @@ -153,7 +152,7 @@ public void testInputBoardWithSingleRowAndTwoFlowersAtEdges() { @Test @DisplayName("vertical line") public void testInputBoardWithSingleColumnAndTwoFlowers() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( " ", "*", " ", @@ -161,7 +160,7 @@ public void testInputBoardWithSingleColumnAndTwoFlowers() { " " ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( "1", "*", "2", @@ -178,7 +177,7 @@ public void testInputBoardWithSingleColumnAndTwoFlowers() { @Test @DisplayName("vertical line, flowers at edges") public void testInputBoardWithSingleColumnAndTwoFlowersAtEdges() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( "*", " ", " ", @@ -186,7 +185,7 @@ public void testInputBoardWithSingleColumnAndTwoFlowersAtEdges() { "*" ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( "*", "1", " ", @@ -203,7 +202,7 @@ public void testInputBoardWithSingleColumnAndTwoFlowersAtEdges() { @Test @DisplayName("cross") public void testInputBoardWithFlowersInCross() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( " * ", " * ", "*****", @@ -211,7 +210,7 @@ public void testInputBoardWithFlowersInCross() { " * " ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( " 2*2 ", "25*52", "*****", @@ -228,7 +227,7 @@ public void testInputBoardWithFlowersInCross() { @Test @DisplayName("large garden") public void testLargeInputBoard() { - List inputBoard = Arrays.asList( + List inputBoard = List.of( " * * ", " * ", " * ", @@ -237,7 +236,7 @@ public void testLargeInputBoard() { " " ); - List expectedNumberedBoard = Arrays.asList( + List expectedNumberedBoard = List.of( "1*22*1", "12*322", " 123*2", @@ -251,4 +250,20 @@ public void testLargeInputBoard() { assertThat(actualNumberedBoard).isEqualTo(expectedNumberedBoard); } + @Disabled("Remove to run test") + @Test + @DisplayName("multiple adjacent flowers") + public void testMultipleAdjacentFlowers() { + List inputBoard = List.of( + " ** " + ); + + List expectedNumberedBoard = List.of( + "1**1" + ); + + List actualNumberedBoard = new FlowerFieldBoard(inputBoard).withNumbers(); + + assertThat(actualNumberedBoard).isEqualTo(expectedNumberedBoard); + } } diff --git a/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/food-chain/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/food-chain/gradlew b/exercises/practice/food-chain/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/food-chain/gradlew +++ b/exercises/practice/food-chain/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/food-chain/gradlew.bat b/exercises/practice/food-chain/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/food-chain/gradlew.bat +++ b/exercises/practice/food-chain/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/forth/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/forth/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/forth/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/forth/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/forth/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/forth/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/forth/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/forth/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/forth/gradlew b/exercises/practice/forth/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/forth/gradlew +++ b/exercises/practice/forth/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/forth/gradlew.bat b/exercises/practice/forth/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/forth/gradlew.bat +++ b/exercises/practice/forth/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/game-of-life/gradlew b/exercises/practice/game-of-life/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/game-of-life/gradlew +++ b/exercises/practice/game-of-life/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/game-of-life/gradlew.bat b/exercises/practice/game-of-life/gradlew.bat index 93e3f59f1..24c62d56f 100644 --- a/exercises/practice/game-of-life/gradlew.bat +++ b/exercises/practice/game-of-life/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -43,13 +45,13 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -57,36 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/gigasecond/.meta/config.json b/exercises/practice/gigasecond/.meta/config.json index 084284dbd..fdcebcef3 100644 --- a/exercises/practice/gigasecond/.meta/config.json +++ b/exercises/practice/gigasecond/.meta/config.json @@ -36,5 +36,5 @@ }, "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", - "source_url": "https://pine.fm/LearnToProgram/?Chapter=09" + "source_url": "https://pine.fm/LearnToProgram/chap_09.html" } diff --git a/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/gigasecond/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/gigasecond/gradlew b/exercises/practice/gigasecond/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/gigasecond/gradlew +++ b/exercises/practice/gigasecond/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/gigasecond/gradlew.bat b/exercises/practice/gigasecond/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/gigasecond/gradlew.bat +++ b/exercises/practice/gigasecond/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/go-counting/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/go-counting/gradlew b/exercises/practice/go-counting/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/go-counting/gradlew +++ b/exercises/practice/go-counting/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/go-counting/gradlew.bat b/exercises/practice/go-counting/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/go-counting/gradlew.bat +++ b/exercises/practice/go-counting/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/grade-school/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/grade-school/gradlew b/exercises/practice/grade-school/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/grade-school/gradlew +++ b/exercises/practice/grade-school/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/grade-school/gradlew.bat b/exercises/practice/grade-school/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/grade-school/gradlew.bat +++ b/exercises/practice/grade-school/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/grains/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/grains/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/grains/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/grains/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/grains/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/grains/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/grains/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/grains/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/grains/gradlew b/exercises/practice/grains/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/grains/gradlew +++ b/exercises/practice/grains/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/grains/gradlew.bat b/exercises/practice/grains/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/grains/gradlew.bat +++ b/exercises/practice/grains/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/grep/.docs/introduction.md b/exercises/practice/grep/.docs/introduction.md new file mode 100644 index 000000000..404129046 --- /dev/null +++ b/exercises/practice/grep/.docs/introduction.md @@ -0,0 +1,5 @@ +# Introduction + +You have taken a job at a local library helping organize their collection of old books. +The student patrons are often hunting for half-remembered quotes to cite in their term papers. +Rather than manually read every book from cover to cover, you decide to build a small tool to scan them, looking for these partial quotes. diff --git a/exercises/practice/grep/.meta/config.json b/exercises/practice/grep/.meta/config.json index 22751e6db..dbf5fb02e 100644 --- a/exercises/practice/grep/.meta/config.json +++ b/exercises/practice/grep/.meta/config.json @@ -28,5 +28,5 @@ }, "blurb": "Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.", "source": "Conversation with Nate Foster.", - "source_url": "https://www.cs.cornell.edu/Courses/cs3110/2014sp/hw/0/ps0.pdf" + "source_url": "https://www.cs.cornell.edu/courses/cs3110/2014sp/hw/0/ps0.pdf" } diff --git a/exercises/practice/grep/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/grep/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/grep/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/grep/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/grep/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/grep/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/grep/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/grep/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/grep/gradlew b/exercises/practice/grep/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/grep/gradlew +++ b/exercises/practice/grep/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/grep/gradlew.bat b/exercises/practice/grep/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/grep/gradlew.bat +++ b/exercises/practice/grep/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/hamming/.approaches/introduction.md b/exercises/practice/hamming/.approaches/introduction.md index 8ef5c7816..14ed9be2d 100644 --- a/exercises/practice/hamming/.approaches/introduction.md +++ b/exercises/practice/hamming/.approaches/introduction.md @@ -127,11 +127,6 @@ For more information, check the [`IntStream` with `reduce()` approach][approach- Since benchmarking with the [Java Microbenchmark Harness][jmh] is currently outside the scope of this document, the choice between the various approaches can be made by perceived readability. -Of the `IntStream` approaches, the `reduce()` approach likely might be fastest, as it is only one iteration -instead of an iteration for `filter()` or `map()` and another iteration for `count()` or `sum()`. - -The `for` loop may also be fast, but it leaves a mutable member variable for the distance, instead of one marked [`final`][final]. - [for]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html [intstream]: https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html [filter]: https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html#filter-java.util.function.IntPredicate- @@ -144,4 +139,3 @@ The `for` loop may also be fast, but it leaves a mutable member variable for the [approach-intstream-map-sum]: https://exercism.org/tracks/java/exercises/hamming/approaches/intstream-map-sum [approach-intstream-reduce]: https://exercism.org/tracks/java/exercises/hamming/approaches/intstream-reduce [jmh]: https://github.com/openjdk/jmh -[final]: https://en.wikibooks.org/wiki/Java_Programming/Keywords/final diff --git a/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/hamming/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/hamming/gradlew b/exercises/practice/hamming/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/hamming/gradlew +++ b/exercises/practice/hamming/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/hamming/gradlew.bat b/exercises/practice/hamming/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/hamming/gradlew.bat +++ b/exercises/practice/hamming/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/hangman/build.gradle b/exercises/practice/hangman/build.gradle index 15df104cc..a55dc26f3 100644 --- a/exercises/practice/hangman/build.gradle +++ b/exercises/practice/hangman/build.gradle @@ -12,6 +12,8 @@ dependencies { testImplementation platform("org.junit:junit-bom:5.10.0") testImplementation "org.junit.jupiter:junit-jupiter" testImplementation "org.assertj:assertj-core:3.25.1" + + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } test { diff --git a/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/hangman/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/hangman/gradlew b/exercises/practice/hangman/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/hangman/gradlew +++ b/exercises/practice/hangman/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/hangman/gradlew.bat b/exercises/practice/hangman/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/hangman/gradlew.bat +++ b/exercises/practice/hangman/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/hangman/src/test/java/HangmanTest.java b/exercises/practice/hangman/src/test/java/HangmanTest.java index df60dbee9..6cecef282 100644 --- a/exercises/practice/hangman/src/test/java/HangmanTest.java +++ b/exercises/practice/hangman/src/test/java/HangmanTest.java @@ -1,8 +1,10 @@ import io.reactivex.Observable; import io.reactivex.ObservableEmitter; import io.reactivex.disposables.Disposable; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -14,6 +16,14 @@ public class HangmanTest { + /** + * Used in {@link #consecutiveGames()} to tell when both are subscribed too. + */ + private static class SubscribedEmitters { + private ObservableEmitter word; + private ObservableEmitter letter; + } + private Hangman hangman; @BeforeEach @@ -22,6 +32,7 @@ public void init() { } @Test + @DisplayName("Initial game state is set correctly") public void initialization() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -39,6 +50,7 @@ public void initialization() { @Disabled("Remove to run test") @Test + @DisplayName("First correct guess updates discovered and guess lists") public void firstGuess() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -54,6 +66,7 @@ public void firstGuess() { @Disabled("Remove to run test") @Test + @DisplayName("First incorrect guess registers a miss and adds a part") public void firstMiss() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -69,6 +82,7 @@ public void firstMiss() { @Disabled("Remove to run test") @Test + @DisplayName("Game in progress accumulates guesses, misses and parts correctly") public void gameInProgress() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -84,6 +98,7 @@ public void gameInProgress() { @Disabled("Remove to run test") @Test + @DisplayName("Winning the game results in WIN status") public void wonGame() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -97,6 +112,7 @@ public void wonGame() { @Disabled("Remove to run test") @Test + @DisplayName("Losing the game results in LOSS status") public void lostGame() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -118,6 +134,7 @@ public void lostGame() { @Disabled("Remove to run test") @Test + @DisplayName("Handles consecutive games correctly with ordered emissions") public void consecutiveGames() { // This test setup is more complex because we have to order the emission of values in the // different observers. @@ -127,14 +144,14 @@ public void consecutiveGames() { // 4. Letter observable receiveds the letters for the second word // Emitters respectively for the word and letter observables - ObservableEmitter[] emitters = new ObservableEmitter[2]; + SubscribedEmitters emitters = new SubscribedEmitters(); Runnable emit = () -> { // Process sending the inputs in the right order - emitters[0].onNext("secret"); - Stream.of("a", "e", "o", "s", "c", "r", "g", "t").forEach(emitters[1]::onNext); - emitters[0].onNext("abba"); - Stream.of("a", "e", "s", "b").forEach(emitters[1]::onNext); - emitters[0].onComplete(); + emitters.word.onNext("secret"); + Stream.of("a", "e", "o", "s", "c", "r", "g", "t").forEach(emitters.letter::onNext); + emitters.word.onNext("abba"); + Stream.of("a", "e", "s", "b").forEach(emitters.letter::onNext); + emitters.word.onComplete(); }; Observable words = createWordObservable(emitters, emit); Observable letters = createLetterObservable(emitters, emit); @@ -163,24 +180,24 @@ public void consecutiveGames() { } } - Observable createWordObservable(ObservableEmitter[] emitters, Runnable emit) { + Observable createWordObservable(SubscribedEmitters emitters, Runnable emit) { return Observable.create( emitter -> { // A new subscription was created for words, record it. - emitters[0] = emitter; - if (emitters[1] != null) { + emitters.word = emitter; + if (emitters.letter != null) { // Start emitting only when both word and letter observable have subscriptions emit.run(); } }); } - Observable createLetterObservable(ObservableEmitter[] emitters, Runnable emit) { + Observable createLetterObservable(SubscribedEmitters emitters, Runnable emit) { return Observable.create( emitter -> { // A new subscription was created for letters, record it. - emitters[1] = emitter; - if (emitters[0] != null) { + emitters.letter = emitter; + if (emitters.word != null) { // Start emitting only when both word and letter observable have subscriptions emit.run(); } @@ -189,6 +206,7 @@ Observable createLetterObservable(ObservableEmitter[] emitters, Runnable emit) { @Disabled("Remove to run test") @Test + @DisplayName("Cannot play the same guess twice") public void cannotPlayAGuessTwice() { Observable result = hangman.play( Observable.fromArray("secret"), @@ -201,6 +219,7 @@ public void cannotPlayAGuessTwice() { @Disabled("Remove to run test") @Test + @DisplayName("Cannot play the same miss twice") public void cannotPlayAMissTwice() { Observable result = hangman.play( Observable.fromArray("secret"), diff --git a/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/hello-world/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/hello-world/gradlew b/exercises/practice/hello-world/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/hello-world/gradlew +++ b/exercises/practice/hello-world/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/hello-world/gradlew.bat b/exercises/practice/hello-world/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/hello-world/gradlew.bat +++ b/exercises/practice/hello-world/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/high-scores/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/high-scores/gradlew b/exercises/practice/high-scores/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/high-scores/gradlew +++ b/exercises/practice/high-scores/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/high-scores/gradlew.bat b/exercises/practice/high-scores/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/high-scores/gradlew.bat +++ b/exercises/practice/high-scores/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/house/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/house/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/house/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/house/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/house/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/house/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/house/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/house/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/house/gradlew b/exercises/practice/house/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/house/gradlew +++ b/exercises/practice/house/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/house/gradlew.bat b/exercises/practice/house/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/house/gradlew.bat +++ b/exercises/practice/house/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/intergalactic-transmission/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/intergalactic-transmission/gradlew b/exercises/practice/intergalactic-transmission/gradlew old mode 100644 new mode 100755 index 1aa94a426..b9bb139f7 --- a/exercises/practice/intergalactic-transmission/gradlew +++ b/exercises/practice/intergalactic-transmission/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/intergalactic-transmission/gradlew.bat b/exercises/practice/intergalactic-transmission/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/intergalactic-transmission/gradlew.bat +++ b/exercises/practice/intergalactic-transmission/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/isbn-verifier/.meta/tests.toml b/exercises/practice/isbn-verifier/.meta/tests.toml index 6d5a84599..17e18d47a 100644 --- a/exercises/practice/isbn-verifier/.meta/tests.toml +++ b/exercises/practice/isbn-verifier/.meta/tests.toml @@ -30,6 +30,12 @@ description = "invalid character in isbn is not treated as zero" [28025280-2c39-4092-9719-f3234b89c627] description = "X is only valid as a check digit" +[8005b57f-f194-44ee-88d2-a77ac4142591] +description = "only one check digit is allowed" + +[fdb14c99-4cf8-43c5-b06d-eb1638eff343] +description = "X is not substituted by the value 10" + [f6294e61-7e79-46b3-977b-f48789a4945b] description = "valid isbn without separating dashes" diff --git a/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/isbn-verifier/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/isbn-verifier/gradlew b/exercises/practice/isbn-verifier/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/isbn-verifier/gradlew +++ b/exercises/practice/isbn-verifier/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/isbn-verifier/gradlew.bat b/exercises/practice/isbn-verifier/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/isbn-verifier/gradlew.bat +++ b/exercises/practice/isbn-verifier/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/isbn-verifier/src/test/java/IsbnVerifierTest.java b/exercises/practice/isbn-verifier/src/test/java/IsbnVerifierTest.java index 6ad959b9b..2848b63c5 100644 --- a/exercises/practice/isbn-verifier/src/test/java/IsbnVerifierTest.java +++ b/exercises/practice/isbn-verifier/src/test/java/IsbnVerifierTest.java @@ -68,6 +68,20 @@ public void xIsOnlyValidAsACheckDigit() { assertThat(isbnVerifier.isValid("3-598-2X507-9")).isFalse(); } + @Disabled("Remove to run test") + @Test + @DisplayName("only one check digit is allowed") + public void onlyOneCheckDigitIsAllowed() { + assertThat(isbnVerifier.isValid("3-598-21508-96")).isFalse(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("X is not substituted by the value 10") + public void xIsNotSubstitutedByTheValue10() { + assertThat(isbnVerifier.isValid("3-598-2X507-5")).isFalse(); + } + @Disabled("Remove to run test") @Test @DisplayName("valid isbn without separating dashes") diff --git a/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/isogram/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/isogram/gradlew b/exercises/practice/isogram/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/isogram/gradlew +++ b/exercises/practice/isogram/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/isogram/gradlew.bat b/exercises/practice/isogram/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/isogram/gradlew.bat +++ b/exercises/practice/isogram/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/killer-sudoku-helper/.docs/instructions.md b/exercises/practice/killer-sudoku-helper/.docs/instructions.md index fdafdca8f..4153c3e9e 100644 --- a/exercises/practice/killer-sudoku-helper/.docs/instructions.md +++ b/exercises/practice/killer-sudoku-helper/.docs/instructions.md @@ -74,12 +74,12 @@ You can also find Killer Sudokus in varying difficulty in numerous newspapers, a ## Credit -The screenshots above have been generated using [F-Puzzles.com](https://www.f-puzzles.com/), a Puzzle Setting Tool by Eric Fox. +The screenshots above have been generated using F-Puzzles.com, a Puzzle Setting Tool by Eric Fox. -[sudoku-rules]: https://masteringsudoku.com/sudoku-rules-beginners/ -[killer-guide]: https://masteringsudoku.com/killer-sudoku/ +[sudoku-rules]: https://en.wikipedia.org/wiki/Sudoku +[killer-guide]: https://en.wikipedia.org/wiki/Killer_sudoku [one-solution-img]: https://assets.exercism.org/images/exercises/killer-sudoku-helper/example1.png [four-solutions-img]: https://assets.exercism.org/images/exercises/killer-sudoku-helper/example2.png [not-possible-img]: https://assets.exercism.org/images/exercises/killer-sudoku-helper/example3.png -[clover-puzzle]: https://app.crackingthecryptic.com/sudoku/HqTBn3Pr6R +[clover-puzzle]: https://sudokupad.app/HqTBn3Pr6R [goodliffe-video]: https://youtu.be/c_NjEbFEeW0?t=1180 diff --git a/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/killer-sudoku-helper/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/killer-sudoku-helper/gradlew b/exercises/practice/killer-sudoku-helper/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/killer-sudoku-helper/gradlew +++ b/exercises/practice/killer-sudoku-helper/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/killer-sudoku-helper/gradlew.bat b/exercises/practice/killer-sudoku-helper/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/killer-sudoku-helper/gradlew.bat +++ b/exercises/practice/killer-sudoku-helper/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/kindergarten-garden/.meta/config.json b/exercises/practice/kindergarten-garden/.meta/config.json index bd4d3254c..4b134eb4f 100644 --- a/exercises/practice/kindergarten-garden/.meta/config.json +++ b/exercises/practice/kindergarten-garden/.meta/config.json @@ -39,5 +39,5 @@ }, "blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", - "source_url": "https://turing.edu" + "source_url": "https://www.turing.edu/" } diff --git a/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/kindergarten-garden/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/kindergarten-garden/gradlew b/exercises/practice/kindergarten-garden/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/kindergarten-garden/gradlew +++ b/exercises/practice/kindergarten-garden/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/kindergarten-garden/gradlew.bat b/exercises/practice/kindergarten-garden/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/kindergarten-garden/gradlew.bat +++ b/exercises/practice/kindergarten-garden/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/knapsack/.meta/src/reference/java/Item.java b/exercises/practice/knapsack/.meta/src/reference/java/Item.java index cae28c411..29aa1f9f7 100644 --- a/exercises/practice/knapsack/.meta/src/reference/java/Item.java +++ b/exercises/practice/knapsack/.meta/src/reference/java/Item.java @@ -1,3 +1,8 @@ +/** + * Represents an item that can be placed in the knapsack. + * + * NOTE: There is no need to change this file and is treated as read only by the Exercism test runners. + */ class Item { // Weight of the item diff --git a/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/knapsack/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/knapsack/gradlew b/exercises/practice/knapsack/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/knapsack/gradlew +++ b/exercises/practice/knapsack/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/knapsack/gradlew.bat b/exercises/practice/knapsack/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/knapsack/gradlew.bat +++ b/exercises/practice/knapsack/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/largest-series-product/.meta/config.json b/exercises/practice/largest-series-product/.meta/config.json index b6a57ee6c..c3ba23a98 100644 --- a/exercises/practice/largest-series-product/.meta/config.json +++ b/exercises/practice/largest-series-product/.meta/config.json @@ -22,6 +22,7 @@ "Smarticles101", "sonapraneeth-a", "sshine", + "Xinri", "Zaldrick" ], "files": { diff --git a/exercises/practice/largest-series-product/.meta/tests.toml b/exercises/practice/largest-series-product/.meta/tests.toml index 883169259..8da9250e0 100644 --- a/exercises/practice/largest-series-product/.meta/tests.toml +++ b/exercises/practice/largest-series-product/.meta/tests.toml @@ -38,6 +38,11 @@ description = "reports zero if all spans include zero" [5d81aaf7-4f67-4125-bf33-11493cc7eab7] description = "rejects span longer than string length" +include = false + +[0ae1ce53-d9ba-41bb-827f-2fceb64f058b] +description = "rejects span longer than string length" +reimplements = "5d81aaf7-4f67-4125-bf33-11493cc7eab7" [06bc8b90-0c51-4c54-ac22-3ec3893a079e] description = "reports 1 for empty string and empty product (0 span)" @@ -49,6 +54,12 @@ include = false [6d96c691-4374-4404-80ee-2ea8f3613dd4] description = "rejects empty string and nonzero span" +include = false + +[6cf66098-a6af-4223-aab1-26aeeefc7402] +description = "rejects empty string and nonzero span" +include = false +reimplements = "6d96c691-4374-4404-80ee-2ea8f3613dd4" [7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74] description = "rejects invalid character in digits" @@ -59,4 +70,5 @@ include = false [c859f34a-9bfe-4897-9c2f-6d7f8598e7f0] description = "rejects negative span" +include = false reimplements = "5fe3c0e5-a945-49f2-b584-f0814b4dd1ef" diff --git a/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/largest-series-product/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/largest-series-product/gradlew b/exercises/practice/largest-series-product/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/largest-series-product/gradlew +++ b/exercises/practice/largest-series-product/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/largest-series-product/gradlew.bat b/exercises/practice/largest-series-product/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/largest-series-product/gradlew.bat +++ b/exercises/practice/largest-series-product/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java b/exercises/practice/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java index 8a2c48e20..554eaa0fe 100644 --- a/exercises/practice/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +++ b/exercises/practice/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java @@ -127,17 +127,6 @@ public void testSeriesLengthLongerThanLengthOfStringToTestIsRejected() { .withMessage("Series length must be less than or equal to the length of the string to search."); } - @Disabled("Remove to run test") - @Test - @DisplayName("reports 1 for empty string and empty product (0 span)") - public void testEmptyStringToSearchAndSeriesOfNonZeroLengthIsRejected() { - LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator(""); - - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(1)) - .withMessage("Series length must be less than or equal to the length of the string to search."); - } - @Disabled("Remove to run test") @Test @DisplayName("rejects invalid character in digits") @@ -147,17 +136,6 @@ public void testStringToSearchContainingNonDigitCharacterIsRejected() { .withMessage("String to search may only contain digits."); } - @Disabled("Remove to run test") - @Test - @DisplayName("rejects negative span") - public void testNegativeSeriesLengthIsRejected() { - LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("12345"); - - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(-1)) - .withMessage("Series length must be non-negative."); - } - @Disabled("Remove to run test") @Test @DisplayName("integer overflow") @@ -169,5 +147,4 @@ public void testForIntegerOverflow() { assertThat(actualProduct).isEqualTo(expectedProduct); } - } diff --git a/exercises/practice/leap/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/leap/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/leap/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/leap/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/leap/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/leap/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/leap/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/leap/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/leap/gradlew b/exercises/practice/leap/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/leap/gradlew +++ b/exercises/practice/leap/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/leap/gradlew.bat b/exercises/practice/leap/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/leap/gradlew.bat +++ b/exercises/practice/leap/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/ledger/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/ledger/gradlew b/exercises/practice/ledger/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/ledger/gradlew +++ b/exercises/practice/ledger/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/ledger/gradlew.bat b/exercises/practice/ledger/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/ledger/gradlew.bat +++ b/exercises/practice/ledger/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/linked-list/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/linked-list/gradlew b/exercises/practice/linked-list/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/linked-list/gradlew +++ b/exercises/practice/linked-list/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/linked-list/gradlew.bat b/exercises/practice/linked-list/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/linked-list/gradlew.bat +++ b/exercises/practice/linked-list/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/list-ops/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/list-ops/gradlew b/exercises/practice/list-ops/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/list-ops/gradlew +++ b/exercises/practice/list-ops/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/list-ops/gradlew.bat b/exercises/practice/list-ops/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/list-ops/gradlew.bat +++ b/exercises/practice/list-ops/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/luhn/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/luhn/gradlew b/exercises/practice/luhn/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/luhn/gradlew +++ b/exercises/practice/luhn/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/luhn/gradlew.bat b/exercises/practice/luhn/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/luhn/gradlew.bat +++ b/exercises/practice/luhn/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/markdown/.docs/instructions.md b/exercises/practice/markdown/.docs/instructions.md index 9b756d991..b3f3044c6 100644 --- a/exercises/practice/markdown/.docs/instructions.md +++ b/exercises/practice/markdown/.docs/instructions.md @@ -10,4 +10,4 @@ Your challenge is to re-write this code to make it easier to read and maintain w It would be helpful if you made notes of what you did in your refactoring in comments so reviewers can see that, but it isn't strictly necessary. The most important thing is to make the code better! -[markdown]: https://guides.github.com/features/mastering-markdown/ +[markdown]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax diff --git a/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/markdown/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/markdown/gradlew b/exercises/practice/markdown/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/markdown/gradlew +++ b/exercises/practice/markdown/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/markdown/gradlew.bat b/exercises/practice/markdown/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/markdown/gradlew.bat +++ b/exercises/practice/markdown/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/markdown/src/test/java/MarkdownTest.java b/exercises/practice/markdown/src/test/java/MarkdownTest.java index 10f0823f2..ec0f31d94 100644 --- a/exercises/practice/markdown/src/test/java/MarkdownTest.java +++ b/exercises/practice/markdown/src/test/java/MarkdownTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,6 +15,7 @@ public void setup() { } @Test + @DisplayName("parses normal text as a paragraph") public void normalTextAsAParagraph() { String input = "This will be a paragraph"; String expected = "

This will be a paragraph

"; @@ -23,6 +25,7 @@ public void normalTextAsAParagraph() { @Disabled("Remove to run test") @Test + @DisplayName("parsing italics") public void italics() { String input = "_This will be italic_"; String expected = "

This will be italic

"; @@ -32,6 +35,7 @@ public void italics() { @Disabled("Remove to run test") @Test + @DisplayName("parsing bold text") public void boldText() { String input = "__This will be bold__"; String expected = "

This will be bold

"; @@ -41,6 +45,7 @@ public void boldText() { @Disabled("Remove to run test") @Test + @DisplayName("mixed normal, italics and bold text") public void normalItalicsAndBoldText() { String input = "This will _be_ __mixed__"; String expected = "

This will be mixed

"; @@ -50,6 +55,7 @@ public void normalItalicsAndBoldText() { @Disabled("Remove to run test") @Test + @DisplayName("with h1 header level") public void withH1HeaderLevel() { String input = "# This will be an h1"; String expected = "

This will be an h1

"; @@ -59,6 +65,7 @@ public void withH1HeaderLevel() { @Disabled("Remove to run test") @Test + @DisplayName("with h2 header level") public void withH2HeaderLevel() { String input = "## This will be an h2"; String expected = "

This will be an h2

"; @@ -68,6 +75,7 @@ public void withH2HeaderLevel() { @Disabled("Remove to run test") @Test + @DisplayName("with h3 header level") public void withH3HeaderLevel() { String input = "### This will be an h3"; String expected = "

This will be an h3

"; @@ -77,6 +85,7 @@ public void withH3HeaderLevel() { @Disabled("Remove to run test") @Test + @DisplayName("with h4 header level") public void withH4HeaderLevel() { String input = "#### This will be an h4"; String expected = "

This will be an h4

"; @@ -86,6 +95,7 @@ public void withH4HeaderLevel() { @Disabled("Remove to run test") @Test + @DisplayName("with h5 header level") public void withH5HeaderLevel() { String input = "##### This will be an h5"; String expected = "
This will be an h5
"; @@ -95,6 +105,7 @@ public void withH5HeaderLevel() { @Disabled("Remove to run test") @Test + @DisplayName("with h6 header level") public void withH6HeaderLevel() { String input = "###### This will be an h6"; String expected = "
This will be an h6
"; @@ -104,6 +115,7 @@ public void withH6HeaderLevel() { @Disabled("Remove to run test") @Test + @DisplayName("h7 header level is a paragraph") public void h7HeaderLevelIsAParagraph() { String input = "####### This will not be an h7"; String expected = "

####### This will not be an h7

"; @@ -113,6 +125,7 @@ public void h7HeaderLevelIsAParagraph() { @Disabled("Remove to run test") @Test + @DisplayName("unordered lists") public void unorderedLists() { String input = "* Item 1\n* Item 2"; String expected = "
  • Item 1
  • Item 2
"; @@ -122,6 +135,7 @@ public void unorderedLists() { @Disabled("Remove to run test") @Test + @DisplayName("With a little bit of everything") public void aLittleBitOfEverything() { String input = "# Header!\n* __Bold Item__\n* _Italic Item_"; String expected = "

Header!

  • Bold Item
  • Italic Item
"; @@ -131,6 +145,7 @@ public void aLittleBitOfEverything() { @Disabled("Remove to run test") @Test + @DisplayName("with markdown symbols in the header text that should not be interpreted") public void markdownSymbolsInTheHeaderShouldNotBeInterpreted() { String input = "# This is a header with # and * in the text"; String expected = "

This is a header with # and * in the text

"; @@ -140,6 +155,7 @@ public void markdownSymbolsInTheHeaderShouldNotBeInterpreted() { @Disabled("Remove to run test") @Test + @DisplayName("with markdown symbols in the list item text that should not be interpreted") public void markdownSymbolsInTheListItemTextShouldNotBeInterpreted() { String input = "* Item 1 with a # in the text\n* Item 2 with * in the text"; String expected = "
  • Item 1 with a # in the text
  • Item 2 with * in the text
"; @@ -149,6 +165,7 @@ public void markdownSymbolsInTheListItemTextShouldNotBeInterpreted() { @Disabled("Remove to run test") @Test + @DisplayName("with markdown symbols in the paragraph text that should not be interpreted") public void markdownSymbolsInTheParagraphTextShouldNotBeInterpreted() { String input = "This is a paragraph with # and * in the text"; String expected = "

This is a paragraph with # and * in the text

"; @@ -158,6 +175,7 @@ public void markdownSymbolsInTheParagraphTextShouldNotBeInterpreted() { @Disabled("Remove to run test") @Test + @DisplayName("unordered lists close properly with preceding and following lines") public void markdownUnorderedListsCloseProperlyWithPrecedingAndFollowingLines() { String input = "# Start a list\n* Item 1\n* Item 2\nEnd a list"; String expected = "

Start a list

  • Item 1
  • Item 2

End a list

"; diff --git a/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/matching-brackets/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/matching-brackets/gradlew b/exercises/practice/matching-brackets/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/matching-brackets/gradlew +++ b/exercises/practice/matching-brackets/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/matching-brackets/gradlew.bat b/exercises/practice/matching-brackets/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/matching-brackets/gradlew.bat +++ b/exercises/practice/matching-brackets/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/matching-brackets/src/test/java/BracketCheckerTest.java b/exercises/practice/matching-brackets/src/test/java/BracketCheckerTest.java index f1a5b5e7e..9051b388c 100644 --- a/exercises/practice/matching-brackets/src/test/java/BracketCheckerTest.java +++ b/exercises/practice/matching-brackets/src/test/java/BracketCheckerTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -6,6 +7,7 @@ public class BracketCheckerTest { @Test + @DisplayName("paired square brackets") public void testPairedSquareBrackets() { BracketChecker bracketChecker = new BracketChecker("[]"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -13,6 +15,7 @@ public void testPairedSquareBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("empty string") public void testEmptyString() { BracketChecker bracketChecker = new BracketChecker(""); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -20,6 +23,7 @@ public void testEmptyString() { @Disabled("Remove to run test") @Test + @DisplayName("unpaired brackets") public void testUnpairedBrackets() { BracketChecker bracketChecker = new BracketChecker("[["); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -27,6 +31,7 @@ public void testUnpairedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("wrong ordered brackets") public void testWrongOrderedBrackets() { BracketChecker bracketChecker = new BracketChecker("}{"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -34,6 +39,7 @@ public void testWrongOrderedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("wrong closing bracket") public void testWrongClosingBracket() { BracketChecker bracketChecker = new BracketChecker("{]"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -41,6 +47,7 @@ public void testWrongClosingBracket() { @Disabled("Remove to run test") @Test + @DisplayName("paired with whitespace") public void testPairedWithWhitespace() { BracketChecker bracketChecker = new BracketChecker("{ }"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -48,6 +55,7 @@ public void testPairedWithWhitespace() { @Disabled("Remove to run test") @Test + @DisplayName("partially paired brackets") public void testPartiallyPairedBrackets() { BracketChecker bracketChecker = new BracketChecker("{[])"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -55,6 +63,7 @@ public void testPartiallyPairedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("simple nested brackets") public void testSimpleNestedBrackets() { BracketChecker bracketChecker = new BracketChecker("{[]}"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -62,6 +71,7 @@ public void testSimpleNestedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("several paired brackets") public void testSeveralPairedBrackets() { BracketChecker bracketChecker = new BracketChecker("{}[]"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -69,6 +79,7 @@ public void testSeveralPairedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("paired and nested brackets") public void testPairedAndNestedBrackets() { BracketChecker bracketChecker = new BracketChecker("([{}({}[])])"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -76,6 +87,7 @@ public void testPairedAndNestedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("unopened closing brackets") public void testUnopenedClosingBracket() { BracketChecker bracketChecker = new BracketChecker("{[)][]}"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -83,6 +95,7 @@ public void testUnopenedClosingBracket() { @Disabled("Remove to run test") @Test + @DisplayName("unpaired and nested brackets") public void testUnpairedAndNestedBrackets() { BracketChecker bracketChecker = new BracketChecker("([{])"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -90,6 +103,7 @@ public void testUnpairedAndNestedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("paired and wrong nested brackets") public void testPairedAndWrongNestedBrackets() { BracketChecker bracketChecker = new BracketChecker("[({]})"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -97,6 +111,7 @@ public void testPairedAndWrongNestedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("paired and wrong nested brackets but innermost are correct") public void testPairedAndWrongNestedBracketsButInnermostAreCorrect() { BracketChecker bracketChecker = new BracketChecker("[({}])"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -104,6 +119,7 @@ public void testPairedAndWrongNestedBracketsButInnermostAreCorrect() { @Disabled("Remove to run test") @Test + @DisplayName("paired and incomplete brackets") public void testPairedAndIncompleteBrackets() { BracketChecker bracketChecker = new BracketChecker("{}["); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -111,6 +127,7 @@ public void testPairedAndIncompleteBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("too many closing brackets") public void testTooManyClosingBrackets() { BracketChecker bracketChecker = new BracketChecker("[]]"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -118,13 +135,15 @@ public void testTooManyClosingBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("early unexpected brackets") public void testEarlyUnexpectedBrackets() { BracketChecker bracketChecker = new BracketChecker(")()"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); } - + @Disabled("Remove to run test") @Test + @DisplayName("early mismatched brackets") public void testEarlyMismatchedBrackets() { BracketChecker bracketChecker = new BracketChecker("{)()"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isFalse(); @@ -132,6 +151,7 @@ public void testEarlyMismatchedBrackets() { @Disabled("Remove to run test") @Test + @DisplayName("math expression") public void testMathExpression() { BracketChecker bracketChecker = new BracketChecker("(((185 + 223.85) * 15) - 543)/2"); assertThat(bracketChecker.areBracketsMatchedAndNestedCorrectly()).isTrue(); @@ -139,6 +159,7 @@ public void testMathExpression() { @Disabled("Remove to run test") @Test + @DisplayName("complex latex expression") public void testComplexLatexExpression() { BracketChecker bracketChecker = new BracketChecker( "\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)"); diff --git a/exercises/practice/matrix/.meta/config.json b/exercises/practice/matrix/.meta/config.json index 58256708d..0ed6b45b8 100644 --- a/exercises/practice/matrix/.meta/config.json +++ b/exercises/practice/matrix/.meta/config.json @@ -36,5 +36,5 @@ }, "blurb": "Given a string representing a matrix of numbers, return the rows and columns of that matrix.", "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", - "source_url": "https://turing.edu" + "source_url": "https://www.turing.edu/" } diff --git a/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/matrix/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/matrix/gradlew b/exercises/practice/matrix/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/matrix/gradlew +++ b/exercises/practice/matrix/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/matrix/gradlew.bat b/exercises/practice/matrix/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/matrix/gradlew.bat +++ b/exercises/practice/matrix/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/mazy-mice/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/mazy-mice/gradlew b/exercises/practice/mazy-mice/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/mazy-mice/gradlew +++ b/exercises/practice/mazy-mice/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/mazy-mice/gradlew.bat b/exercises/practice/mazy-mice/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/mazy-mice/gradlew.bat +++ b/exercises/practice/mazy-mice/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java b/exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java index 24e5de663..8b3635f2a 100644 --- a/exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java +++ b/exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Set; @@ -37,6 +38,7 @@ public void setup() { } @Test + @DisplayName("Maze has correct overall dimensions") public void theDimensionsOfTheMazeAreCorrect() { var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); var expectedWidth = RECTANGLE_COLUMNS * 2 + 1; @@ -49,6 +51,7 @@ public void theDimensionsOfTheMazeAreCorrect() { @Disabled("Remove to run test") @Test + @DisplayName("Maze contains only valid characters") public void theMazeContainsOnlyValidCharacters() { var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); @@ -63,7 +66,8 @@ public void theMazeContainsOnlyValidCharacters() { @Disabled("Remove to run test") @Test - public void theMazeHasOnlyOneEntranceOnTheLeftSide() { + @DisplayName("Maze has a single entrance on the left side") + public void theMazeHasSingleEntranceOnTheLeftSide() { var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); int entranceCount = countEntrances(maze); @@ -74,7 +78,8 @@ public void theMazeHasOnlyOneEntranceOnTheLeftSide() { @Disabled("Remove to run test") @Test - public void theMazeHasSingleExitOnTheRightSideOfTheMaze() { + @DisplayName("Maze has a single exit on the right side") + public void theMazeHasSingleExitOnTheRightSide() { var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); int exitCount = countExits(maze); @@ -85,6 +90,7 @@ public void theMazeHasSingleExitOnTheRightSideOfTheMaze() { @Disabled("Remove to run test") @Test + @DisplayName("Maze is different each time it is generated") public void aMazeIsDifferentEachTimeItIsGenerated() { var maze1 = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); var maze2 = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); @@ -96,6 +102,27 @@ public void aMazeIsDifferentEachTimeItIsGenerated() { @Disabled("Remove to run test") @Test + @DisplayName("Maze is generated perfectly (single path, no isolated cells)") + public void theMazeIsPerfect() { + var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); + + assertThatMazeHasSinglePath(maze); + assertThatMazeHasNoIsolatedSections(maze); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Maze with a seed is generated perfectly (single path, no isolated cells)") + public void theMazeIsPerfectWithSeed() { + var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS, SEED_ONE); + + assertThatMazeHasSinglePath(maze); + assertThatMazeHasNoIsolatedSections(maze); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Mazes generated with same seed are identical") public void twoMazesWithSameSeedShouldBeEqual() { var maze1 = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS, SEED_ONE); var maze2 = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS, SEED_ONE); @@ -107,6 +134,7 @@ public void twoMazesWithSameSeedShouldBeEqual() { @Disabled("Remove to run test") @Test + @DisplayName("Mazes generated with different seeds are different") public void twoMazesWithDifferentSeedsShouldNotBeEqual() { var maze1 = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS, SEED_ONE); var maze2 = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS, SEED_TWO); @@ -118,24 +146,7 @@ public void twoMazesWithDifferentSeedsShouldNotBeEqual() { @Disabled("Remove to run test") @Test - public void theMazeIsPerfect() { - var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS); - - assertThatMazeHasSinglePath(maze); - assertThatMazeHasNoIsolatedSections(maze); - } - - @Disabled("Remove to run test") - @Test - public void theMazeIsPerfectWithSeed() { - var maze = sut.generatePerfectMaze(RECTANGLE_ROWS, RECTANGLE_COLUMNS, SEED_ONE); - - assertThatMazeHasSinglePath(maze); - assertThatMazeHasNoIsolatedSections(maze); - } - - @Disabled("Remove to run test") - @Test + @DisplayName("Throws when rows are less than five") public void shouldThrowExceptionWhenRowsIsLessThanFive() { assertThatIllegalArgumentException() .isThrownBy(() -> sut.generatePerfectMaze(0, RECTANGLE_COLUMNS)); @@ -143,6 +154,7 @@ public void shouldThrowExceptionWhenRowsIsLessThanFive() { @Disabled("Remove to run test") @Test + @DisplayName("Throws when columns are less than five") public void shouldThrowExceptionWhenColumnsIsLessThanFive() { assertThatIllegalArgumentException() .isThrownBy(() -> sut.generatePerfectMaze(RECTANGLE_ROWS, 0)); @@ -150,6 +162,7 @@ public void shouldThrowExceptionWhenColumnsIsLessThanFive() { @Disabled("Remove to run test") @Test + @DisplayName("Throws when rows exceed hundred") public void shouldThrowExceptionWhenRowsIsMoreThenHundred() { assertThatIllegalArgumentException() .isThrownBy(() -> sut.generatePerfectMaze(101, RECTANGLE_COLUMNS)); @@ -157,6 +170,7 @@ public void shouldThrowExceptionWhenRowsIsMoreThenHundred() { @Disabled("Remove to run test") @Test + @DisplayName("Throws when columns exceed hundred") public void shouldThrowExceptionWhenColumnsIsMoreThenHundred() { assertThatIllegalArgumentException() .isThrownBy(() -> sut.generatePerfectMaze(RECTANGLE_ROWS, 101)); diff --git a/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/meetup/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/meetup/gradlew b/exercises/practice/meetup/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/meetup/gradlew +++ b/exercises/practice/meetup/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/meetup/gradlew.bat b/exercises/practice/meetup/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/meetup/gradlew.bat +++ b/exercises/practice/meetup/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/micro-blog/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/micro-blog/gradlew b/exercises/practice/micro-blog/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/micro-blog/gradlew +++ b/exercises/practice/micro-blog/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/micro-blog/gradlew.bat b/exercises/practice/micro-blog/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/micro-blog/gradlew.bat +++ b/exercises/practice/micro-blog/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/micro-blog/src/test/java/MicroBlogTest.java b/exercises/practice/micro-blog/src/test/java/MicroBlogTest.java index 46ced92d6..1b44d5a78 100644 --- a/exercises/practice/micro-blog/src/test/java/MicroBlogTest.java +++ b/exercises/practice/micro-blog/src/test/java/MicroBlogTest.java @@ -26,7 +26,7 @@ public void englishLanguageLong() { @Disabled("Remove to run test") @Test @DisplayName("German language short (broth)") - public void germanLanguageShort_broth() { + public void germanLanguageShortBroth() { String expected = "brühe"; assertThat(microBlog.truncate("brühe")).isEqualTo(expected); } @@ -34,7 +34,7 @@ public void germanLanguageShort_broth() { @Disabled("Remove to run test") @Test @DisplayName("German language long (bear carpet → beards)") - public void germanLanguageLong_bearCarpet_to_beards() { + public void germanLanguageLongBearCarpetToBeards() { String expected = "Bärte"; assertThat(microBlog.truncate("Bärteppich")).isEqualTo(expected); } @@ -42,7 +42,7 @@ public void germanLanguageLong_bearCarpet_to_beards() { @Disabled("Remove to run test") @Test @DisplayName("Bulgarian language short (good)") - public void bulgarianLanguageShort_good() { + public void bulgarianLanguageShortGood() { String expected = "Добър"; assertThat(microBlog.truncate("Добър")).isEqualTo(expected); } @@ -50,7 +50,7 @@ public void bulgarianLanguageShort_good() { @Disabled("Remove to run test") @Test @DisplayName("Greek language short (health)") - public void greekLanguageShort_health() { + public void greekLanguageShortHealth() { String expected = "υγειά"; assertThat(microBlog.truncate("υγειά")).isEqualTo(expected); } diff --git a/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/nth-prime/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/nth-prime/gradlew b/exercises/practice/nth-prime/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/nth-prime/gradlew +++ b/exercises/practice/nth-prime/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/nth-prime/gradlew.bat b/exercises/practice/nth-prime/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/nth-prime/gradlew.bat +++ b/exercises/practice/nth-prime/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/nth-prime/src/test/java/PrimeCalculatorTest.java b/exercises/practice/nth-prime/src/test/java/PrimeCalculatorTest.java index e13c7f23d..10d0bcf29 100644 --- a/exercises/practice/nth-prime/src/test/java/PrimeCalculatorTest.java +++ b/exercises/practice/nth-prime/src/test/java/PrimeCalculatorTest.java @@ -1,8 +1,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; public class PrimeCalculatorTest { @@ -10,30 +10,35 @@ public class PrimeCalculatorTest { private PrimeCalculator primeCalculator = new PrimeCalculator(); @Test + @DisplayName("first prime") public void testFirstPrime() { assertThat(primeCalculator.nth(1)).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("second prime") public void testSecondPrime() { assertThat(primeCalculator.nth(2)).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("sixth prime") public void testSixthPrime() { assertThat(primeCalculator.nth(6)).isEqualTo(13); } @Disabled("Remove to run test") @Test + @DisplayName("big prime") public void testBigPrime() { assertThat(primeCalculator.nth(10001)).isEqualTo(104743); } @Disabled("Remove to run test") @Test + @DisplayName("there is no zeroth prime") public void testUndefinedPrime() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> primeCalculator.nth(0)); diff --git a/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/nucleotide-count/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/nucleotide-count/gradlew b/exercises/practice/nucleotide-count/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/nucleotide-count/gradlew +++ b/exercises/practice/nucleotide-count/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/nucleotide-count/gradlew.bat b/exercises/practice/nucleotide-count/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/nucleotide-count/gradlew.bat +++ b/exercises/practice/nucleotide-count/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/nucleotide-count/src/test/java/NucleotideCounterTest.java b/exercises/practice/nucleotide-count/src/test/java/NucleotideCounterTest.java index b47fb836e..d5938268a 100644 --- a/exercises/practice/nucleotide-count/src/test/java/NucleotideCounterTest.java +++ b/exercises/practice/nucleotide-count/src/test/java/NucleotideCounterTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Map; @@ -9,6 +10,7 @@ public class NucleotideCounterTest { @Test + @DisplayName("empty strand") public void testEmptyDnaStringHasNoNucleotides() { NucleotideCounter nucleotideCounter = new NucleotideCounter(""); @@ -19,6 +21,7 @@ public void testEmptyDnaStringHasNoNucleotides() { @Disabled("Remove to run test") @Test + @DisplayName("can count one nucleotide in single-character input") public void testDnaStringHasOneNucleotide() { NucleotideCounter nucleotideCounter = new NucleotideCounter("G"); @@ -29,6 +32,7 @@ public void testDnaStringHasOneNucleotide() { @Disabled("Remove to run test") @Test + @DisplayName("strand with repeated nucleotide") public void testRepetitiveSequenceWithOnlyGuanine() { NucleotideCounter nucleotideCounter = new NucleotideCounter("GGGGGGG"); @@ -39,6 +43,7 @@ public void testRepetitiveSequenceWithOnlyGuanine() { @Disabled("Remove to run test") @Test + @DisplayName("strand with multiple nucleotides") public void testDnaStringHasMultipleNucleotide() { NucleotideCounter nucleotideCounter = new NucleotideCounter("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"); @@ -50,6 +55,7 @@ public void testDnaStringHasMultipleNucleotide() { @Disabled("Remove to run test") @Test + @DisplayName("strand with invalid nucleotides") public void testDnaStringHasInvalidNucleotides() { assertThatThrownBy(() -> new NucleotideCounter("AGXXACT")) .isInstanceOf(IllegalArgumentException.class); diff --git a/exercises/practice/ocr-numbers/.docs/instructions.md b/exercises/practice/ocr-numbers/.docs/instructions.md index 7beb25779..8a391ce4f 100644 --- a/exercises/practice/ocr-numbers/.docs/instructions.md +++ b/exercises/practice/ocr-numbers/.docs/instructions.md @@ -1,79 +1,47 @@ # Instructions -Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled. +Optical Character Recognition or OCR is software that converts images of text into machine-readable text. +Given a grid of characters representing some digits, convert the grid to a string of digits. +If the grid has multiple rows of cells, the rows should be separated in the output with a `","`. -## Step One +- The grid is made of one of more lines of cells. +- Each line of the grid is made of one or more cells. +- Each cell is three columns wide and four rows high (3x4) and represents one digit. +- Digits are drawn using pipes (`"|"`), underscores (`"_"`), and spaces (`" "`). -To begin with, convert a simple binary font to a string containing 0 or 1. +## Edge cases -The binary font uses pipes and underscores, four rows high and three columns wide. +- If the input is not a valid size, your program should indicate there is an error. +- If the input is the correct size, but a cell is not recognizable, your program should output a `"?"` for that character. -```text - _ # - | | # zero. - |_| # - # the fourth row is always blank -``` +## Examples -Is converted to "0" - -```text - # - | # one. - | # - # (blank fourth row) -``` - -Is converted to "1" - -If the input is the correct size, but not recognizable, your program should return '?' - -If the input is the incorrect size, your program should return an error. - -## Step Two - -Update your program to recognize multi-character binary strings, replacing garbled numbers with ? - -## Step Three - -Update your program to recognize all numbers 0 through 9, both individually and as part of a larger string. - -```text - _ - _| -|_ - -``` - -Is converted to "2" +The following input (without the comments) is converted to `"1234567890"`. ```text _ _ _ _ _ _ _ _ # - | _| _||_||_ |_ ||_||_|| | # decimal numbers. + | _| _||_||_ |_ ||_||_|| | # Decimal numbers. ||_ _| | _||_| ||_| _||_| # - # fourth line is always blank + # The fourth line is always blank, ``` -Is converted to "1234567890" - -## Step Four +The following input is converted to `"123,456,789"`. -Update your program to handle multiple numbers, one per line. -When converting several lines, join the lines with commas. + ```text - _ _ + _ _ | _| _| ||_ _| - - _ _ -|_||_ |_ + + _ _ +|_||_ |_ | _||_| - - _ _ _ + + _ _ _ ||_||_| ||_| _| - + ``` -Is converted to "123,456,789". + diff --git a/exercises/practice/ocr-numbers/.docs/introduction.md b/exercises/practice/ocr-numbers/.docs/introduction.md new file mode 100644 index 000000000..366d76062 --- /dev/null +++ b/exercises/practice/ocr-numbers/.docs/introduction.md @@ -0,0 +1,6 @@ +# Introduction + +Your best friend Marta recently landed their dream job working with a local history museum's collections. +Knowing of your interests in programming, they confide in you about an issue at work for an upcoming exhibit on computing history. +A local university's math department had donated several boxes of historical printouts, but given the poor condition of the documents, the decision has been made to digitize the text. +However, the university's old printer had some quirks in how text was represented, and your friend could use your help to extract the data successfully. diff --git a/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/ocr-numbers/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/ocr-numbers/gradlew b/exercises/practice/ocr-numbers/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/ocr-numbers/gradlew +++ b/exercises/practice/ocr-numbers/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/ocr-numbers/gradlew.bat b/exercises/practice/ocr-numbers/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/ocr-numbers/gradlew.bat +++ b/exercises/practice/ocr-numbers/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/ocr-numbers/src/test/java/OpticalCharacterReaderTest.java b/exercises/practice/ocr-numbers/src/test/java/OpticalCharacterReaderTest.java index fbe4c040c..6cc079c23 100644 --- a/exercises/practice/ocr-numbers/src/test/java/OpticalCharacterReaderTest.java +++ b/exercises/practice/ocr-numbers/src/test/java/OpticalCharacterReaderTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -9,6 +10,7 @@ public class OpticalCharacterReaderTest { @Test + @DisplayName("Recognizes 0") public void testReaderRecognizesSingle0() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -23,6 +25,7 @@ public void testReaderRecognizesSingle0() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 1") public void testReaderRecognizesSingle1() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " ", @@ -36,6 +39,7 @@ public void testReaderRecognizesSingle1() { @Disabled("Remove to run test") @Test + @DisplayName("Unreadable but correctly sized inputs return ?") public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " ", @@ -49,6 +53,7 @@ public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() { @Disabled("Remove to run test") @Test + @DisplayName("Input with a number of lines that is not a multiple of four raises an error") public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -63,6 +68,7 @@ public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() { @Disabled("Remove to run test") @Test + @DisplayName("Input with a number of columns that is not a multiple of three raises an error") public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3() { @@ -79,6 +85,7 @@ public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3() @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 110101100") public void testReaderRecognizesBinarySequence110101100() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ _ _ _ ", @@ -92,6 +99,7 @@ public void testReaderRecognizesBinarySequence110101100() { @Disabled("Remove to run test") @Test + @DisplayName("Garbled numbers in a string are replaced with ?") public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ _ _ ", @@ -106,6 +114,7 @@ public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence() @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 2") public void testReaderRecognizesSingle2() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -119,6 +128,7 @@ public void testReaderRecognizesSingle2() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 3") public void testReaderRecognizesSingle3() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -132,6 +142,7 @@ public void testReaderRecognizesSingle3() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 4") public void testReaderRecognizesSingle4() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " ", @@ -145,6 +156,7 @@ public void testReaderRecognizesSingle4() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 5") public void testReaderRecognizesSingle5() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -158,6 +170,7 @@ public void testReaderRecognizesSingle5() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 6") public void testReaderRecognizesSingle6() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -171,6 +184,7 @@ public void testReaderRecognizesSingle6() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 7") public void testReaderRecognizesSingle7() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -184,6 +198,7 @@ public void testReaderRecognizesSingle7() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 8") public void testReaderRecognizesSingle8() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -197,6 +212,7 @@ public void testReaderRecognizesSingle8() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes 9") public void testReaderRecognizesSingle9() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ ", @@ -210,6 +226,7 @@ public void testReaderRecognizesSingle9() { @Disabled("Remove to run test") @Test + @DisplayName("Recognizes string of decimal numbers") public void testReaderRecognizesSequence1234567890() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ _ _ _ _ _ _ _ ", @@ -223,6 +240,7 @@ public void testReaderRecognizesSequence1234567890() { @Disabled("Remove to run test") @Test + @DisplayName("Numbers separated by empty lines are recognized. Lines are joined by commas.") public void testReaderRecognizesAndCorrectlyFormatsMultiRowInput() { String parsedInput = new OpticalCharacterReader().parse(Arrays.asList( " _ _ ", diff --git a/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/palindrome-products/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/palindrome-products/gradlew b/exercises/practice/palindrome-products/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/palindrome-products/gradlew +++ b/exercises/practice/palindrome-products/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/palindrome-products/gradlew.bat b/exercises/practice/palindrome-products/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/palindrome-products/gradlew.bat +++ b/exercises/practice/palindrome-products/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/palindrome-products/src/test/java/PalindromeCalculatorTest.java b/exercises/practice/palindrome-products/src/test/java/PalindromeCalculatorTest.java index b82b55109..211b4a9b8 100644 --- a/exercises/practice/palindrome-products/src/test/java/PalindromeCalculatorTest.java +++ b/exercises/practice/palindrome-products/src/test/java/PalindromeCalculatorTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -15,6 +16,7 @@ public class PalindromeCalculatorTest { private PalindromeCalculator palindromeCalculator = new PalindromeCalculator(); @Test + @DisplayName("find the smallest palindrome from single digit factors") public void smallestPalindromeFromSingleDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -30,6 +32,7 @@ public void smallestPalindromeFromSingleDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the largest palindrome from single digit factors") public void largestPalindromeFromSingleDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -46,6 +49,7 @@ public void largestPalindromeFromSingleDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the smallest palindrome from double digit factors") public void largestPalindromeFromDoubleDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -62,6 +66,7 @@ public void largestPalindromeFromDoubleDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the largest palindrome from double digit factors") public void smallestPalindromeFromDoubleDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -78,6 +83,7 @@ public void smallestPalindromeFromDoubleDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the largest palindrome from triple digit factors") public void largestPalindromeFromTripleDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -94,6 +100,7 @@ public void largestPalindromeFromTripleDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the smallest palindrome from triple digit factors") public void smallestPalindromeFromTripleDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -110,6 +117,7 @@ public void smallestPalindromeFromTripleDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the smallest palindrome from four digit factors") public void smallestPalindromeFromQuadDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -126,6 +134,7 @@ public void smallestPalindromeFromQuadDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("find the largest palindrome from four digit factors") public void largestPalindromeFromQuadDigitFactors() { List> expected = Collections.unmodifiableList( Arrays.asList( @@ -142,6 +151,7 @@ public void largestPalindromeFromQuadDigitFactors() { @Disabled("Remove to run test") @Test + @DisplayName("empty result for smallest if no palindrome in the range") public void emtpyResultSmallestNoPalindromeInRange() { SortedMap>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1002, @@ -151,6 +161,7 @@ public void emtpyResultSmallestNoPalindromeInRange() { @Disabled("Remove to run test") @Test + @DisplayName("empty result for largest if no palindrome in the range") public void emptyResultLargestNoPalindromeInRange() { SortedMap>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(15, @@ -160,6 +171,7 @@ public void emptyResultLargestNoPalindromeInRange() { @Disabled("Remove to run test") @Test + @DisplayName("error result for smallest if min is more than max") public void errorSmallestMinIsMoreThanMax() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -169,6 +181,7 @@ public void errorSmallestMinIsMoreThanMax() { @Disabled("Remove to run test") @Test + @DisplayName("error result for largest if min is more than max") public void errorLargestMinIsMoreThanMax() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -178,6 +191,7 @@ public void errorLargestMinIsMoreThanMax() { @Disabled("Remove to run test") @Test + @DisplayName("smallest product does not use the smallest factor") public void smallestProductDoesNotUseTheSmallestFactor() { List> expected = Collections.unmodifiableList( Arrays.asList( diff --git a/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/pangram/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/pangram/gradlew b/exercises/practice/pangram/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/pangram/gradlew +++ b/exercises/practice/pangram/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/pangram/gradlew.bat b/exercises/practice/pangram/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/pangram/gradlew.bat +++ b/exercises/practice/pangram/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/parallel-letter-frequency/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/parallel-letter-frequency/gradlew b/exercises/practice/parallel-letter-frequency/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/parallel-letter-frequency/gradlew +++ b/exercises/practice/parallel-letter-frequency/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/parallel-letter-frequency/gradlew.bat b/exercises/practice/parallel-letter-frequency/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/parallel-letter-frequency/gradlew.bat +++ b/exercises/practice/parallel-letter-frequency/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java b/exercises/practice/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java index 1f3e83ba3..cce168b52 100644 --- a/exercises/practice/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java +++ b/exercises/practice/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -205,6 +206,7 @@ public class ParallelLetterFrequencyTest { "- from the days of the Flood to the Schleswig-Holstein period."; @Test + @DisplayName("no texts") public void testNoTexts() { String[] input = {}; Map expectedOutput = new HashMap<>(); @@ -215,6 +217,7 @@ public void testNoTexts() { @Disabled("Remove to run test") @Test + @DisplayName("one text with one letter") public void testOneTextWithOneLetter() { String[] input = { "a" }; Map expectedOutput = new HashMap<>() { @@ -229,6 +232,7 @@ public void testOneTextWithOneLetter() { @Disabled("Remove to run test") @Test + @DisplayName("one text with multiple letters") public void testOneTextWithMultipleLetters() { String[] input = { "bbcccd" }; Map expectedOutput = new HashMap<>() { @@ -245,6 +249,7 @@ public void testOneTextWithMultipleLetters() { @Disabled("Remove to run test") @Test + @DisplayName("two texts with one letter") public void testTwoTextsWithOneLetter() { String[] input = { "e", "f" }; Map expectedOutput = new HashMap<>() { @@ -260,6 +265,7 @@ public void testTwoTextsWithOneLetter() { @Disabled("Remove to run test") @Test + @DisplayName("two texts with multiple letters") public void testTwoTextsWithMultipleLetters() { String[] input = { "ggh", "hhi" }; Map expectedOutput = new HashMap<>() { @@ -276,6 +282,7 @@ public void testTwoTextsWithMultipleLetters() { @Disabled("Remove to run test") @Test + @DisplayName("ignore letter casing") public void testIgnoreLetterCasing() { String[] input = { "m", "M" }; Map expectedOutput = new HashMap<>() { @@ -290,6 +297,7 @@ public void testIgnoreLetterCasing() { @Disabled("Remove to run test") @Test + @DisplayName("ignore whitespace") public void testIgnoreWhitespace() { String[] input = { " ", "\t", "\r\n" }; Map expectedOutput = new HashMap<>(); @@ -300,6 +308,7 @@ public void testIgnoreWhitespace() { @Disabled("Remove to run test") @Test + @DisplayName("ignore punctuation") public void testIgnorePunctuation() { String[] input = { "!", "?", ";", ",", "." }; Map expectedOutput = new HashMap<>(); @@ -310,6 +319,7 @@ public void testIgnorePunctuation() { @Disabled("Remove to run test") @Test + @DisplayName("ignore numbers") public void testIgnoreNumbers() { String[] input = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; Map expectedOutput = new HashMap<>(); @@ -320,6 +330,7 @@ public void testIgnoreNumbers() { @Disabled("Remove to run test") @Test + @DisplayName("Unicode letters") public void testUnicodeLetters() { String[] input = { "本", "φ", "ほ", "ø" }; Map expectedOutput = new HashMap<>() { @@ -337,6 +348,7 @@ public void testUnicodeLetters() { @Disabled("Remove to run test") @Test + @DisplayName("combination of lower- and uppercase letters, punctuation and white space") public void testCombinationOfLowerAndUppercaseLettersPunctuationAndWhiteSpace() { String[] input = {calculateFrequencies}; Map expectedOutput = new HashMap<>() { @@ -369,26 +381,10 @@ public void testCombinationOfLowerAndUppercaseLettersPunctuationAndWhiteSpace() assertThat(p.countLetters()).isEqualTo(expectedOutput); } - - @Disabled("Remove to run test") - @Test - public void testManySmallTexts() { - String[] input = new String[50]; - Arrays.fill(input, "abbccc"); - Map expectedOutput = new HashMap<>() { - { - put('a', 50); - put('b', 100); - put('c', 150); - } - }; - ParallelLetterFrequency p = new ParallelLetterFrequency(input); - - assertThat(p.countLetters()).isEqualTo(expectedOutput); - } @Disabled("Remove to run test") @Test + @DisplayName("large texts") public void testLargeTexts() { String[] input = { largeTexts1, largeTexts2, largeTexts3, largeTexts4 }; Map expectedOutput = new HashMap<>() { @@ -423,6 +419,24 @@ public void testLargeTexts() { ParallelLetterFrequency p = new ParallelLetterFrequency(input); assertThat(p.countLetters()).isEqualTo(expectedOutput); - } + } + + @Disabled("Remove to run test") + @Test + @DisplayName("many small texts") + public void testManySmallTexts() { + String[] input = new String[50]; + Arrays.fill(input, "abbccc"); + Map expectedOutput = new HashMap<>() { + { + put('a', 50); + put('b', 100); + put('c', 150); + } + }; + ParallelLetterFrequency p = new ParallelLetterFrequency(input); + + assertThat(p.countLetters()).isEqualTo(expectedOutput); + } } diff --git a/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/pascals-triangle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/pascals-triangle/gradlew b/exercises/practice/pascals-triangle/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/pascals-triangle/gradlew +++ b/exercises/practice/pascals-triangle/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/pascals-triangle/gradlew.bat b/exercises/practice/pascals-triangle/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/pascals-triangle/gradlew.bat +++ b/exercises/practice/pascals-triangle/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/pascals-triangle/src/test/java/PascalsTriangleGeneratorTest.java b/exercises/practice/pascals-triangle/src/test/java/PascalsTriangleGeneratorTest.java index c72c2dc07..becdb0825 100644 --- a/exercises/practice/pascals-triangle/src/test/java/PascalsTriangleGeneratorTest.java +++ b/exercises/practice/pascals-triangle/src/test/java/PascalsTriangleGeneratorTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -9,6 +10,7 @@ public class PascalsTriangleGeneratorTest { new PascalsTriangleGenerator(); @Test + @DisplayName("zero rows") public void testTriangleWithZeroRows() { int[][] expectedOutput = new int[][]{}; @@ -17,6 +19,7 @@ public void testTriangleWithZeroRows() { @Disabled("Remove to run test") @Test + @DisplayName("single row") public void testTriangleWithOneRow() { int[][] expectedOutput = new int[][]{ {1} @@ -27,6 +30,7 @@ public void testTriangleWithOneRow() { @Disabled("Remove to run test") @Test + @DisplayName("two rows") public void testTriangleWithTwoRows() { int[][] expectedOutput = new int[][]{ {1}, @@ -38,6 +42,7 @@ public void testTriangleWithTwoRows() { @Disabled("Remove to run test") @Test + @DisplayName("three rows") public void testTriangleWithThreeRows() { int[][] expectedOutput = new int[][]{ {1}, @@ -50,6 +55,7 @@ public void testTriangleWithThreeRows() { @Disabled("Remove to run test") @Test + @DisplayName("four rows") public void testTriangleWithFourRows() { int[][] expectedOutput = new int[][]{ {1}, @@ -63,6 +69,7 @@ public void testTriangleWithFourRows() { @Disabled("Remove to run test") @Test + @DisplayName("five rows") public void testTriangleWithFiveRows() { int[][] expectedOutput = new int[][]{ {1}, @@ -77,6 +84,7 @@ public void testTriangleWithFiveRows() { @Disabled("Remove to run test") @Test + @DisplayName("six rows") public void testTriangleWithSixRows() { int[][] expectedOutput = new int[][]{ {1}, @@ -92,6 +100,7 @@ public void testTriangleWithSixRows() { @Disabled("Remove to run test") @Test + @DisplayName("ten rows") public void testTriangleWithTenRows() { int[][] expectedOutput = new int[][]{ {1}, diff --git a/exercises/practice/perfect-numbers/.meta/tests.toml b/exercises/practice/perfect-numbers/.meta/tests.toml index 3232bb44e..81d484081 100644 --- a/exercises/practice/perfect-numbers/.meta/tests.toml +++ b/exercises/practice/perfect-numbers/.meta/tests.toml @@ -1,42 +1,52 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [163e8e86-7bfd-4ee2-bd68-d083dc3381a3] -description = "Smallest perfect number is classified correctly" +description = "Perfect numbers -> Smallest perfect number is classified correctly" [169a7854-0431-4ae0-9815-c3b6d967436d] -description = "Medium perfect number is classified correctly" +description = "Perfect numbers -> Medium perfect number is classified correctly" [ee3627c4-7b36-4245-ba7c-8727d585f402] -description = "Large perfect number is classified correctly" +description = "Perfect numbers -> Large perfect number is classified correctly" [80ef7cf8-9ea8-49b9-8b2d-d9cb3db3ed7e] -description = "Smallest abundant number is classified correctly" +description = "Abundant numbers -> Smallest abundant number is classified correctly" [3e300e0d-1a12-4f11-8c48-d1027165ab60] -description = "Medium abundant number is classified correctly" +description = "Abundant numbers -> Medium abundant number is classified correctly" [ec7792e6-8786-449c-b005-ce6dd89a772b] -description = "Large abundant number is classified correctly" +description = "Abundant numbers -> Large abundant number is classified correctly" + +[05f15b93-849c-45e9-9c7d-1ea131ef7d10] +description = "Abundant numbers -> Perfect square abundant number is classified correctly" [e610fdc7-2b6e-43c3-a51c-b70fb37413ba] -description = "Smallest prime deficient number is classified correctly" +description = "Deficient numbers -> Smallest prime deficient number is classified correctly" [0beb7f66-753a-443f-8075-ad7fbd9018f3] -description = "Smallest non-prime deficient number is classified correctly" +description = "Deficient numbers -> Smallest non-prime deficient number is classified correctly" [1c802e45-b4c6-4962-93d7-1cad245821ef] -description = "Medium deficient number is classified correctly" +description = "Deficient numbers -> Medium deficient number is classified correctly" [47dd569f-9e5a-4a11-9a47-a4e91c8c28aa] -description = "Large deficient number is classified correctly" +description = "Deficient numbers -> Large deficient number is classified correctly" [a696dec8-6147-4d68-afad-d38de5476a56] -description = "Edge case (no factors other than itself) is classified correctly" +description = "Deficient numbers -> Edge case (no factors other than itself) is classified correctly" [72445cee-660c-4d75-8506-6c40089dc302] -description = "Zero is rejected (not a natural number)" +description = "Invalid inputs -> Zero is rejected (as it is not a positive integer)" [2d72ce2c-6802-49ac-8ece-c790ba3dae13] -description = "Negative integer is rejected (not a natural number)" +description = "Invalid inputs -> Negative integer is rejected (as it is not a positive integer)" diff --git a/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/perfect-numbers/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/perfect-numbers/gradlew b/exercises/practice/perfect-numbers/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/perfect-numbers/gradlew +++ b/exercises/practice/perfect-numbers/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/perfect-numbers/gradlew.bat b/exercises/practice/perfect-numbers/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/perfect-numbers/gradlew.bat +++ b/exercises/practice/perfect-numbers/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/perfect-numbers/src/test/java/NaturalNumberTest.java b/exercises/practice/perfect-numbers/src/test/java/NaturalNumberTest.java index b7387c4b1..fb2f3600d 100644 --- a/exercises/practice/perfect-numbers/src/test/java/NaturalNumberTest.java +++ b/exercises/practice/perfect-numbers/src/test/java/NaturalNumberTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -7,66 +8,84 @@ public class NaturalNumberTest { @Test + @DisplayName("Smallest perfect number is classified correctly") public void testSmallPerfectNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(6).getClassification()).isEqualTo(Classification.PERFECT); } @Disabled("Remove to run test") @Test + @DisplayName("Medium perfect number is classified correctly") public void testMediumPerfectNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(28).getClassification()).isEqualTo(Classification.PERFECT); } @Disabled("Remove to run test") @Test + @DisplayName("Large perfect number is classified correctly") public void testLargePerfectNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(33550336).getClassification()).isEqualTo(Classification.PERFECT); } @Disabled("Remove to run test") @Test + @DisplayName("Smallest abundant number is classified correctly") public void testSmallAbundantNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(12).getClassification()).isEqualTo(Classification.ABUNDANT); } @Disabled("Remove to run test") @Test + @DisplayName("Medium abundant number is classified correctly") public void testMediumAbundantNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(30).getClassification()).isEqualTo(Classification.ABUNDANT); } @Disabled("Remove to run test") @Test + @DisplayName("Large abundant number is classified correctly") public void testLargeAbundantNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(33550335).getClassification()).isEqualTo(Classification.ABUNDANT); } @Disabled("Remove to run test") @Test + @DisplayName("Perfect square abundant number is classified correctly") + public void testPerfectSquareAbundantNumberIsClassifiedCorrectly() { + assertThat(new NaturalNumber(196).getClassification()).isEqualTo(Classification.ABUNDANT); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Smallest prime deficient number is classified correctly") public void testSmallestPrimeDeficientNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(2).getClassification()).isEqualTo(Classification.DEFICIENT); } @Disabled("Remove to run test") @Test + @DisplayName("Smallest non-prime deficient number is classified correctly") public void testSmallestNonPrimeDeficientNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(4).getClassification()).isEqualTo(Classification.DEFICIENT); } @Disabled("Remove to run test") @Test + @DisplayName("Medium deficient number is classified as DEFICIENT") public void testMediumDeficientNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(32).getClassification()).isEqualTo(Classification.DEFICIENT); } @Disabled("Remove to run test") @Test + @DisplayName("Large deficient number is classified as DEFICIENT") public void testLargeDeficientNumberIsClassifiedCorrectly() { assertThat(new NaturalNumber(33550337).getClassification()).isEqualTo(Classification.DEFICIENT); } @Disabled("Remove to run test") @Test + @DisplayName("Edge case (no factors other than itself) is classified correctly") /* * The number 1 has no proper divisors (https://en.wikipedia.org/wiki/Divisor#Further_notions_and_facts), and the * additive identity is 0, so the aliquot sum of 1 should be 0. Hence 1 should be classified as deficient. @@ -77,6 +96,7 @@ public void testThatOneIsCorrectlyClassifiedAsDeficient() { @Disabled("Remove to run test") @Test + @DisplayName("Zero is rejected (as it is not a positive integer)") public void testThatNonNegativeIntegerIsRejected() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new NaturalNumber(0)) @@ -85,6 +105,7 @@ public void testThatNonNegativeIntegerIsRejected() { @Disabled("Remove to run test") @Test + @DisplayName("Negative integer is rejected (as it is not a positive integer)") public void testThatNegativeIntegerIsRejected() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new NaturalNumber(-1)) diff --git a/exercises/practice/phone-number/.meta/config.json b/exercises/practice/phone-number/.meta/config.json index 3f9c2df66..295278293 100644 --- a/exercises/practice/phone-number/.meta/config.json +++ b/exercises/practice/phone-number/.meta/config.json @@ -43,5 +43,5 @@ }, "blurb": "Clean up user-entered phone numbers so that they can be sent SMS messages.", "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", - "source_url": "https://turing.edu" + "source_url": "https://www.turing.edu/" } diff --git a/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/phone-number/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/phone-number/gradlew b/exercises/practice/phone-number/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/phone-number/gradlew +++ b/exercises/practice/phone-number/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/phone-number/gradlew.bat b/exercises/practice/phone-number/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/phone-number/gradlew.bat +++ b/exercises/practice/phone-number/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/phone-number/src/test/java/PhoneNumberTest.java b/exercises/practice/phone-number/src/test/java/PhoneNumberTest.java index bfd7c6212..300415b65 100644 --- a/exercises/practice/phone-number/src/test/java/PhoneNumberTest.java +++ b/exercises/practice/phone-number/src/test/java/PhoneNumberTest.java @@ -1,12 +1,14 @@ -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public class PhoneNumberTest { @Test + @DisplayName("cleans the number") public void cleansTheNumber() { String expectedNumber = "2234567890"; String actualNumber = new PhoneNumber("(223) 456-7890").getNumber(); @@ -16,6 +18,7 @@ public void cleansTheNumber() { @Disabled("Remove to run test") @Test + @DisplayName("cleans numbers with dots") public void cleansNumbersWithDots() { String expectedNumber = "2234567890"; String actualNumber = new PhoneNumber("223.456.7890").getNumber(); @@ -26,6 +29,7 @@ public void cleansNumbersWithDots() { @Disabled("Remove to run test") @Test + @DisplayName("cleans numbers with multiple spaces") public void cleansNumbersWithMultipleSpaces() { String expectedNumber = "2234567890"; String actualNumber = new PhoneNumber("223 456 7890 ").getNumber(); @@ -35,6 +39,7 @@ public void cleansNumbersWithMultipleSpaces() { @Disabled("Remove to run test") @Test + @DisplayName("invalid when 9 digits") public void invalidWhen9Digits() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -44,6 +49,7 @@ public void invalidWhen9Digits() { @Disabled("Remove to run test") @Test + @DisplayName("invalid when 11 digits does not start with a 1") public void invalidWhen11DigitsDoesNotStartWith1() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -53,6 +59,7 @@ public void invalidWhen11DigitsDoesNotStartWith1() { @Disabled("Remove to run test") @Test + @DisplayName("valid when 11 digits and starting with 1") public void validWhen11DigitsAndStartingWith1() { String expectedNumber = "2234567890"; String actualNumber = new PhoneNumber("12234567890").getNumber(); @@ -62,6 +69,7 @@ public void validWhen11DigitsAndStartingWith1() { @Disabled("Remove to run test") @Test + @DisplayName("valid when 11 digits and starting with 1 even with punctuation") public void validWhen11DigitsAndStartingWith1EvenWithPunctuation() { String expectedNumber = "2234567890"; String actualNumber = new PhoneNumber("+1 (223) 456-7890").getNumber(); @@ -71,6 +79,7 @@ public void validWhen11DigitsAndStartingWith1EvenWithPunctuation() { @Disabled("Remove to run test") @Test + @DisplayName("invalid when more than 11 digits") public void invalidWhenMoreThan11Digits() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("321234567890")) @@ -79,6 +88,7 @@ public void invalidWhenMoreThan11Digits() { @Disabled("Remove to run test") @Test + @DisplayName("invalid with letters") public void invalidWithLetters() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("523-abc-7890")) @@ -87,6 +97,7 @@ public void invalidWithLetters() { @Disabled("Remove to run test") @Test + @DisplayName("invalid with punctuations") public void invalidWithPunctuations() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("523-@:!-7890")) @@ -95,6 +106,7 @@ public void invalidWithPunctuations() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if area code starts with 0") public void invalidIfAreaCodeStartsWith0() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("(023) 456-7890")) @@ -103,6 +115,7 @@ public void invalidIfAreaCodeStartsWith0() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if area code starts with 1") public void invalidIfAreaCodeStartsWith1() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("(123) 456-7890")) @@ -111,6 +124,7 @@ public void invalidIfAreaCodeStartsWith1() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if exchange code starts with 0") public void invalidIfExchangeCodeStartsWith0() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("(223) 056-7890")) @@ -119,6 +133,7 @@ public void invalidIfExchangeCodeStartsWith0() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if exchange code starts with 1") public void invalidIfExchangeCodeStartsWith1() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("(223) 156-7890")) @@ -127,6 +142,7 @@ public void invalidIfExchangeCodeStartsWith1() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if area code starts with 0 on valid 11-digit number") public void invalidIfAreaCodeStartsWith0OnValid11DigitNumber() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("1 (023) 456-7890")) @@ -135,6 +151,7 @@ public void invalidIfAreaCodeStartsWith0OnValid11DigitNumber() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if area code starts with 1 on valid 11-digit number") public void invalidIfAreaCodeStartsWith1OnValid11DigitNumber() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("1 (123) 456-7890")) @@ -143,6 +160,7 @@ public void invalidIfAreaCodeStartsWith1OnValid11DigitNumber() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if exchange code starts with 0 on valid 11-digit number") public void invalidIfExchangeCodeStartsWith0OnValid11DigitNumber() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("1 (223) 056-7890")) @@ -151,6 +169,7 @@ public void invalidIfExchangeCodeStartsWith0OnValid11DigitNumber() { @Disabled("Remove to run test") @Test + @DisplayName("invalid if exchange code starts with 1 on valid 11-digit number") public void invalidIfExchangeCodeStartsWith1OnValid11DigitNumber() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new PhoneNumber("1 (223) 156-7890")) diff --git a/exercises/practice/piecing-it-together/.docs/instructions.md b/exercises/practice/piecing-it-together/.docs/instructions.md index c0c966592..8a2781d99 100644 --- a/exercises/practice/piecing-it-together/.docs/instructions.md +++ b/exercises/practice/piecing-it-together/.docs/instructions.md @@ -24,18 +24,24 @@ For this exercise, you may assume square pieces, so that the format can be deriv ### Portrait -A portrait jigsaw puzzle with 6 pieces, all of which are border pieces and none are inside pieces. It has 3 rows and 2 columns. The aspect ratio is 1.5 (3/2). +A portrait jigsaw puzzle with 6 pieces, all of which are border pieces and none are inside pieces. +It has 2 columns and 3 rows. +The aspect ratio is 0.666666... (2/3). ![A 2 by 3 jigsaw puzzle](https://assets.exercism.org/images/exercises/piecing-it-together/jigsaw-puzzle-2x3.svg) ### Square -A square jigsaw puzzle with 9 pieces, all of which are border pieces except for the one in the center, which is an inside piece. It has 3 rows and 3 columns. The aspect ratio is 1 (3/3). +A square jigsaw puzzle with 9 pieces, all of which are border pieces except for the one in the center, which is an inside piece. +It has 3 columns and 3 rows. +The aspect ratio is 1.0 (3/3). ![A 3 by 3 jigsaw puzzle](https://assets.exercism.org/images/exercises/piecing-it-together/jigsaw-puzzle-3x3.svg) ### Landscape -A landscape jigsaw puzzle with 12 pieces, 10 of which are border pieces and 2 are inside pieces. It has 3 rows and 4 columns. The aspect ratio is 1.333333... (4/3). +A landscape jigsaw puzzle with 12 pieces, 10 of which are border pieces and 2 are inside pieces. +It has 4 columns and 3 rows. +The aspect ratio is 1.333333... (4/3). ![A 4 by 3 jigsaw puzzle](https://assets.exercism.org/images/exercises/piecing-it-together/jigsaw-puzzle-4x3.svg) diff --git a/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/piecing-it-together/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/piecing-it-together/gradlew b/exercises/practice/piecing-it-together/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/piecing-it-together/gradlew +++ b/exercises/practice/piecing-it-together/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/piecing-it-together/gradlew.bat b/exercises/practice/piecing-it-together/gradlew.bat index 93e3f59f1..24c62d56f 100644 --- a/exercises/practice/piecing-it-together/gradlew.bat +++ b/exercises/practice/piecing-it-together/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -43,13 +45,13 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -57,36 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/piecing-it-together/src/test/java/PiecingItTogetherTest.java b/exercises/practice/piecing-it-together/src/test/java/PiecingItTogetherTest.java index b07648c0a..791302fa3 100644 --- a/exercises/practice/piecing-it-together/src/test/java/PiecingItTogetherTest.java +++ b/exercises/practice/piecing-it-together/src/test/java/PiecingItTogetherTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,6 +9,7 @@ public class PiecingItTogetherTest { private static final double DOUBLE_EQUALITY_TOLERANCE = 1e-9; @Test + @DisplayName("1000 pieces puzzle with 1.6 aspect ratio") public void test1000PiecesWithAspectRatio() { JigsawInfo input = new JigsawInfo.Builder() .pieces(1000) @@ -30,6 +32,7 @@ public void test1000PiecesWithAspectRatio() { @Disabled("Remove to run test") @Test + @DisplayName("square puzzle with 32 rows") public void testSquarePuzzleWith32Rows() { JigsawInfo input = new JigsawInfo.Builder() .rows(32) @@ -52,6 +55,7 @@ public void testSquarePuzzleWith32Rows() { @Disabled("Remove to run test") @Test + @DisplayName("400 pieces square puzzle with only inside pieces and aspect ratio") public void testInsideAndAspectRatioOnly() { JigsawInfo input = new JigsawInfo.Builder() .inside(324) @@ -74,6 +78,7 @@ public void testInsideAndAspectRatioOnly() { @Disabled("Remove to run test") @Test + @DisplayName("1500 pieces landscape puzzle with 30 rows and 1.6 aspect ratio") public void testLandscape1500WithRowsAndAspect() { JigsawInfo input = new JigsawInfo.Builder() .rows(30) @@ -96,6 +101,7 @@ public void testLandscape1500WithRowsAndAspect() { @Disabled("Remove to run test") @Test + @DisplayName("300 pieces portrait puzzle with 70 border pieces") public void test300PiecesPortraitWithBorder() { JigsawInfo input = new JigsawInfo.Builder() .pieces(300) @@ -119,6 +125,7 @@ public void test300PiecesPortraitWithBorder() { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with insufficient data") public void testInsufficientData() { JigsawInfo input = new JigsawInfo.Builder() .pieces(1500) @@ -132,6 +139,7 @@ public void testInsufficientData() { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with contradictory data") public void testContradictoryData() { JigsawInfo input = new JigsawInfo.Builder() .rows(100) diff --git a/exercises/practice/pig-latin/.meta/config.json b/exercises/practice/pig-latin/.meta/config.json index e0bbd7c25..d809a6255 100644 --- a/exercises/practice/pig-latin/.meta/config.json +++ b/exercises/practice/pig-latin/.meta/config.json @@ -41,5 +41,5 @@ }, "blurb": "Implement a program that translates from English to Pig Latin.", "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", - "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" + "source_url": "https://github.com/ultrasaurus/test-first-teaching/tree/master/learn_ruby/pig_latin" } diff --git a/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/pig-latin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/pig-latin/gradlew b/exercises/practice/pig-latin/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/pig-latin/gradlew +++ b/exercises/practice/pig-latin/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/pig-latin/gradlew.bat b/exercises/practice/pig-latin/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/pig-latin/gradlew.bat +++ b/exercises/practice/pig-latin/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/pig-latin/src/test/java/PigLatinTranslatorTest.java b/exercises/practice/pig-latin/src/test/java/PigLatinTranslatorTest.java index a3fb91d95..0a7466dcd 100644 --- a/exercises/practice/pig-latin/src/test/java/PigLatinTranslatorTest.java +++ b/exercises/practice/pig-latin/src/test/java/PigLatinTranslatorTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,138 +15,161 @@ public void setup() { } @Test + @DisplayName("word beginning with a") public void testWordBeginningWithA() { assertThat(pigLatinTranslator.translate("apple")).isEqualTo("appleay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with e") public void testWordBeginningWithE() { assertThat(pigLatinTranslator.translate("ear")).isEqualTo("earay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with i") public void testWordBeginningWithI() { assertThat(pigLatinTranslator.translate("igloo")).isEqualTo("iglooay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with o") public void testWordBeginningWithO() { assertThat(pigLatinTranslator.translate("object")).isEqualTo("objectay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with u") public void testWordBeginningWithU() { assertThat(pigLatinTranslator.translate("under")).isEqualTo("underay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with a vowel and followed by a qu") public void testWordBeginningWithVowelAndFollowedByQu() { assertThat(pigLatinTranslator.translate("equal")).isEqualTo("equalay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with p") public void testWordBeginningWithP() { assertThat(pigLatinTranslator.translate("pig")).isEqualTo("igpay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with k") public void testWordBeginningWithK() { assertThat(pigLatinTranslator.translate("koala")).isEqualTo("oalakay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with x") public void testWordBeginningWithX() { assertThat(pigLatinTranslator.translate("xenon")).isEqualTo("enonxay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with q without a following u") public void testWordBeginningWithQWithoutAFollowingU() { assertThat(pigLatinTranslator.translate("qat")).isEqualTo("atqay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with consonant and vowel containing qu") public void testWordBeginningWithConsonantAndVowelContainingQu() { assertThat(pigLatinTranslator.translate("liquid")).isEqualTo("iquidlay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with ch") public void testChTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("chair")).isEqualTo("airchay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with qu") public void testQuTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("queen")).isEqualTo("eenquay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with qu and a preceding consonant") public void testQuAndAPrecedingConsonantTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("square")).isEqualTo("aresquay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with th") public void testThTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("therapy")).isEqualTo("erapythay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with thr") public void testThrTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("thrush")).isEqualTo("ushthray"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with sch") public void testSchTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("school")).isEqualTo("oolschay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with yt") public void testYtTreatedLikeAVowelAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("yttria")).isEqualTo("yttriaay"); } @Disabled("Remove to run test") @Test + @DisplayName("word beginning with xr") public void testXrTreatedLikeAVowelAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("xray")).isEqualTo("xrayay"); } @Disabled("Remove to run test") @Test + @DisplayName("y is treated like a consonant at the beginning of a word") public void testYTreatedLikeAConsonantAtTheBeginningOfAWord() { assertThat(pigLatinTranslator.translate("yellow")).isEqualTo("ellowyay"); } @Disabled("Remove to run test") @Test + @DisplayName("y is treated like a vowel at the end of a consonant cluster") public void testYTreatedLikeAVowelAtTheEndOfAConsonantCluster() { assertThat(pigLatinTranslator.translate("rhythm")).isEqualTo("ythmrhay"); } @Disabled("Remove to run test") @Test + @DisplayName("y as second letter in two letter word") public void testYAsSecondLetterInTwoLetterWord() { assertThat(pigLatinTranslator.translate("my")).isEqualTo("ymay"); } @Disabled("Remove to run test") @Test + @DisplayName("a whole phrase") public void testAWholePhrase() { assertThat(pigLatinTranslator.translate("quick fast run")).isEqualTo("ickquay astfay unray"); } diff --git a/exercises/practice/poker/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/poker/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/poker/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/poker/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/poker/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/poker/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/poker/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/poker/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/poker/gradlew b/exercises/practice/poker/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/poker/gradlew +++ b/exercises/practice/poker/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/poker/gradlew.bat b/exercises/practice/poker/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/poker/gradlew.bat +++ b/exercises/practice/poker/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/poker/src/test/java/PokerTest.java b/exercises/practice/poker/src/test/java/PokerTest.java index 016889229..367b776df 100644 --- a/exercises/practice/poker/src/test/java/PokerTest.java +++ b/exercises/practice/poker/src/test/java/PokerTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -8,6 +9,7 @@ public class PokerTest { @Test + @DisplayName("single hand always wins") public void oneHand() { String hand = "4S 5S 7H 8D JC"; assertThat(new Poker(Collections.singletonList(hand)).getBestHands()) @@ -16,6 +18,7 @@ public void oneHand() { @Disabled("Remove to run test") @Test + @DisplayName("highest card out of all hands wins") public void highestCardWins() { String highest8 = "4D 5S 6S 8D 3C"; String highest10 = "2S 4C 7S 9H 10H"; @@ -26,6 +29,7 @@ public void highestCardWins() { @Disabled("Remove to run test") @Test + @DisplayName("a tie has multiple winners") public void tieHasMultipleWinners() { String highest8 = "4D 5S 6S 8D 3C"; String highest10 = "2S 4C 7S 9H 10H"; @@ -37,6 +41,7 @@ public void tieHasMultipleWinners() { @Disabled("Remove to run test") @Test + @DisplayName("multiple hands with the same high cards, tie compares next highest ranked, down to last card") public void sameHighCards() { String nextHighest3 = "3S 5H 6S 8D 7H"; String nextHighest2 = "2S 5D 6D 8C 7S"; @@ -46,6 +51,7 @@ public void sameHighCards() { @Disabled("Remove to run test") @Test + @DisplayName("winning high card hand also has the lowest card") public void winningWithLowestCard() { String lowest2 = "2S 5H 6S 8D 7H"; String lowest3 = "3S 4D 6D 8C 7S"; @@ -55,6 +61,7 @@ public void winningWithLowestCard() { @Disabled("Remove to run test") @Test + @DisplayName("one pair beats high card") public void nothingVsOnePair() { String nothing = "4S 5H 6C 8D KH"; String pairOf4 = "2S 4H 6S 4D JH"; @@ -64,6 +71,7 @@ public void nothingVsOnePair() { @Disabled("Remove to run test") @Test + @DisplayName("highest pair wins") public void twoPairs() { String pairOf2 = "4S 2H 6S 2D JH"; String pairOf4 = "2S 4H 6C 4D JD"; @@ -73,6 +81,7 @@ public void twoPairs() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have the same pair, high card wins") public void samePair() { String pairOf4Lower = "4H 4S AH JC 3D"; String pairOf4Higher = "4C 4D AS 5D 6C"; @@ -82,6 +91,7 @@ public void samePair() { @Disabled("Remove to run test") @Test + @DisplayName("two pairs beats one pair") public void onePairVsDoublePair() { String pairOf8 = "2S 8H 6S 8D JH"; String doublePair = "4S 5H 4C 8C 5C"; @@ -91,6 +101,7 @@ public void onePairVsDoublePair() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have two pairs, highest ranked pair wins") public void twoDoublePairs() { String doublePair2And8 = "2S 8H 2D 8D 3H"; String doublePair4And5 = "4S 5H 4C 8S 5D"; @@ -100,6 +111,7 @@ public void twoDoublePairs() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have two pairs, with the same highest ranked pair, tie goes to low pair") public void sameHighestPair() { String doublePair2AndQ = "2S QS 2C QD JH"; String doublePairJAndQ = "JD QH JS 8D QC"; @@ -109,6 +121,7 @@ public void sameHighestPair() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have two identically ranked pairs, tie goes to remaining card (kicker)") public void identicallyRankedPairs() { String kicker8 = "JD QH JS 8D QC"; String kicker2 = "JS QS JC 2D QD"; @@ -118,6 +131,7 @@ public void identicallyRankedPairs() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have two pairs that add to the same value, win goes to highest pair") public void twoPairsAddingToSameValue() { String doublePair6And3 = "6S 6H 3S 3H AS"; String doublePair7And2 = "7H 7S 2H 2S AC"; @@ -127,6 +141,7 @@ public void twoPairsAddingToSameValue() { @Disabled("Remove to run test") @Test + @DisplayName("two pairs first ranked by largest pair") public void rankedByLargestPair() { String doublePairs5And4 = "5C 2S 5S 4H 4C"; String doublePairs6And2 = "6S 2S 6H 7C 2C"; @@ -136,6 +151,7 @@ public void rankedByLargestPair() { @Disabled("Remove to run test") @Test + @DisplayName("three of a kind beats two pair") public void doublePairVsThree() { String doublePair2And8 = "2S 8H 2H 8D JH"; String threeOf4 = "4S 5H 4C 8S 4H"; @@ -145,6 +161,7 @@ public void doublePairVsThree() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have three of a kind, tie goes to highest ranked triplet") public void twoThrees() { String threeOf2 = "2S 2H 2C 8D JH"; String threeOf1 = "4S AH AS 8C AD"; @@ -154,6 +171,7 @@ public void twoThrees() { @Disabled("Remove to run test") @Test + @DisplayName("with multiple decks, two players can have same three of a kind, ties go to highest remaining cards") public void sameThreesMultipleDecks() { String remainingCard7 = "5S AH AS 7C AD"; String remainingCard8 = "4S AH AS 8C AD"; @@ -163,6 +181,7 @@ public void sameThreesMultipleDecks() { @Disabled("Remove to run test") @Test + @DisplayName("a straight beats three of a kind") public void threeVsStraight() { String threeOf4 = "4S 5H 4C 8D 4H"; String straight = "3S 4D 2S 6D 5C"; @@ -172,6 +191,7 @@ public void threeVsStraight() { @Disabled("Remove to run test") @Test + @DisplayName("aces can end a straight (10 J Q K A)") public void acesCanEndAStraight() { String hand = "4S 5H 4C 8D 4H"; String straightEndsA = "10D JH QS KD AC"; @@ -181,6 +201,7 @@ public void acesCanEndAStraight() { @Disabled("Remove to run test") @Test + @DisplayName("aces can start a straight (A 2 3 4 5)") public void acesCanStartAStraight() { String hand = "4S 5H 4C 8D 4H"; String straightStartA = "4D AH 3S 2D 5C"; @@ -190,6 +211,7 @@ public void acesCanStartAStraight() { @Disabled("Remove to run test") @Test + @DisplayName("aces cannot be in the middle of a straight (Q K A 2 3)") public void acesCannotBeInMiddleOfStraight() { String hand = "2C 3D 7H 5H 2S"; String straightMiddleA = "QS KH AC 2D 3S"; @@ -199,6 +221,7 @@ public void acesCannotBeInMiddleOfStraight() { @Disabled("Remove to run test") @Test + @DisplayName("both hands with a straight, tie goes to highest ranked card") public void twoStraights() { String straightTo8 = "4S 6C 7S 8D 5H"; String straightTo9 = "5S 7H 8S 9D 6H"; @@ -208,6 +231,7 @@ public void twoStraights() { @Disabled("Remove to run test") @Test + @DisplayName("even though an ace is usually high, a 5-high straight is the lowest-scoring straight") public void theLowestStraightStartsWithAce() { String straight = "2H 3C 4D 5D 6H"; String straightStartA = "4S AH 3S 2D 5H"; @@ -217,6 +241,7 @@ public void theLowestStraightStartsWithAce() { @Disabled("Remove to run test") @Test + @DisplayName("flush beats a straight") public void straightVsFlush() { String straightTo8 = "4C 6H 7D 8D 5H"; String flushTo7 = "2S 4S 5S 6S 7S"; @@ -226,6 +251,7 @@ public void straightVsFlush() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have a flush, tie goes to high card, down to the last one if necessary") public void twoFlushs() { String flushTo9 = "2H 7H 8H 9H 6H"; String flushTo7 = "3S 5S 6S 7S 8S"; @@ -235,6 +261,7 @@ public void twoFlushs() { @Disabled("Remove to run test") @Test + @DisplayName("full house beats a flush") public void flushVsFull() { String flushTo8 = "3H 6H 7H 8H 5H"; String full = "4S 5H 4C 5D 4H"; @@ -244,6 +271,7 @@ public void flushVsFull() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have a full house, tie goes to highest-ranked triplet") public void twoFulls() { String fullOf4By9 = "4H 4S 4D 9S 9D"; String fullOf5By8 = "5H 5S 5D 8S 8D"; @@ -253,6 +281,7 @@ public void twoFulls() { @Disabled("Remove to run test") @Test + @DisplayName("with multiple decks, both hands have a full house with the same triplet, tie goes to the pair") public void twoFullssameThripletMultipleDecks() { String fullOf5By9 = "5H 5S 5D 9S 9D"; String fullOf5By8 = "5H 5S 5D 8S 8D"; @@ -262,6 +291,7 @@ public void twoFullssameThripletMultipleDecks() { @Disabled("Remove to run test") @Test + @DisplayName("four of a kind beats a full house") public void fullVsSquare() { String full = "4S 5H 4D 5D 4H"; String squareOf3 = "3S 3H 2S 3D 3C"; @@ -271,6 +301,7 @@ public void fullVsSquare() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have four of a kind, tie goes to high quad") public void twoSquares() { String squareOf2 = "2S 2H 2C 8D 2D"; String squareOf5 = "4S 5H 5S 5D 5C"; @@ -280,6 +311,7 @@ public void twoSquares() { @Disabled("Remove to run test") @Test + @DisplayName("with multiple decks, both hands with identical four of a kind, tie determined by kicker") public void sameSquaresMultipleDecks() { String kicker2 = "3S 3H 2S 3D 3C"; String kicker4 = "3S 3H 4S 3D 3C"; @@ -289,6 +321,7 @@ public void sameSquaresMultipleDecks() { @Disabled("Remove to run test") @Test + @DisplayName("straight flush beats four of a kind") public void squareVsStraightFlush() { String squareOf5 = "4S 5H 5S 5D 5C"; String straightFlushTo9 = "7S 8S 9S 6S 10S"; @@ -298,6 +331,7 @@ public void squareVsStraightFlush() { @Disabled("Remove to run test") @Test + @DisplayName("aces can end a straight flush (10 J Q K A)") public void acesEndingStraightFlush() { String hand = "KC AH AS AD AC"; String straightFlushEndingWithA = "10C JC QC KC AC"; @@ -307,6 +341,7 @@ public void acesEndingStraightFlush() { @Disabled("Remove to run test") @Test + @DisplayName("aces can start a straight flush (A 2 3 4 5)") public void acesStartingStraightFlush() { String straightFlushStartingWithA = "4H AH 3H 2H 5H"; String hand = "KS AH AS AD AC"; @@ -316,6 +351,7 @@ public void acesStartingStraightFlush() { @Disabled("Remove to run test") @Test + @DisplayName("aces cannot be in the middle of a straight flush (Q K A 2 3)") public void acesCannotBeInMiddleOfStraightFlush() { String straightFlushWithAInMiddle = "QH KH AH 2H 3H"; String hand = "2C AC QC 10C KC"; @@ -325,6 +361,7 @@ public void acesCannotBeInMiddleOfStraightFlush() { @Disabled("Remove to run test") @Test + @DisplayName("both hands have a straight flush, tie goes to highest-ranked card") public void twoStraightFlushes() { String straightFlushTo8 = "4H 6H 7H 8H 5H"; String straightFlushTo9 = "5S 7S 8S 9S 6S"; @@ -334,6 +371,7 @@ public void twoStraightFlushes() { @Disabled("Remove to run test") @Test + @DisplayName("even though an ace is usually high, a 5-high straight flush is the lowest-scoring straight flush") public void straightFlushTo5IsTheLowestScoring() { String straightFlushTo6 = "2H 3H 4H 5H 6H"; String straightFlushTo5 = "4D AD 3D 2D 5D"; diff --git a/exercises/practice/pov/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/pov/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/pov/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/pov/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/pov/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/pov/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/pov/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/pov/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/pov/gradlew b/exercises/practice/pov/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/pov/gradlew +++ b/exercises/practice/pov/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/pov/gradlew.bat b/exercises/practice/pov/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/pov/gradlew.bat +++ b/exercises/practice/pov/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/prime-factors/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/prime-factors/gradlew b/exercises/practice/prime-factors/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/prime-factors/gradlew +++ b/exercises/practice/prime-factors/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/prime-factors/gradlew.bat b/exercises/practice/prime-factors/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/prime-factors/gradlew.bat +++ b/exercises/practice/prime-factors/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/prism/.docs/instructions.md b/exercises/practice/prism/.docs/instructions.md new file mode 100644 index 000000000..13cefae8c --- /dev/null +++ b/exercises/practice/prism/.docs/instructions.md @@ -0,0 +1,38 @@ +# Instructions + +Before activating the laser array, you must predict the exact order in which crystals will be hit, identified by their sample IDs. + +## Example Test Case + +Consider this crystal array configuration: + +```json +{ + "start": { "x": 0, "y": 0, "angle": 0 }, + "prisms": [ + { "id": 1, "x": 10, "y": 10, "angle": -90 }, + { "id": 2, "x": 10, "y": 0, "angle": 90 }, + { "id": 3, "x": 30, "y": 10, "angle": 45 }, + { "id": 4, "x": 20, "y": 0, "angle": 0 } + ] +} +``` + +## What's Happening + +The laser starts at the origin `(0, 0)` and fires horizontally to the right at angle 0°. +Here's the step-by-step beam path: + +**Step 1**: The beam travels along the x-axis (y = 0) and first encounters **Crystal #2** at position `(10, 0)`. +This crystal has a refraction angle of 90°, which means it bends the beam perpendicular to its current path. +The beam, originally traveling at 0°, is now redirected to 90° (straight up). + +**Step 2**: The beam now travels vertically upward from position `(10, 0)` and strikes **Crystal #1** at position `(10, 10)`. +This crystal has a refraction angle of -90°, bending the beam by -90° relative to its current direction. +The beam was traveling at 90°, so after refraction it's now at 0° (90° + (-90°) = 0°), traveling horizontally to the right again. + +**Step 3**: From position `(10, 10)`, the beam travels horizontally and encounters **Crystal #3** at position `(30, 10)`. +This crystal refracts the beam by 45°, changing its direction to 45°. +The beam continues into empty space beyond the array. + +!["A graph showing the path of a laser beam refracted through three prisms."](https://assets.exercism.org/images/exercises/prism/laser_path-light.svg) diff --git a/exercises/practice/prism/.docs/introduction.md b/exercises/practice/prism/.docs/introduction.md new file mode 100644 index 000000000..bfa7ed72e --- /dev/null +++ b/exercises/practice/prism/.docs/introduction.md @@ -0,0 +1,5 @@ +# Introduction + +You're a researcher at **PRISM** (Precariously Redirected Illumination Safety Management), working with a precision laser calibration system that tests experimental crystal prisms. +These crystals are being developed for next-generation optical computers, and each one has unique refractive properties based on its molecular structure. +The lab's laser system can damage crystals if they receive unexpected illumination, so precise path prediction is critical. diff --git a/exercises/practice/prism/.meta/config.json b/exercises/practice/prism/.meta/config.json new file mode 100644 index 000000000..1dd33d011 --- /dev/null +++ b/exercises/practice/prism/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "kahgoh" + ], + "files": { + "solution": [ + "src/main/java/Prism.java" + ], + "test": [ + "src/test/java/PrismTest.java" + ], + "example": [ + ".meta/src/reference/java/Prism.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Calculate the path of a laser through refractive prisms.", + "source": "FraSanga", + "source_url": "https://github.com/exercism/problem-specifications/pull/2625" +} diff --git a/exercises/practice/prism/.meta/src/reference/java/Prism.java b/exercises/practice/prism/.meta/src/reference/java/Prism.java new file mode 100644 index 000000000..5be2d192e --- /dev/null +++ b/exercises/practice/prism/.meta/src/reference/java/Prism.java @@ -0,0 +1,88 @@ +import java.util.*; +import java.util.function.Predicate; + +public class Prism { + + public record LaserInfo(double x, double y, double angle, Integer prismId) { + public LaserInfo(double x, double y, double angle) { + this(x, y, angle, null); + } + } + + public record PrismInfo(int id, double x, double y, double angle) { + } + + private static final int DECIMAL_PLACES = 3; + + private static final double ROUND_FACTOR = Math.pow(10, DECIMAL_PLACES); + + public static List findSequence(LaserInfo laser, List prisms) { + LaserInfo last = laser; + Optional lastPrism = Optional.empty(); + List sequence = new ArrayList<>(); + + do { + lastPrism = prisms.stream().filter(new TouchesPrism(last)).min(new CompareDistance(last)); + if (lastPrism.isPresent()) { + PrismInfo nextPrism = lastPrism.get(); + sequence.add(nextPrism.id); + last = new LaserInfo(nextPrism.x, nextPrism.y, + normalizeDegrees(nextPrism.angle + last.angle), nextPrism.id); + } + } while (lastPrism.isPresent()); + return sequence; + } + + private static double normalizeDegrees(double degrees) { + if (degrees < 0) { + return (degrees % 360) + 360; + } + return degrees % 360; + } + + private static class CompareDistance implements Comparator { + private final LaserInfo laser; + + public CompareDistance(LaserInfo laser) { + this.laser = laser; + } + + @Override + public int compare(PrismInfo o1, PrismInfo o2) { + final double d1 = Math.hypot(o1.x - laser.x, o1.y - laser.y); + final double d2 = Math.hypot(o2.x - laser.x, o2.y - laser.y); + return Double.compare(d1, d2); + } + } + + private static class TouchesPrism implements Predicate { + private final LaserInfo laser; + private final double sinAngle; + private final double cosAngle; + + public TouchesPrism(LaserInfo laser) { + this.laser = laser; + + double angleRadians = Math.toRadians(laser.angle); + this.sinAngle = Math.sin(angleRadians); + this.cosAngle = Math.cos(angleRadians); + } + + @Override + public boolean test(PrismInfo prism) { + if (laser.prismId != null && laser.prismId == prism.id) { + return false; + } + + double dx = prism.x - laser.x; + double dy = prism.y - laser.y; + double hyp = Math.hypot(dx, dy); + + return isClose(hyp * cosAngle, dx) && isClose(hyp * sinAngle, dy); + } + } + + private static boolean isClose(double a, double b) { + return Math.abs(Math.round(a * ROUND_FACTOR - b * ROUND_FACTOR)) <= 1; + } +} diff --git a/exercises/practice/prism/.meta/tests.toml b/exercises/practice/prism/.meta/tests.toml new file mode 100644 index 000000000..b00222383 --- /dev/null +++ b/exercises/practice/prism/.meta/tests.toml @@ -0,0 +1,52 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[ec65d3b3-f7bf-4015-8156-0609c141c4c4] +description = "zero prisms" + +[ec0ca17c-0c5f-44fb-89ba-b76395bdaf1c] +description = "one prism one hit" + +[0db955f2-0a27-4c82-ba67-197bd6202069] +description = "one prism zero hits" + +[8d92485b-ebc0-4ee9-9b88-cdddb16b52da] +description = "going up zero hits" + +[78295b3c-7438-492d-8010-9c63f5c223d7] +description = "going down zero hits" + +[acc723ea-597b-4a50-8d1b-b980fe867d4c] +description = "going left zero hits" + +[3f19b9df-9eaa-4f18-a2db-76132f466d17] +description = "negative angle" + +[96dacffb-d821-4cdf-aed8-f152ce063195] +description = "large angle" + +[513a7caa-957f-4c5d-9820-076842de113c] +description = "upward refraction two hits" + +[d452b7c7-9761-4ea9-81a9-2de1d73eb9ef] +description = "downward refraction two hits" + +[be1a2167-bf4c-4834-acc9-e4d68e1a0203] +description = "same prism twice" + +[df5a60dd-7c7d-4937-ac4f-c832dae79e2e] +description = "simple path" + +[8d9a3cc8-e846-4a3b-a137-4bfc4aa70bd1] +description = "multiple prisms floating point precision" + +[e077fc91-4e4a-46b3-a0f5-0ba00321da56] +description = "complex path with multiple prisms floating point precision" diff --git a/exercises/practice/prism/build.gradle b/exercises/practice/prism/build.gradle new file mode 100644 index 000000000..d28f35dee --- /dev/null +++ b/exercises/practice/prism/build.gradle @@ -0,0 +1,25 @@ +plugins { + id "java" +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation platform("org.junit:junit-bom:5.10.0") + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "org.assertj:assertj-core:3.25.1" + + testRuntimeOnly "org.junit.platform:junit-platform-launcher" +} + +test { + useJUnitPlatform() + + testLogging { + exceptionFormat = "full" + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/exercises/practice/prism/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/prism/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..b1b8ef56b Binary files /dev/null and b/exercises/practice/prism/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/prism/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/prism/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..6394b4647 --- /dev/null +++ b/exercises/practice/prism/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/exercises/practice/prism/gradlew b/exercises/practice/prism/gradlew new file mode 100755 index 000000000..b9bb139f7 --- /dev/null +++ b/exercises/practice/prism/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/exercises/practice/prism/gradlew.bat b/exercises/practice/prism/gradlew.bat new file mode 100644 index 000000000..24c62d56f --- /dev/null +++ b/exercises/practice/prism/gradlew.bat @@ -0,0 +1,82 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/prism/src/main/java/Prism.java b/exercises/practice/prism/src/main/java/Prism.java new file mode 100644 index 000000000..b02fe3fae --- /dev/null +++ b/exercises/practice/prism/src/main/java/Prism.java @@ -0,0 +1,15 @@ +import java.util.*; +import java.util.function.Predicate; + +public class Prism { + + public record LaserInfo(double x, double y, double angle) { + } + + public record PrismInfo(int id, double x, double y, double angle) { + } + + public static List findSequence(LaserInfo laser, List prisms) { + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); + } +} \ No newline at end of file diff --git a/exercises/practice/prism/src/test/java/PrismTest.java b/exercises/practice/prism/src/test/java/PrismTest.java new file mode 100644 index 000000000..a4637c1bc --- /dev/null +++ b/exercises/practice/prism/src/test/java/PrismTest.java @@ -0,0 +1,303 @@ +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PrismTest { + @Test + @DisplayName("zero prisms") + public void testZeroPrisms() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + + assertThat(Prism.findSequence(laser, List.of())).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("one prism one hit") + public void testOnePrismOneHit() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of(new Prism.PrismInfo(1, 10, 0, 0)); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly(1); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("one prism hits zero") + public void testOnePrismHitsZero() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of(new Prism.PrismInfo(1, -10, 0, 0)); + + assertThat(Prism.findSequence(laser, prisms)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("going up zero hits") + public void testGoingUpZeroHits() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 90); + final List prisms = List.of( + new Prism.PrismInfo(3, 0, -10, 0), + new Prism.PrismInfo(1, -10, 0, 0), + new Prism.PrismInfo(2, 10, 0, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("going down zero hits") + public void testGoingDownZeroHits() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, -90); + final List prisms = List.of( + new Prism.PrismInfo(1, 10, 0, 0), + new Prism.PrismInfo(2, 0, 10, 0), + new Prism.PrismInfo(3, -10, 0, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("going left zero hits") + public void testGoingLeftZeroHits() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 180); + final List prisms = List.of( + new Prism.PrismInfo(2, 0, 10, 0), + new Prism.PrismInfo(3, 10, 0, 0), + new Prism.PrismInfo(1, 0, -10, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("negative angle") + public void testNegativeAngle() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, -180); + final List prisms = List.of( + new Prism.PrismInfo(1, 0, -10, 0), + new Prism.PrismInfo(2, 0, 10, 0), + new Prism.PrismInfo(3, 10, 0, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("large angle") + public void testLargeAngle() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 2340); + final List prisms = List.of( + new Prism.PrismInfo(1, 10, 0, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("upward reflection two hits") + public void testUpwardReflectionTwoHits() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of( + new Prism.PrismInfo(1, 10, 10, 0), + new Prism.PrismInfo(2, 10, 0, 90) + ); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly(2, 1); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("downward reflection two hits") + public void testDownwardReflectionTwoHits() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of( + new Prism.PrismInfo(1, 10, 0, -90), + new Prism.PrismInfo(2, 10, -10, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly(1, 2); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("same prism twice") + public void testSamePrismTwice() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of( + new Prism.PrismInfo(2, 10, 0, 0), + new Prism.PrismInfo(1, 20, 0, -180) + ); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly(2, 1, 2); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("simple path") + public void testSimplePath() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of( + new Prism.PrismInfo(3, 30, 10, 45), + new Prism.PrismInfo(1, 10, 10, -90), + new Prism.PrismInfo(2, 10, 0, 90), + new Prism.PrismInfo(4, 20, 0, 0) + ); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly(2, 1, 3); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("multiple prisms floating point precision") + public void testMultiplePrismFloatingPointPrecision() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, -6.429); + final List prisms = List.of( + new Prism.PrismInfo(26, 5.8, 73.4, 6.555), + new Prism.PrismInfo(24, 36.2, 65.2, -0.304), + new Prism.PrismInfo(20, 20.4, 82.8, 45.17), + new Prism.PrismInfo(31, -20.2, 48.8, 30.615), + new Prism.PrismInfo(30, 24.0, 0.6, 28.771), + new Prism.PrismInfo(29, 31.4, 79.4, 61.327), + new Prism.PrismInfo(28, 36.4, 31.4, -18.157), + new Prism.PrismInfo(22, 47.0, 57.8, 54.745), + new Prism.PrismInfo(38, 36.4, 79.2, 49.05), + new Prism.PrismInfo(10, 37.8, 55.2, 11.978), + new Prism.PrismInfo(18, -26.0, 42.6, 22.661), + new Prism.PrismInfo(25, 38.8, 76.2, 51.958), + new Prism.PrismInfo(2, 0.0, 42.4, -21.817), + new Prism.PrismInfo(35, 21.4, 44.8, -171.579), + new Prism.PrismInfo(7, 14.2, -1.6, 19.081), + new Prism.PrismInfo(33, 11.2, 44.4, -165.941), + new Prism.PrismInfo(11, 15.4, 82.6, 66.262), + new Prism.PrismInfo(16, 30.8, 6.6, 35.852), + new Prism.PrismInfo(15, -3.0, 79.2, 53.782), + new Prism.PrismInfo(4, 29.0, 75.4, 17.016), + new Prism.PrismInfo(23, 41.6, 59.8, 70.763), + new Prism.PrismInfo(8, -10.0, 15.8, -9.24), + new Prism.PrismInfo(13, 48.6, 51.8, 45.812), + new Prism.PrismInfo(1, 13.2, 77.0, 17.937), + new Prism.PrismInfo(34, -8.8, 36.8, -4.199), + new Prism.PrismInfo(21, 24.4, 75.8, 20.783), + new Prism.PrismInfo(17, -4.4, 74.6, 24.709), + new Prism.PrismInfo(9, 30.8, 41.8, -165.413), + new Prism.PrismInfo(32, 4.2, 78.6, 40.892), + new Prism.PrismInfo(37, -15.8, 47.0, 33.29), + new Prism.PrismInfo(6, 1.0, 80.6, 51.295), + new Prism.PrismInfo(36, -27.0, 47.8, 92.52), + new Prism.PrismInfo(14, -2.0, 34.4, -52.001), + new Prism.PrismInfo(5, 23.2, 80.2, 31.866), + new Prism.PrismInfo(27, -5.6, 32.8, -75.303), + new Prism.PrismInfo(12, -1.0, 0.2, 0.0), + new Prism.PrismInfo(3, -6.6, 3.2, 46.72), + new Prism.PrismInfo(19, -13.8, 24.2, -9.205) + ); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly( + 7, 30, 16, 28, 13, 22, 23, 10, 9, 24, 25, 38, 29, 4, 35, 21, 5, 20, + 11, 1, 33, 26, 32, 6, 15, 17, 2, 14, 27, 34, 37, 31, 36, 18, 19, 8, 3, 12); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("complex path with multiple prisms floating point precision") + public void testComplexPathWithMultiplePrismFloatingPointPrecision() { + final Prism.LaserInfo laser = new Prism.LaserInfo(0, 0, 0); + final List prisms = List.of( + new Prism.PrismInfo(46, 37.4, 20.6, -88.332), + new Prism.PrismInfo(72, -24.2, 23.4, -90.774), + new Prism.PrismInfo(25, 78.6, 7.8, 98.562), + new Prism.PrismInfo(60, -58.8, 31.6, 115.56), + new Prism.PrismInfo(22, 75.2, 28.0, 63.515), + new Prism.PrismInfo(2, 89.8, 27.8, 91.176), + new Prism.PrismInfo(23, 9.8, 30.8, 30.829), + new Prism.PrismInfo(69, 22.8, 20.6, -88.315), + new Prism.PrismInfo(44, -0.8, 15.6, -116.565), + new Prism.PrismInfo(36, -24.2, 8.2, -90.0), + new Prism.PrismInfo(53, -1.2, 0.0, 0.0), + new Prism.PrismInfo(52, 14.2, 24.0, -143.896), + new Prism.PrismInfo(5, -65.2, 21.6, 93.128), + new Prism.PrismInfo(66, 5.4, 15.6, 31.608), + new Prism.PrismInfo(51, -72.6, 21.0, -100.976), + new Prism.PrismInfo(65, 48.0, 10.2, 87.455), + new Prism.PrismInfo(21, -41.8, 0.0, 68.352), + new Prism.PrismInfo(18, -46.2, 19.2, -128.362), + new Prism.PrismInfo(10, 74.4, 0.4, 90.939), + new Prism.PrismInfo(15, 67.6, 0.4, 84.958), + new Prism.PrismInfo(35, 14.8, -0.4, 89.176), + new Prism.PrismInfo(1, 83.0, 0.2, 89.105), + new Prism.PrismInfo(68, 14.6, 28.0, -29.867), + new Prism.PrismInfo(67, 79.8, 18.6, -136.643), + new Prism.PrismInfo(38, 53.0, 14.6, -90.848), + new Prism.PrismInfo(31, -58.0, 6.6, -61.837), + new Prism.PrismInfo(74, -30.8, 0.4, 85.966), + new Prism.PrismInfo(48, -4.6, 10.0, -161.222), + new Prism.PrismInfo(12, 59.0, 5.0, -91.164), + new Prism.PrismInfo(33, -16.4, 18.4, 90.734), + new Prism.PrismInfo(4, 82.6, 27.6, 71.127), + new Prism.PrismInfo(75, -10.2, 30.6, -1.108), + new Prism.PrismInfo(28, 38.0, 0.0, 86.863), + new Prism.PrismInfo(11, 64.4, -0.2, 92.353), + new Prism.PrismInfo(9, -51.4, 31.6, 67.249), + new Prism.PrismInfo(26, -39.8, 30.8, 61.113), + new Prism.PrismInfo(30, -34.2, 0.6, 111.33), + new Prism.PrismInfo(56, -51.0, 0.2, 70.445), + new Prism.PrismInfo(41, -12.0, 0.0, 91.219), + new Prism.PrismInfo(24, 63.8, 14.4, 86.586), + new Prism.PrismInfo(70, -72.8, 13.4, -87.238), + new Prism.PrismInfo(3, 22.4, 7.0, -91.685), + new Prism.PrismInfo(13, 34.4, 7.0, 90.0), + new Prism.PrismInfo(16, -47.4, 11.4, -136.02), + new Prism.PrismInfo(6, 90.0, 0.2, 90.415), + new Prism.PrismInfo(54, 44.0, 27.8, 85.969), + new Prism.PrismInfo(32, -9.0, 0.0, 91.615), + new Prism.PrismInfo(8, -31.6, 30.8, 0.535), + new Prism.PrismInfo(39, -12.0, 8.2, 90.0), + new Prism.PrismInfo(14, -79.6, 32.4, 92.342), + new Prism.PrismInfo(42, 65.8, 20.8, -85.867), + new Prism.PrismInfo(40, -65.0, 14.0, 87.109), + new Prism.PrismInfo(45, 10.6, 18.8, 23.697), + new Prism.PrismInfo(71, -24.2, 18.6, -88.531), + new Prism.PrismInfo(7, -72.6, 6.4, -89.148), + new Prism.PrismInfo(62, -32.0, 24.8, -140.8), + new Prism.PrismInfo(49, 34.4, -0.2, 89.415), + new Prism.PrismInfo(63, 74.2, 12.6, -138.429), + new Prism.PrismInfo(59, 82.8, 13.0, -140.177), + new Prism.PrismInfo(34, -9.4, 23.2, -88.238), + new Prism.PrismInfo(76, -57.6, 0.0, 1.2), + new Prism.PrismInfo(43, 7.0, 0.0, 116.565), + new Prism.PrismInfo(20, 45.8, -0.2, 1.469), + new Prism.PrismInfo(37, -16.6, 13.2, 84.785), + new Prism.PrismInfo(58, -79.0, -0.2, 89.481), + new Prism.PrismInfo(50, -24.2, 12.8, -86.987), + new Prism.PrismInfo(64, 59.2, 10.2, -92.203), + new Prism.PrismInfo(61, -72.0, 26.4, -83.66), + new Prism.PrismInfo(47, 45.4, 5.8, -82.992), + new Prism.PrismInfo(17, -52.2, 17.8, -52.938), + new Prism.PrismInfo(57, -61.8, 32.0, 84.627), + new Prism.PrismInfo(29, 47.2, 28.2, 92.954), + new Prism.PrismInfo(27, -4.6, 0.2, 87.397), + new Prism.PrismInfo(55, -61.4, 26.4, 94.086), + new Prism.PrismInfo(73, -40.4, 13.4, -62.229), + new Prism.PrismInfo(19, 53.2, 20.6, -87.181) + ); + + assertThat(Prism.findSequence(laser, prisms)).containsExactly( + 43, 44, 66, 45, 52, 35, 49, 13, 3, 69, 46, 28, 20, 11, 24, 38, 19, 42, + 15, 10, 63, 25, 59, 1, 6, 2, 4, 67, 22, 29, 65, 64, 12, 47, 54, 68, + 23, 75, 8, 26, 18, 9, 60, 17, 31, 7, 70, 40, 5, 51, 61, 55, 57, 14, + 58, 76, 56, 16, 21, 30, 73, 62, 74, 41, 39, 36, 50, 37, 33, 71, 72, + 34, 32, 27, 48, 53 + ); + } +} diff --git a/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/protein-translation/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/protein-translation/gradlew b/exercises/practice/protein-translation/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/protein-translation/gradlew +++ b/exercises/practice/protein-translation/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/protein-translation/gradlew.bat b/exercises/practice/protein-translation/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/protein-translation/gradlew.bat +++ b/exercises/practice/protein-translation/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/proverb/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/proverb/gradlew b/exercises/practice/proverb/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/proverb/gradlew +++ b/exercises/practice/proverb/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/proverb/gradlew.bat b/exercises/practice/proverb/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/proverb/gradlew.bat +++ b/exercises/practice/proverb/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/pythagorean-triplet/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/pythagorean-triplet/gradlew b/exercises/practice/pythagorean-triplet/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/pythagorean-triplet/gradlew +++ b/exercises/practice/pythagorean-triplet/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/pythagorean-triplet/gradlew.bat b/exercises/practice/pythagorean-triplet/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/pythagorean-triplet/gradlew.bat +++ b/exercises/practice/pythagorean-triplet/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/queen-attack/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/queen-attack/gradlew b/exercises/practice/queen-attack/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/queen-attack/gradlew +++ b/exercises/practice/queen-attack/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/queen-attack/gradlew.bat b/exercises/practice/queen-attack/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/queen-attack/gradlew.bat +++ b/exercises/practice/queen-attack/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rail-fence-cipher/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rail-fence-cipher/gradlew b/exercises/practice/rail-fence-cipher/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/rail-fence-cipher/gradlew +++ b/exercises/practice/rail-fence-cipher/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rail-fence-cipher/gradlew.bat b/exercises/practice/rail-fence-cipher/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/rail-fence-cipher/gradlew.bat +++ b/exercises/practice/rail-fence-cipher/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/raindrops/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/raindrops/gradlew b/exercises/practice/raindrops/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/raindrops/gradlew +++ b/exercises/practice/raindrops/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/raindrops/gradlew.bat b/exercises/practice/raindrops/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/raindrops/gradlew.bat +++ b/exercises/practice/raindrops/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rate-limiter/.meta/config.json b/exercises/practice/rate-limiter/.meta/config.json index 0f7b8ebea..252db1567 100644 --- a/exercises/practice/rate-limiter/.meta/config.json +++ b/exercises/practice/rate-limiter/.meta/config.json @@ -15,6 +15,9 @@ ], "editor": [ "src/main/java/TimeSource.java" + ], + "invalidator": [ + "build.gradle" ] }, "blurb": "Practice stateful logic and time handling by implementing a fixed-window rate limiter" diff --git a/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..6394b4647 100644 --- a/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rate-limiter/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rate-limiter/gradlew b/exercises/practice/rate-limiter/gradlew old mode 100644 new mode 100755 index 1aa94a426..b9bb139f7 --- a/exercises/practice/rate-limiter/gradlew +++ b/exercises/practice/rate-limiter/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rate-limiter/gradlew.bat b/exercises/practice/rate-limiter/gradlew.bat index 93e3f59f1..24c62d56f 100644 --- a/exercises/practice/rate-limiter/gradlew.bat +++ b/exercises/practice/rate-limiter/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -43,13 +45,13 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -57,36 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rational-numbers/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rational-numbers/gradlew b/exercises/practice/rational-numbers/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/rational-numbers/gradlew +++ b/exercises/practice/rational-numbers/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rational-numbers/gradlew.bat b/exercises/practice/rational-numbers/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/rational-numbers/gradlew.bat +++ b/exercises/practice/rational-numbers/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/react/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/react/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/react/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/react/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/react/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/react/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/react/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/react/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/react/gradlew b/exercises/practice/react/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/react/gradlew +++ b/exercises/practice/react/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/react/gradlew.bat b/exercises/practice/react/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/react/gradlew.bat +++ b/exercises/practice/react/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rectangles/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rectangles/gradlew b/exercises/practice/rectangles/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/rectangles/gradlew +++ b/exercises/practice/rectangles/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rectangles/gradlew.bat b/exercises/practice/rectangles/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/rectangles/gradlew.bat +++ b/exercises/practice/rectangles/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/relative-distance/.docs/instructions.md b/exercises/practice/relative-distance/.docs/instructions.md index 9046aee7c..64ca4e437 100644 --- a/exercises/practice/relative-distance/.docs/instructions.md +++ b/exercises/practice/relative-distance/.docs/instructions.md @@ -36,4 +36,4 @@ Isla and Tariq are siblings and have a separation of 1. Similarly, this implementation would report a separation of 2 from you to your father's brother. ~~~~ -[six-bacons]: https://en.m.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon +[six-bacons]: https://en.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon diff --git a/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/relative-distance/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/relative-distance/gradlew b/exercises/practice/relative-distance/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/relative-distance/gradlew +++ b/exercises/practice/relative-distance/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/relative-distance/gradlew.bat b/exercises/practice/relative-distance/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/relative-distance/gradlew.bat +++ b/exercises/practice/relative-distance/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/resistor-color-duo/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/resistor-color-duo/gradlew b/exercises/practice/resistor-color-duo/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/resistor-color-duo/gradlew +++ b/exercises/practice/resistor-color-duo/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/resistor-color-duo/gradlew.bat b/exercises/practice/resistor-color-duo/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/resistor-color-duo/gradlew.bat +++ b/exercises/practice/resistor-color-duo/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/resistor-color-trio/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/resistor-color-trio/gradlew b/exercises/practice/resistor-color-trio/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/resistor-color-trio/gradlew +++ b/exercises/practice/resistor-color-trio/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/resistor-color-trio/gradlew.bat b/exercises/practice/resistor-color-trio/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/resistor-color-trio/gradlew.bat +++ b/exercises/practice/resistor-color-trio/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/resistor-color/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/resistor-color/gradlew b/exercises/practice/resistor-color/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/resistor-color/gradlew +++ b/exercises/practice/resistor-color/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/resistor-color/gradlew.bat b/exercises/practice/resistor-color/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/resistor-color/gradlew.bat +++ b/exercises/practice/resistor-color/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rest-api/.docs/instructions.md b/exercises/practice/rest-api/.docs/instructions.md index af223ba4b..e889b1bf2 100644 --- a/exercises/practice/rest-api/.docs/instructions.md +++ b/exercises/practice/rest-api/.docs/instructions.md @@ -43,6 +43,6 @@ Your task is to implement a simple [RESTful API][restful-wikipedia] that receive [restful-wikipedia]: https://en.wikipedia.org/wiki/Representational_state_transfer [iou]: https://en.wikipedia.org/wiki/IOU -[github-rest]: https://developer.github.com/v3/ +[github-rest]: https://docs.github.com/en/rest [reddit-rest]: https://web.archive.org/web/20231202231149/https://www.reddit.com/dev/api/ [restfulapi]: https://restfulapi.net/ diff --git a/exercises/practice/rest-api/build.gradle b/exercises/practice/rest-api/build.gradle index 7b2a81d33..b5866449e 100644 --- a/exercises/practice/rest-api/build.gradle +++ b/exercises/practice/rest-api/build.gradle @@ -12,6 +12,8 @@ dependencies { testImplementation platform("org.junit:junit-bom:5.10.0") testImplementation "org.junit.jupiter:junit-jupiter" testImplementation "org.assertj:assertj-core:3.25.1" + + testRuntimeOnly "org.junit.platform:junit-platform-launcher" } test { diff --git a/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rest-api/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rest-api/gradlew b/exercises/practice/rest-api/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/rest-api/gradlew +++ b/exercises/practice/rest-api/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rest-api/gradlew.bat b/exercises/practice/rest-api/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/rest-api/gradlew.bat +++ b/exercises/practice/rest-api/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/reverse-string/.meta/config.json b/exercises/practice/reverse-string/.meta/config.json index 5d9b73de9..f4b2d6712 100644 --- a/exercises/practice/reverse-string/.meta/config.json +++ b/exercises/practice/reverse-string/.meta/config.json @@ -36,5 +36,5 @@ }, "blurb": "Reverse a given string.", "source": "Introductory challenge to reverse an input string", - "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" + "source_url": "https://www.freecodecamp.org/news/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" } diff --git a/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/reverse-string/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/reverse-string/gradlew b/exercises/practice/reverse-string/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/reverse-string/gradlew +++ b/exercises/practice/reverse-string/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/reverse-string/gradlew.bat b/exercises/practice/reverse-string/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/reverse-string/gradlew.bat +++ b/exercises/practice/reverse-string/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rna-transcription/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rna-transcription/gradlew b/exercises/practice/rna-transcription/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/rna-transcription/gradlew +++ b/exercises/practice/rna-transcription/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rna-transcription/gradlew.bat b/exercises/practice/rna-transcription/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/rna-transcription/gradlew.bat +++ b/exercises/practice/rna-transcription/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/robot-name/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/robot-name/gradlew b/exercises/practice/robot-name/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/robot-name/gradlew +++ b/exercises/practice/robot-name/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/robot-name/gradlew.bat b/exercises/practice/robot-name/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/robot-name/gradlew.bat +++ b/exercises/practice/robot-name/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/robot-name/src/test/java/RobotTest.java b/exercises/practice/robot-name/src/test/java/RobotTest.java index 6c19ae877..542d4a586 100644 --- a/exercises/practice/robot-name/src/test/java/RobotTest.java +++ b/exercises/practice/robot-name/src/test/java/RobotTest.java @@ -1,11 +1,12 @@ -import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import java.util.HashSet; import java.util.Set; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; public class RobotTest { @@ -18,24 +19,28 @@ public void setUp() { } @Test + @DisplayName("Robot has a valid name") public void hasName() { assertIsValidName(robot.getName()); } @Test @Disabled("Remove to run test") + @DisplayName("Same robot returns the same name on repeated calls") public void sameRobotsHaveSameNames() { assertThat(robot.getName()).isEqualTo(robot.getName()); } @Disabled("Remove to run test") @Test + @DisplayName("Different robots have different names") public void differentRobotsHaveDifferentNames() { assertThat(robot.getName()).isNotEqualTo(new Robot().getName()); } @Disabled("Remove to run test") @Test + @DisplayName("Resetting a robot assigns a new valid name") public void resetName() { final String name = robot.getName(); robot.reset(); @@ -46,6 +51,7 @@ public void resetName() { @Disabled("Remove to run test") @Test + @DisplayName("Robot names are unique") public void robotNamesAreUnique() { Set robotNames = new HashSet<>(); int sampleSize = 5000; diff --git a/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/robot-simulator/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/robot-simulator/gradlew b/exercises/practice/robot-simulator/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/robot-simulator/gradlew +++ b/exercises/practice/robot-simulator/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/robot-simulator/gradlew.bat b/exercises/practice/robot-simulator/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/robot-simulator/gradlew.bat +++ b/exercises/practice/robot-simulator/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/roman-numerals/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/roman-numerals/gradlew b/exercises/practice/roman-numerals/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/roman-numerals/gradlew +++ b/exercises/practice/roman-numerals/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/roman-numerals/gradlew.bat b/exercises/practice/roman-numerals/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/roman-numerals/gradlew.bat +++ b/exercises/practice/roman-numerals/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/rotational-cipher/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/rotational-cipher/gradlew b/exercises/practice/rotational-cipher/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/rotational-cipher/gradlew +++ b/exercises/practice/rotational-cipher/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/rotational-cipher/gradlew.bat b/exercises/practice/rotational-cipher/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/rotational-cipher/gradlew.bat +++ b/exercises/practice/rotational-cipher/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/run-length-encoding/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/run-length-encoding/gradlew b/exercises/practice/run-length-encoding/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/run-length-encoding/gradlew +++ b/exercises/practice/run-length-encoding/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/run-length-encoding/gradlew.bat b/exercises/practice/run-length-encoding/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/run-length-encoding/gradlew.bat +++ b/exercises/practice/run-length-encoding/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/saddle-points/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/saddle-points/gradlew b/exercises/practice/saddle-points/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/saddle-points/gradlew +++ b/exercises/practice/saddle-points/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/saddle-points/gradlew.bat b/exercises/practice/saddle-points/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/saddle-points/gradlew.bat +++ b/exercises/practice/saddle-points/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/saddle-points/src/test/java/MatrixTest.java b/exercises/practice/saddle-points/src/test/java/MatrixTest.java index 6bcb5afcb..56b5087fc 100644 --- a/exercises/practice/saddle-points/src/test/java/MatrixTest.java +++ b/exercises/practice/saddle-points/src/test/java/MatrixTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -12,6 +13,7 @@ public class MatrixTest { @Test + @DisplayName("Can identify single saddle point") public void testCanIdentifySingleSaddlePoint() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(9, 8, 7), @@ -26,6 +28,7 @@ public void testCanIdentifySingleSaddlePoint() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify that empty matrix has no saddle points") public void testCanIdentifyThatEmptyMatrixHasNoSaddlePoints() { Matrix matrix = new Matrix(new ArrayList<>()); @@ -36,6 +39,7 @@ public void testCanIdentifyThatEmptyMatrixHasNoSaddlePoints() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify lack of saddle points when there are none") public void testCanIdentifyLackOfSaddlePointsWhenThereAreNone() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(1, 2, 3), @@ -50,6 +54,7 @@ public void testCanIdentifyLackOfSaddlePointsWhenThereAreNone() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify multiple saddle points in a column") public void testCanIdentifyMultipleSaddlePointsInAColumn() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(4, 5, 4), @@ -68,6 +73,7 @@ public void testCanIdentifyMultipleSaddlePointsInAColumn() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify multiple saddle points in a Row") public void testCanIdentifyMultipleSaddlePointsInARow() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(6, 7, 8), @@ -86,6 +92,7 @@ public void testCanIdentifyMultipleSaddlePointsInARow() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify saddle point in bottom right corner") public void testCanIdentifySaddlePointInBottomRightCorner() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(8, 7, 9), @@ -100,6 +107,7 @@ public void testCanIdentifySaddlePointInBottomRightCorner() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify saddle points in a non square matrix") public void testCanIdentifySaddlePointsInANonSquareMatrix() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(3, 1, 3), @@ -116,6 +124,7 @@ public void testCanIdentifySaddlePointsInANonSquareMatrix() { @Disabled("Remove to run test") @Test + @DisplayName("Can identify that saddle points in a single column matrix are those with the minimum value") public void testCanIdentifyThatSaddlePointsInASingleColumnMatrixAreThoseWithMinimumValue() { Matrix matrix = new Matrix(Arrays.asList( Collections.singletonList(2), @@ -134,6 +143,7 @@ public void testCanIdentifyThatSaddlePointsInASingleColumnMatrixAreThoseWithMini @Disabled("Remove to run test") @Test + @DisplayName("Can identify that saddle points in a single row matrix are those with the maximum value") public void testCanIdentifyThatSaddlePointsInASingleRowMatrixAreThoseWithMaximumValue() { Matrix matrix = new Matrix(Arrays.asList( Arrays.asList(2, 5, 3, 5) diff --git a/exercises/practice/satellite/.meta/tests.toml b/exercises/practice/satellite/.meta/tests.toml index 8314daa43..d0ed5b6ac 100644 --- a/exercises/practice/satellite/.meta/tests.toml +++ b/exercises/practice/satellite/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [8df3fa26-811a-4165-9286-ff9ac0850d19] description = "Empty tree" @@ -19,3 +26,12 @@ description = "Reject inconsistent traversals of same length" [d86a3d72-76a9-43b5-9d3a-e64cb1216035] description = "Reject traversals with repeated items" + +[af31ae02-7e5b-4452-a990-bccb3fca9148] +description = "A degenerate binary tree" + +[ee54463d-a719-4aae-ade4-190d30ce7320] +description = "Another degenerate binary tree" + +[87123c08-c155-4486-90a4-e2f75b0f3e8f] +description = "Tree with many more items" diff --git a/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/satellite/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/satellite/gradlew b/exercises/practice/satellite/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/satellite/gradlew +++ b/exercises/practice/satellite/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/satellite/gradlew.bat b/exercises/practice/satellite/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/satellite/gradlew.bat +++ b/exercises/practice/satellite/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/satellite/src/test/java/SatelliteTest.java b/exercises/practice/satellite/src/test/java/SatelliteTest.java index 52bd9e97c..a97672643 100644 --- a/exercises/practice/satellite/src/test/java/SatelliteTest.java +++ b/exercises/practice/satellite/src/test/java/SatelliteTest.java @@ -2,13 +2,16 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import java.util.List; + import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; public class SatelliteTest { Satellite satellite = new Satellite(); @Test + @DisplayName("Empty tree") public void emptyTree() { List preorder = List.of(); List inorder = List.of(); @@ -22,6 +25,7 @@ public void emptyTree() { @Disabled("Remove to run test") @Test + @DisplayName("Tree with one item") public void treeWithOneItem() { List preorder = List.of('a'); List inorder = List.of('a'); @@ -35,6 +39,7 @@ public void treeWithOneItem() { @Disabled("Remove to run test") @Test + @DisplayName("Tree with many items") public void treeWithManyItems() { List preorder = List.of('a', 'i', 'x', 'f', 'r'); List inorder = List.of('i', 'a', 'f', 'x', 'r'); @@ -48,6 +53,7 @@ public void treeWithManyItems() { @Disabled("Remove to run test") @Test + @DisplayName("Reject traversals of different length") public void rejectTraversalsOfDifferentLengths() { List preorder = List.of('a', 'b'); List inorder = List.of('b', 'a', 'r'); @@ -60,6 +66,7 @@ public void rejectTraversalsOfDifferentLengths() { @Disabled("Remove to run test") @Test + @DisplayName("Reject inconsistent traversals of same length") public void rejectInconsistentTraversalsOfSameLength() { List preorder = List.of('x', 'y', 'z'); List inorder = List.of('a', 'b', 'c'); @@ -71,6 +78,7 @@ public void rejectInconsistentTraversalsOfSameLength() { @Disabled("Remove to run test") @Test + @DisplayName("Reject traversals with repeated items") public void rejectTraversalsWithRepeatedItems() { List preorder = List.of('a', 'b', 'a'); List inorder = List.of('b', 'a', 'a'); @@ -79,4 +87,46 @@ public void rejectTraversalsWithRepeatedItems() { .isThrownBy(() -> satellite.treeFromTraversals(preorder, inorder)) .withMessage("traversals must contain unique items"); } + + @Disabled("Remove to run test") + @Test + @DisplayName("A degenerate binary tree") + public void degenerateBinaryTree() { + List preorder = List.of('a', 'b', 'c', 'd'); + List inorder = List.of('d', 'c', 'b', 'a'); + + Tree tree = satellite.treeFromTraversals(preorder, inorder); + + assertThat(tree.preorder()).containsExactlyElementsOf(preorder); + assertThat(tree.inorder()).containsExactlyElementsOf(inorder); + assertThat(tree.postorder()).containsExactly('d', 'c', 'b', 'a'); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Another degenerate binary tree") + public void anotherDegenerateBinaryTree() { + List preorder = List.of('a', 'b', 'c', 'd'); + List inorder = List.of('a', 'b', 'c', 'd'); + + Tree tree = satellite.treeFromTraversals(preorder, inorder); + + assertThat(tree.preorder()).containsExactlyElementsOf(preorder); + assertThat(tree.inorder()).containsExactlyElementsOf(inorder); + assertThat(tree.postorder()).containsExactly('d', 'c', 'b', 'a'); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Tree with many more items") + public void treeWithManyMoreItems() { + List preorder = List.of('a', 'b', 'd', 'g', 'h', 'c', 'e', 'f', 'i'); + List inorder = List.of('g', 'd', 'h', 'b', 'a', 'e', 'c', 'i', 'f'); + + Tree tree = satellite.treeFromTraversals(preorder, inorder); + + assertThat(tree.preorder()).containsExactlyElementsOf(preorder); + assertThat(tree.inorder()).containsExactlyElementsOf(inorder); + assertThat(tree.postorder()).containsExactly('g', 'h', 'd', 'b', 'e', 'i', 'f', 'c', 'a'); + } } diff --git a/exercises/practice/say/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/say/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/say/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/say/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/say/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/say/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/say/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/say/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/say/gradlew b/exercises/practice/say/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/say/gradlew +++ b/exercises/practice/say/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/say/gradlew.bat b/exercises/practice/say/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/say/gradlew.bat +++ b/exercises/practice/say/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/say/src/test/java/SayTest.java b/exercises/practice/say/src/test/java/SayTest.java index 9e7090d53..2a999c517 100644 --- a/exercises/practice/say/src/test/java/SayTest.java +++ b/exercises/practice/say/src/test/java/SayTest.java @@ -1,5 +1,6 @@ -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; @@ -8,102 +9,119 @@ public class SayTest { private Say say = new Say(); @Test + @DisplayName("zero") public void zero() { assertThat(say.say(0)).isEqualTo("zero"); } @Disabled("Remove to run test") @Test + @DisplayName("one") public void one() { assertThat(say.say(1)).isEqualTo("one"); } @Disabled("Remove to run test") @Test + @DisplayName("fourteen") public void fourteen() { assertThat(say.say(14)).isEqualTo("fourteen"); } @Disabled("Remove to run test") @Test + @DisplayName("twenty") public void twenty() { assertThat(say.say(20)).isEqualTo("twenty"); } @Disabled("Remove to run test") @Test + @DisplayName("twenty-two") public void twentyTwo() { assertThat(say.say(22)).isEqualTo("twenty-two"); } @Disabled("Remove to run test") @Test + @DisplayName("thirty") public void thirty() { assertThat(say.say(30)).isEqualTo("thirty"); } @Disabled("Remove to run test") @Test + @DisplayName("ninety-nine") public void ninetyNine() { assertThat(say.say(99)).isEqualTo("ninety-nine"); } @Disabled("Remove to run test") @Test + @DisplayName("one hundred") public void oneHundred() { assertThat(say.say(100)).isEqualTo("one hundred"); } @Disabled("Remove to run test") @Test + @DisplayName("one hundred twenty-three") public void oneHundredTwentyThree() { assertThat(say.say(123)).isEqualTo("one hundred twenty-three"); } @Disabled("Remove to run test") @Test + @DisplayName("two hundred") public void twoHundred() { assertThat(say.say(200)).isEqualTo("two hundred"); } @Disabled("Remove to run test") @Test + @DisplayName("nine hundred ninety-nine") public void nineHundredNinetyNine() { assertThat(say.say(999)).isEqualTo("nine hundred ninety-nine"); } @Disabled("Remove to run test") @Test + @DisplayName("one thousand") public void oneThousand() { assertThat(say.say(1_000)).isEqualTo("one thousand"); } @Disabled("Remove to run test") @Test + @DisplayName("one thousand two hundred thirty-four") public void oneThousandTwoHundredThirtyFour() { assertThat(say.say(1_234)).isEqualTo("one thousand two hundred thirty-four"); } @Disabled("Remove to run test") @Test + @DisplayName("one million") public void oneMillion() { assertThat(say.say(1_000_000)).isEqualTo("one million"); } @Disabled("Remove to run test") @Test + @DisplayName("one million two thousand three hundred forty-five") public void oneMillionTwoThousandThreeHundredFortyFive() { assertThat(say.say(1_002_345)).isEqualTo("one million two thousand three hundred forty-five"); } @Disabled("Remove to run test") @Test + @DisplayName("one billion") public void oneBillion() { assertThat(say.say(1_000_000_000)).isEqualTo("one billion"); } @Disabled("Remove to run test") @Test + @DisplayName("a big number") public void nineHundredEightySevenBillionSixHundredFiftyFourThreeHundredTwentyOneThousandOneHundredTwentyThree() { assertThat(say.say(987_654_321_123L)) .isEqualTo("nine hundred eighty-seven billion six hundred fifty-four million" + @@ -112,6 +130,7 @@ public void nineHundredEightySevenBillionSixHundredFiftyFourThreeHundredTwentyOn @Disabled("Remove to run test") @Test + @DisplayName("numbers below zero are out of range") public void illegalNegativeNumber() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> say.say(-1)); @@ -119,6 +138,7 @@ public void illegalNegativeNumber() { @Disabled("Remove to run test") @Test + @DisplayName("numbers above 999,999,999,999 are out of range") public void illegalTooBigNumber() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> say.say(1_000_000_000_000L)); diff --git a/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/scrabble-score/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/scrabble-score/gradlew b/exercises/practice/scrabble-score/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/scrabble-score/gradlew +++ b/exercises/practice/scrabble-score/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/scrabble-score/gradlew.bat b/exercises/practice/scrabble-score/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/scrabble-score/gradlew.bat +++ b/exercises/practice/scrabble-score/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/scrabble-score/src/test/java/ScrabbleScoreTest.java b/exercises/practice/scrabble-score/src/test/java/ScrabbleScoreTest.java index 1be75ea9b..9fc05c0f5 100644 --- a/exercises/practice/scrabble-score/src/test/java/ScrabbleScoreTest.java +++ b/exercises/practice/scrabble-score/src/test/java/ScrabbleScoreTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -6,6 +7,7 @@ public class ScrabbleScoreTest { @Test + @DisplayName("lowercase letter") public void testALowerCaseLetter() { Scrabble scrabble = new Scrabble("a"); assertThat(scrabble.getScore()).isEqualTo(1); @@ -13,6 +15,7 @@ public void testALowerCaseLetter() { @Disabled("Remove to run test") @Test + @DisplayName("uppercase letter") public void testAUpperCaseLetter() { Scrabble scrabble = new Scrabble("A"); assertThat(scrabble.getScore()).isEqualTo(1); @@ -20,6 +23,7 @@ public void testAUpperCaseLetter() { @Disabled("Remove to run test") @Test + @DisplayName("valuable letter") public void testAValuableLetter() { Scrabble scrabble = new Scrabble("f"); assertThat(scrabble.getScore()).isEqualTo(4); @@ -27,6 +31,7 @@ public void testAValuableLetter() { @Disabled("Remove to run test") @Test + @DisplayName("short word") public void testAShortWord() { Scrabble scrabble = new Scrabble("at"); assertThat(scrabble.getScore()).isEqualTo(2); @@ -34,6 +39,7 @@ public void testAShortWord() { @Disabled("Remove to run test") @Test + @DisplayName("short, valuable word") public void testAShortValuableWord() { Scrabble scrabble = new Scrabble("zoo"); assertThat(scrabble.getScore()).isEqualTo(12); @@ -41,6 +47,7 @@ public void testAShortValuableWord() { @Disabled("Remove to run test") @Test + @DisplayName("medium word") public void testAMediumWord() { Scrabble scrabble = new Scrabble("street"); assertThat(scrabble.getScore()).isEqualTo(6); @@ -48,6 +55,7 @@ public void testAMediumWord() { @Disabled("Remove to run test") @Test + @DisplayName("medium, valuable word") public void testAMediumValuableWord() { Scrabble scrabble = new Scrabble("quirky"); assertThat(scrabble.getScore()).isEqualTo(22); @@ -55,6 +63,7 @@ public void testAMediumValuableWord() { @Disabled("Remove to run test") @Test + @DisplayName("long, mixed-case word") public void testALongMixCaseWord() { Scrabble scrabble = new Scrabble("OxyphenButazone"); assertThat(scrabble.getScore()).isEqualTo(41); @@ -62,6 +71,7 @@ public void testALongMixCaseWord() { @Disabled("Remove to run test") @Test + @DisplayName("english-like word") public void testAEnglishLikeWord() { Scrabble scrabble = new Scrabble("pinata"); assertThat(scrabble.getScore()).isEqualTo(8); @@ -69,6 +79,7 @@ public void testAEnglishLikeWord() { @Disabled("Remove to run test") @Test + @DisplayName("empty input") public void testAnEmptyInput() { Scrabble scrabble = new Scrabble(""); assertThat(scrabble.getScore()).isEqualTo(0); @@ -76,6 +87,7 @@ public void testAnEmptyInput() { @Disabled("Remove to run test") @Test + @DisplayName("entire alphabet available") public void testEntireAlphabetAvailable() { Scrabble scrabble = new Scrabble("abcdefghijklmnopqrstuvwxyz"); assertThat(scrabble.getScore()).isEqualTo(87); diff --git a/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/secret-handshake/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/secret-handshake/gradlew b/exercises/practice/secret-handshake/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/secret-handshake/gradlew +++ b/exercises/practice/secret-handshake/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/secret-handshake/gradlew.bat b/exercises/practice/secret-handshake/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/secret-handshake/gradlew.bat +++ b/exercises/practice/secret-handshake/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/secret-handshake/src/test/java/HandshakeCalculatorTest.java b/exercises/practice/secret-handshake/src/test/java/HandshakeCalculatorTest.java index 286bff45b..a1cc3ce32 100644 --- a/exercises/practice/secret-handshake/src/test/java/HandshakeCalculatorTest.java +++ b/exercises/practice/secret-handshake/src/test/java/HandshakeCalculatorTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,30 +9,35 @@ public class HandshakeCalculatorTest { private final HandshakeCalculator handshakeCalculator = new HandshakeCalculator(); @Test + @DisplayName("wink for 1") public void testThatInput1YieldsAWink() { assertThat(handshakeCalculator.calculateHandshake(1)).containsExactly(Signal.WINK); } @Disabled("Remove to run test") @Test + @DisplayName("double blink for 10") public void testThatInput2YieldsADoubleBlink() { assertThat(handshakeCalculator.calculateHandshake(2)).containsExactly(Signal.DOUBLE_BLINK); } @Disabled("Remove to run test") @Test + @DisplayName("close your eyes for 100") public void testThatInput4YieldsACloseYourEyes() { assertThat(handshakeCalculator.calculateHandshake(4)).containsExactly(Signal.CLOSE_YOUR_EYES); } @Disabled("Remove to run test") @Test + @DisplayName("jump for 1000") public void testThatInput8YieldsAJump() { assertThat(handshakeCalculator.calculateHandshake(8)).containsExactly(Signal.JUMP); } @Disabled("Remove to run test") @Test + @DisplayName("combine two actions") public void testAnInputThatYieldsTwoActions() { assertThat(handshakeCalculator.calculateHandshake(3)) .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK); @@ -39,6 +45,7 @@ public void testAnInputThatYieldsTwoActions() { @Disabled("Remove to run test") @Test + @DisplayName("reverse two actions") public void testAnInputThatYieldsTwoReversedActions() { assertThat(handshakeCalculator.calculateHandshake(19)) .containsExactly(Signal.DOUBLE_BLINK, Signal.WINK); @@ -46,18 +53,21 @@ public void testAnInputThatYieldsTwoReversedActions() { @Disabled("Remove to run test") @Test + @DisplayName("reversing one action gives the same action") public void testReversingASingleActionYieldsTheSameAction() { assertThat(handshakeCalculator.calculateHandshake(24)).containsExactly(Signal.JUMP); } @Disabled("Remove to run test") @Test + @DisplayName("reversing no actions still gives no actions") public void testReversingNoActionsYieldsNoActions() { assertThat(handshakeCalculator.calculateHandshake(16)).isEmpty(); } @Disabled("Remove to run test") @Test + @DisplayName("all possible actions") public void testInputThatYieldsAllActions() { assertThat(handshakeCalculator.calculateHandshake(15)) .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP); @@ -65,6 +75,7 @@ public void testInputThatYieldsAllActions() { @Disabled("Remove to run test") @Test + @DisplayName("reverse all possible actions") public void testInputThatYieldsAllActionsReversed() { assertThat(handshakeCalculator.calculateHandshake(31)) .containsExactly(Signal.JUMP, Signal.CLOSE_YOUR_EYES, Signal.DOUBLE_BLINK, Signal.WINK); @@ -72,12 +83,18 @@ public void testInputThatYieldsAllActionsReversed() { @Disabled("Remove to run test") @Test + @DisplayName("do nothing for zero") public void testThatInput0YieldsNoActions() { assertThat(handshakeCalculator.calculateHandshake(0)).isEmpty(); } + /* The following tests diverge from the canonical test data to test numbers with binary representation with + * more than five digits are correctly handled. For more details, check out issue #1965 here: + * (https://github.com/exercism/java/issues/1965). + */ @Disabled("Remove to run test") @Test + @DisplayName("handles input with more than five bits with reversal") public void testThatHandlesMoreThanFiveBinaryPlacesWithReversal() { assertThat(handshakeCalculator.calculateHandshake(51)) .containsExactly(Signal.DOUBLE_BLINK, Signal.WINK); @@ -85,6 +102,7 @@ public void testThatHandlesMoreThanFiveBinaryPlacesWithReversal() { @Disabled("Remove to run test") @Test + @DisplayName("handles input with more than five bits without reversal") public void testThatHandlesMoreThanFiveBinaryPlacesWithoutReversal() { assertThat(handshakeCalculator.calculateHandshake(35)) .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK); @@ -92,6 +110,7 @@ public void testThatHandlesMoreThanFiveBinaryPlacesWithoutReversal() { @Disabled("Remove to run test") @Test + @DisplayName("all actions for input with more than five bits") public void testInputThatYieldsAllActionsFromMoreThanFiveBinaryPlaces() { assertThat(handshakeCalculator.calculateHandshake(111)) .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP); diff --git a/exercises/practice/series/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/series/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/series/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/series/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/series/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/series/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/series/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/series/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/series/gradlew b/exercises/practice/series/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/series/gradlew +++ b/exercises/practice/series/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/series/gradlew.bat b/exercises/practice/series/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/series/gradlew.bat +++ b/exercises/practice/series/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/series/src/test/java/SeriesTest.java b/exercises/practice/series/src/test/java/SeriesTest.java index 2009d437b..726e9fd24 100644 --- a/exercises/practice/series/src/test/java/SeriesTest.java +++ b/exercises/practice/series/src/test/java/SeriesTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -11,6 +12,7 @@ public class SeriesTest { @Test + @DisplayName("slices of one from one") public void slicesOfOneFromOne() { Series series = new Series("1"); List expected = Collections.singletonList("1"); @@ -20,6 +22,7 @@ public void slicesOfOneFromOne() { @Disabled("Remove to run test") @Test + @DisplayName("slices of one from two") public void slicesOfOneFromTwo() { Series series = new Series("12"); List expected = Arrays.asList("1", "2"); @@ -29,6 +32,7 @@ public void slicesOfOneFromTwo() { @Disabled("Remove to run test") @Test + @DisplayName("slices of two") public void slicesOfTwo() { Series series = new Series("35"); List expected = Collections.singletonList("35"); @@ -38,6 +42,7 @@ public void slicesOfTwo() { @Disabled("Remove to run test") @Test + @DisplayName("slices of two overlap") public void slicesOfTwoOverlap() { Series series = new Series("9142"); List expected = Arrays.asList("91", "14", "42"); @@ -47,6 +52,7 @@ public void slicesOfTwoOverlap() { @Disabled("Remove to run test") @Test + @DisplayName("slices can include duplicates") public void slicesIncludeDuplicates() { Series series = new Series("777777"); List expected = Arrays.asList( @@ -61,6 +67,7 @@ public void slicesIncludeDuplicates() { @Disabled("Remove to run test") @Test + @DisplayName("slices of a long series") public void slicesOfLongSeries() { Series series = new Series("918493904243"); List expected = Arrays.asList( @@ -79,6 +86,7 @@ public void slicesOfLongSeries() { @Disabled("Remove to run test") @Test + @DisplayName("slice length is too large") public void sliceLengthIsToolarge() { Series series = new Series("12345"); @@ -89,6 +97,7 @@ public void sliceLengthIsToolarge() { @Disabled("Remove to run test") @Test + @DisplayName("slice length is way too large") public void sliceLengthIsWayToolarge() { Series series = new Series("12345"); @@ -99,6 +108,7 @@ public void sliceLengthIsWayToolarge() { @Disabled("Remove to run test") @Test + @DisplayName("slice length cannot be zero") public void sliceLengthZero() { Series series = new Series("12345"); @@ -109,6 +119,7 @@ public void sliceLengthZero() { @Disabled("Remove to run test") @Test + @DisplayName("slice length cannot be negative") public void sliceLengthNegative() { Series series = new Series("123"); @@ -119,6 +130,7 @@ public void sliceLengthNegative() { @Disabled("Remove to run test") @Test + @DisplayName("empty series is invalid") public void emptySeries() { assertThatExceptionOfType(IllegalArgumentException.class) diff --git a/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/sgf-parsing/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/sgf-parsing/gradlew b/exercises/practice/sgf-parsing/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/sgf-parsing/gradlew +++ b/exercises/practice/sgf-parsing/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/sgf-parsing/gradlew.bat b/exercises/practice/sgf-parsing/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/sgf-parsing/gradlew.bat +++ b/exercises/practice/sgf-parsing/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/sgf-parsing/src/test/java/SgfParsingTest.java b/exercises/practice/sgf-parsing/src/test/java/SgfParsingTest.java index 6e15ca04b..afd458506 100644 --- a/exercises/practice/sgf-parsing/src/test/java/SgfParsingTest.java +++ b/exercises/practice/sgf-parsing/src/test/java/SgfParsingTest.java @@ -5,11 +5,13 @@ import java.util.Map; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; public class SgfParsingTest { @Test + @DisplayName("empty input") public void emptyInput() { String input = ""; assertThatExceptionOfType(SgfParsingException.class).as("tree missing") @@ -18,6 +20,7 @@ public void emptyInput() { @Test @Disabled("Remove to run test") + @DisplayName("tree with no nodes") public void treeWithNoNodes() { String input = "()"; assertThatExceptionOfType(SgfParsingException.class) @@ -27,6 +30,7 @@ public void treeWithNoNodes() { @Test @Disabled("Remove to run test") + @DisplayName("node without tree") public void nodeWithoutTree() { String input = ";"; assertThatExceptionOfType(SgfParsingException.class).as("tree missing") @@ -35,6 +39,7 @@ public void nodeWithoutTree() { @Test @Disabled("Remove to run test") + @DisplayName("node without properties") public void nodeWithoutProperties() throws SgfParsingException { String input = "(;)"; SgfNode expected = new SgfNode(); @@ -44,6 +49,7 @@ public void nodeWithoutProperties() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("single node tree") public void singleNodeTree() throws SgfParsingException { String input = "(;A[B])"; SgfNode expected = new SgfNode(Map.of("A", List.of("B"))); @@ -53,6 +59,7 @@ public void singleNodeTree() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("multiple properties") public void multipleProperties() throws SgfParsingException { String input = "(;A[b]C[d])"; SgfNode expected = new SgfNode(Map.of("A", List.of("b"), @@ -63,6 +70,7 @@ public void multipleProperties() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("properties without delimiter") public void propertiesWithoutDelimiter() { String input = "(;A)"; assertThatExceptionOfType(SgfParsingException.class).as("properties without delimiter") @@ -71,6 +79,7 @@ public void propertiesWithoutDelimiter() { @Test @Disabled("Remove to run test") + @DisplayName("all lowercase property") public void allLowercaseProperty() { String input = "(;a[b])"; assertThatExceptionOfType(SgfParsingException.class).as("property must be in uppercase") @@ -79,6 +88,7 @@ public void allLowercaseProperty() { @Test @Disabled("Remove to run test") + @DisplayName("upper and lowercase property") public void upperAndLowercaseProperty() { String input = "(;Aa[b])"; assertThatExceptionOfType(SgfParsingException.class).as("property must be in uppercase") @@ -87,6 +97,7 @@ public void upperAndLowercaseProperty() { @Test @Disabled("Remove to run test") + @DisplayName("two nodes") public void twoNodes() throws SgfParsingException { String input = "(;A[B];B[C])"; SgfNode expected = new SgfNode(Map.of("A", List.of("B")), @@ -99,6 +110,7 @@ public void twoNodes() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("two child trees") public void twoChildTrees() throws SgfParsingException { String input = "(;A[B](;B[C])(;C[D]))"; SgfNode expected = new SgfNode(Map.of("A", List.of("B")), @@ -112,6 +124,7 @@ public void twoChildTrees() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("multiple property values") public void multiplePropertyValues() throws SgfParsingException { String input = "(;A[b][c][d])"; SgfNode expected = new SgfNode(Map.of("A", List.of("b", "c", "d"))); @@ -121,6 +134,7 @@ public void multiplePropertyValues() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("within property values, whitespace characters such as tab are converted to spaces") public void withinPropertyValueWhitespace() throws SgfParsingException { String input = "(;A[hello\t\tworld])"; SgfNode expected = new SgfNode(Map.of("A", List.of("hello world"))); @@ -130,6 +144,7 @@ public void withinPropertyValueWhitespace() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("within property values, newlines remain as newlines") public void withinPropertyValueNewline() throws SgfParsingException { String input = "(;A[hello\n\nworld])"; SgfNode expected = new SgfNode(Map.of("A", List.of("hello\n\nworld"))); @@ -139,6 +154,7 @@ public void withinPropertyValueNewline() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("escaped closing bracket within property value becomes just a closing bracket") public void escapedClosingBracket() throws SgfParsingException { String input = "(;A[\\]])"; SgfNode expected = new SgfNode(Map.of("A", List.of("]"))); @@ -148,6 +164,7 @@ public void escapedClosingBracket() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("escaped backslash in property value becomes just a backslash") public void escapedBacklash() throws SgfParsingException { String input = "(;A[\\\\])"; SgfNode expected = new SgfNode(Map.of("A", List.of("\\"))); @@ -157,6 +174,7 @@ public void escapedBacklash() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("opening bracket within property value doesn't need to be escaped") public void openingBracketNeedNotToBeEscaped() throws SgfParsingException { String input = "(;A[x[y\\]z][foo]B[bar];C[baz])"; SgfNode expected = new SgfNode(Map.of("A", List.of("x[y]z", "foo"), @@ -170,6 +188,7 @@ public void openingBracketNeedNotToBeEscaped() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("semicolon in property value doesn't need to be escaped") public void semicolonNeedNotToBeEscaped() throws SgfParsingException { String input = "(;A[a;b][foo]B[bar];C[baz])"; SgfNode expected = new SgfNode(Map.of("A", List.of("a;b", "foo"), @@ -183,6 +202,7 @@ public void semicolonNeedNotToBeEscaped() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("parentheses in property value don't need to be escaped") public void paranthesesNeedNotToBeEscaped() throws SgfParsingException { String input = "(;A[x(y)z][foo]B[bar];C[baz])"; SgfNode expected = new SgfNode(Map.of("A", List.of("x(y)z", "foo"), @@ -196,6 +216,7 @@ public void paranthesesNeedNotToBeEscaped() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("escaped tab in property value is converted to space") public void escapedTab() throws SgfParsingException { String input = "(;A[hello\\\tworld])"; SgfNode expected = new SgfNode(Map.of("A", List.of("hello world"))); @@ -205,6 +226,7 @@ public void escapedTab() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("escaped newline in property value is converted to nothing at all") public void escapedNewline() throws SgfParsingException { String input = "(;A[hello\\\nworld])"; SgfNode expected = new SgfNode(Map.of("A", List.of("helloworld"))); @@ -215,6 +237,7 @@ public void escapedNewline() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("escaped t and n in property value are just letters, not whitespace") public void escapedTAndN() throws SgfParsingException { String input = "(;A[\\t = t and \\n = n])"; SgfNode expected = new SgfNode(Map.of("A", List.of("t = t and n = n"))); @@ -225,6 +248,7 @@ public void escapedTAndN() throws SgfParsingException { @Test @Disabled("Remove to run test") + @DisplayName("mixing various kinds of whitespace and escaped characters in property value") public void mixOfEscapedCharactersAndWhitespaces() throws SgfParsingException { String input = "(;A[\\]b\nc\\\nd\t\te\\\\ \\\n\\]])"; SgfNode expected = new SgfNode(Map.of("A", List.of("]b\ncd e\\ ]"))); diff --git a/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/sieve/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/sieve/gradlew b/exercises/practice/sieve/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/sieve/gradlew +++ b/exercises/practice/sieve/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/sieve/gradlew.bat b/exercises/practice/sieve/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/sieve/gradlew.bat +++ b/exercises/practice/sieve/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/sieve/src/test/java/SieveTest.java b/exercises/practice/sieve/src/test/java/SieveTest.java index b213ac0f7..529329323 100644 --- a/exercises/practice/sieve/src/test/java/SieveTest.java +++ b/exercises/practice/sieve/src/test/java/SieveTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -10,6 +11,7 @@ public class SieveTest { @Test + @DisplayName("no primes under two") public void noPrimesUnder2() { Sieve sieve = new Sieve(1); List expectedOutput = Collections.emptyList(); @@ -19,6 +21,7 @@ public void noPrimesUnder2() { @Disabled("Remove to run test") @Test + @DisplayName("find first prime") public void findFirstPrime() { Sieve sieve = new Sieve(2); List expectedOutput = Collections.singletonList(2); @@ -28,6 +31,7 @@ public void findFirstPrime() { @Disabled("Remove to run test") @Test + @DisplayName("find primes up to 10") public void findPrimesUpTo10() { Sieve sieve = new Sieve(10); List expectedOutput = Arrays.asList(2, 3, 5, 7); @@ -37,6 +41,7 @@ public void findPrimesUpTo10() { @Disabled("Remove to run test") @Test + @DisplayName("limit is prime") public void limitIsPrime() { Sieve sieve = new Sieve(13); List expectedOutput = Arrays.asList(2, 3, 5, 7, 11, 13); @@ -46,6 +51,7 @@ public void limitIsPrime() { @Disabled("Remove to run test") @Test + @DisplayName("find primes up to 1000") public void findPrimesUpTo1000() { Sieve sieve = new Sieve(1000); List expectedOutput = Arrays.asList(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, diff --git a/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/simple-cipher/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/simple-cipher/gradlew b/exercises/practice/simple-cipher/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/simple-cipher/gradlew +++ b/exercises/practice/simple-cipher/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/simple-cipher/gradlew.bat b/exercises/practice/simple-cipher/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/simple-cipher/gradlew.bat +++ b/exercises/practice/simple-cipher/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/simple-cipher/src/test/java/SimpleCipherTest.java b/exercises/practice/simple-cipher/src/test/java/SimpleCipherTest.java index 1aadc854f..af7adbe4b 100644 --- a/exercises/practice/simple-cipher/src/test/java/SimpleCipherTest.java +++ b/exercises/practice/simple-cipher/src/test/java/SimpleCipherTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -18,6 +19,7 @@ public void setup() { * problem with shift ciphers, some characters will always output the key verbatim. */ @Test + @DisplayName("Can encode") public void randomKeyCipherCanEncode() { String plainText = "aaaaaaaaaa"; String cipherText = randomKeyCipher.getKey().substring(0, 10); @@ -26,6 +28,7 @@ public void randomKeyCipherCanEncode() { @Disabled("Remove to run test") @Test + @DisplayName("Can decode") public void randomKeyCipherCanDecode() { String cipherText = "aaaaaaaaaa"; assertThat(randomKeyCipher.decode(randomKeyCipher.getKey().substring(0, 10))) @@ -34,6 +37,10 @@ public void randomKeyCipherCanDecode() { @Disabled("Remove to run test") @Test + @DisplayName( + "Is reversible. I.e., if you apply decode in a encoded result, " + + "you must see the same plaintext encode parameter as a result of the decode method" + ) public void randomKeyCipherIsReversible() { String plainText = "abcdefghij"; assertThat(randomKeyCipher.decode(randomKeyCipher.encode(plainText))).isEqualTo(plainText); @@ -41,12 +48,14 @@ public void randomKeyCipherIsReversible() { @Disabled("Remove to run test") @Test + @DisplayName("Key is made only of lowercase letters") public void randomKeyCipherKeyIsLowercaseLetters() { assertThat(randomKeyCipher.getKey()).matches("^[a-z]+$"); } @Disabled("Remove to run test") @Test + @DisplayName("Can encode") public void substitutionCipherCanEncode() { String plainText = "aaaaaaaaaa"; String cipherText = "abcdefghij"; @@ -55,6 +64,7 @@ public void substitutionCipherCanEncode() { @Disabled("Remove to run test") @Test + @DisplayName("Can decode") public void substitutionCipherCanDecode() { String plainText = "abcdefghij"; String cipherText = "aaaaaaaaaa"; @@ -63,6 +73,10 @@ public void substitutionCipherCanDecode() { @Disabled("Remove to run test") @Test + @DisplayName( + "Is reversible. I.e., if you apply decode in a encoded result, " + + "you must see the same plaintext encode parameter as a result of the decode method" + ) public void substitutionCipherIsReversibleGivenKey() { String plainText = "abcdefghij"; assertThat(substitutionCipher.decode(substitutionCipher.encode(plainText))).isEqualTo(plainText); @@ -70,6 +84,7 @@ public void substitutionCipherIsReversibleGivenKey() { @Disabled("Remove to run test") @Test + @DisplayName("Can double shift encode") public void substitutionCipherCanDoubleShiftEncode() { String plainText = "iamapandabear"; String cipherText = "qayaeaagaciai"; @@ -78,6 +93,7 @@ public void substitutionCipherCanDoubleShiftEncode() { @Disabled("Remove to run test") @Test + @DisplayName("Can wrap on encode") public void substitutionCipherCanWrapEncode() { String plainText = "zzzzzzzzzz"; String cipherText = "zabcdefghi"; @@ -86,6 +102,7 @@ public void substitutionCipherCanWrapEncode() { @Disabled("Remove to run test") @Test + @DisplayName("Can wrap on decode") public void substitutionCipherCanWrapDecode() { String plainText = "zabcdefghi"; String cipherText = "zzzzzzzzzz"; @@ -94,6 +111,7 @@ public void substitutionCipherCanWrapDecode() { @Disabled("Remove to run test") @Test + @DisplayName("Can decode messages longer than the key") public void substitutionCipherMessageLongerThanKey() { String plainText = "iamapandabear"; String key = "abc"; diff --git a/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/simple-linked-list/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/simple-linked-list/gradlew b/exercises/practice/simple-linked-list/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/simple-linked-list/gradlew +++ b/exercises/practice/simple-linked-list/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/simple-linked-list/gradlew.bat b/exercises/practice/simple-linked-list/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/simple-linked-list/gradlew.bat +++ b/exercises/practice/simple-linked-list/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/simple-linked-list/src/test/java/SimpleLinkedListTest.java b/exercises/practice/simple-linked-list/src/test/java/SimpleLinkedListTest.java index 76e219ff8..109d3b3a7 100644 --- a/exercises/practice/simple-linked-list/src/test/java/SimpleLinkedListTest.java +++ b/exercises/practice/simple-linked-list/src/test/java/SimpleLinkedListTest.java @@ -1,14 +1,16 @@ -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.NoSuchElementException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + public class SimpleLinkedListTest { @Test + @DisplayName("A new list is empty") public void aNewListIsEmpty() { SimpleLinkedList list = new SimpleLinkedList<>(); assertThat(list.size()).isEqualTo(0); @@ -16,6 +18,7 @@ public void aNewListIsEmpty() { @Disabled("Remove to run test") @Test + @DisplayName("Create list from array") public void canCreateFromArray() { Character[] values = new Character[]{'1', '2', '3'}; SimpleLinkedList list = new SimpleLinkedList(values); @@ -24,6 +27,7 @@ public void canCreateFromArray() { @Disabled("Remove to run test") @Test + @DisplayName("Popping an empty list throws NoSuchElementException") public void popOnEmptyListWillThrow() { SimpleLinkedList list = new SimpleLinkedList(); @@ -32,6 +36,7 @@ public void popOnEmptyListWillThrow() { @Disabled("Remove to run test") @Test + @DisplayName("Pop returns last added element (LIFO)") public void popReturnsLastAddedElement() { SimpleLinkedList list = new SimpleLinkedList(); list.push(9); @@ -44,6 +49,7 @@ public void popReturnsLastAddedElement() { @Disabled("Remove to run test") @Test + @DisplayName("Reverse reverses the list order") public void reverseReversesList() { SimpleLinkedList list = new SimpleLinkedList(); list.push("9"); @@ -61,6 +67,7 @@ public void reverseReversesList() { @Disabled("Remove to run test") @Test + @DisplayName("Can return list as an array") public void canReturnListAsArray() { SimpleLinkedList list = new SimpleLinkedList(); list.push('9'); @@ -74,6 +81,7 @@ public void canReturnListAsArray() { @Disabled("Remove to run test") @Test + @DisplayName("Can return empty list as an empty array") public void canReturnEmptyListAsEmptyArray() { SimpleLinkedList list = new SimpleLinkedList(); Object[] expected = {}; diff --git a/exercises/practice/space-age/.meta/config.json b/exercises/practice/space-age/.meta/config.json index 449c0e3f7..d1779a5e3 100644 --- a/exercises/practice/space-age/.meta/config.json +++ b/exercises/practice/space-age/.meta/config.json @@ -36,5 +36,5 @@ }, "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", - "source_url": "https://pine.fm/LearnToProgram/?Chapter=01" + "source_url": "https://pine.fm/LearnToProgram/chap_01.html" } diff --git a/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/space-age/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/space-age/gradlew b/exercises/practice/space-age/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/space-age/gradlew +++ b/exercises/practice/space-age/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/space-age/gradlew.bat b/exercises/practice/space-age/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/space-age/gradlew.bat +++ b/exercises/practice/space-age/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/space-age/src/test/java/SpaceAgeTest.java b/exercises/practice/space-age/src/test/java/SpaceAgeTest.java index 4b2a9d43a..248d6938e 100644 --- a/exercises/practice/space-age/src/test/java/SpaceAgeTest.java +++ b/exercises/practice/space-age/src/test/java/SpaceAgeTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -9,6 +10,7 @@ public class SpaceAgeTest { private static final double MAXIMUM_DELTA = 1E-02; @Test + @DisplayName("age on Earth") public void ageOnEarth() { SpaceAge age = new SpaceAge(1000000000); @@ -17,6 +19,7 @@ public void ageOnEarth() { @Disabled("Remove to run test") @Test + @DisplayName("age on Mercury") public void ageOnMercury() { SpaceAge age = new SpaceAge(2134835688); @@ -25,6 +28,7 @@ public void ageOnMercury() { @Disabled("Remove to run test") @Test + @DisplayName("age on Venus") public void ageOnVenus() { SpaceAge age = new SpaceAge(189839836); @@ -33,6 +37,7 @@ public void ageOnVenus() { @Disabled("Remove to run test") @Test + @DisplayName("age on Mars") public void ageOnMars() { SpaceAge age = new SpaceAge(2129871239L); @@ -41,6 +46,7 @@ public void ageOnMars() { @Disabled("Remove to run test") @Test + @DisplayName("age on Jupiter") public void ageOnJupiter() { SpaceAge age = new SpaceAge(901876382); @@ -49,6 +55,7 @@ public void ageOnJupiter() { @Disabled("Remove to run test") @Test + @DisplayName("age on Saturn") public void ageOnSaturn() { SpaceAge age = new SpaceAge(2000000000L); @@ -57,6 +64,7 @@ public void ageOnSaturn() { @Disabled("Remove to run test") @Test + @DisplayName("age on Uranus") public void ageOnUranus() { SpaceAge age = new SpaceAge(1210123456L); @@ -65,6 +73,7 @@ public void ageOnUranus() { @Disabled("Remove to run test") @Test + @DisplayName("age on Neptune") public void ageOnNeptune() { SpaceAge age = new SpaceAge(1821023456L); diff --git a/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/spiral-matrix/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/spiral-matrix/gradlew b/exercises/practice/spiral-matrix/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/spiral-matrix/gradlew +++ b/exercises/practice/spiral-matrix/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/spiral-matrix/gradlew.bat b/exercises/practice/spiral-matrix/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/spiral-matrix/gradlew.bat +++ b/exercises/practice/spiral-matrix/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java b/exercises/practice/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java index ee9a971f9..215afdc10 100644 --- a/exercises/practice/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java +++ b/exercises/practice/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,12 +15,14 @@ public void setUp() { } @Test + @DisplayName("empty spiral") public void testEmptySpiral() { assertThat(spiralMatrixBuilder.buildMatrixOfSize(0)).isEmpty(); } @Disabled("Remove to run test") @Test + @DisplayName("trivial spiral") public void testTrivialSpiral() { int[][] expected = { {1} @@ -30,6 +33,7 @@ public void testTrivialSpiral() { @Disabled("Remove to run test") @Test + @DisplayName("spiral of size 2") public void testSpiralOfSize2() { int[][] expected = { {1, 2}, @@ -41,6 +45,7 @@ public void testSpiralOfSize2() { @Disabled("Remove to run test") @Test + @DisplayName("spiral of size 3") public void testSpiralOfSize3() { int[][] expected = { {1, 2, 3}, @@ -53,6 +58,7 @@ public void testSpiralOfSize3() { @Disabled("Remove to run test") @Test + @DisplayName("spiral of size 4") public void testSpiralOfSize4() { int[][] expected = { { 1, 2, 3, 4}, @@ -66,6 +72,7 @@ public void testSpiralOfSize4() { @Disabled("Remove to run test") @Test + @DisplayName("spiral of size 5") public void testSpiralOfSize5() { int[][] expected = { { 1, 2, 3, 4, 5}, diff --git a/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/split-second-stopwatch/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/split-second-stopwatch/gradlew b/exercises/practice/split-second-stopwatch/gradlew old mode 100644 new mode 100755 index 1aa94a426..b9bb139f7 --- a/exercises/practice/split-second-stopwatch/gradlew +++ b/exercises/practice/split-second-stopwatch/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/split-second-stopwatch/gradlew.bat b/exercises/practice/split-second-stopwatch/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/split-second-stopwatch/gradlew.bat +++ b/exercises/practice/split-second-stopwatch/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/square-root/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/square-root/gradlew b/exercises/practice/square-root/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/square-root/gradlew +++ b/exercises/practice/square-root/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/square-root/gradlew.bat b/exercises/practice/square-root/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/square-root/gradlew.bat +++ b/exercises/practice/square-root/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/state-of-tic-tac-toe/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/state-of-tic-tac-toe/gradlew b/exercises/practice/state-of-tic-tac-toe/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/state-of-tic-tac-toe/gradlew +++ b/exercises/practice/state-of-tic-tac-toe/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/state-of-tic-tac-toe/gradlew.bat b/exercises/practice/state-of-tic-tac-toe/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/state-of-tic-tac-toe/gradlew.bat +++ b/exercises/practice/state-of-tic-tac-toe/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index e5352ae50..d264db005 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,6 +15,7 @@ public void setup() { } @Test + @DisplayName("Finished game where X won via left column victory") public void testFinishedGameWhereXWonViaLeftColumnVictory() { assertThat( @@ -23,6 +25,7 @@ public void testFinishedGameWhereXWonViaLeftColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via middle column victory") public void testFinishedGameWhereXWonViaMiddleColumnVictory() { assertThat( @@ -32,6 +35,7 @@ public void testFinishedGameWhereXWonViaMiddleColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via right column victory") public void testFinishedGameWhereXWonViaRightColumnVictory() { assertThat( @@ -41,6 +45,7 @@ public void testFinishedGameWhereXWonViaRightColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via left column victory") public void testFinishedGameWhereOWonViaLeftColumnVictory() { assertThat( @@ -50,6 +55,7 @@ public void testFinishedGameWhereOWonViaLeftColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via middle column victory") public void testFinishedGameWhereOWonViaMiddleColumnVictory() { assertThat( @@ -59,6 +65,7 @@ public void testFinishedGameWhereOWonViaMiddleColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via right column victory") public void testFinishedGameWhereOWonViaRightColumnVictory() { assertThat( @@ -68,6 +75,7 @@ public void testFinishedGameWhereOWonViaRightColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via top row victory") public void testFinishedGameWhereXWonViaTopRowVictory() { assertThat( @@ -77,6 +85,7 @@ public void testFinishedGameWhereXWonViaTopRowVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via middle row victory") public void testFinishedGameWhereXWonViaMiddleRowVictory() { assertThat( @@ -86,6 +95,7 @@ public void testFinishedGameWhereXWonViaMiddleRowVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via middle row victory") public void testFinishedGameWhereXWonViaBottomRowVictory() { assertThat( @@ -95,6 +105,7 @@ public void testFinishedGameWhereXWonViaBottomRowVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via top row victory") public void testFinishedGameWhereOWonViaTopRowVictory() { assertThat( @@ -104,6 +115,7 @@ public void testFinishedGameWhereOWonViaTopRowVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via middle row victory") public void testFinishedGameWhereOWonViaMiddleRowVictory() { assertThat( @@ -113,6 +125,7 @@ public void testFinishedGameWhereOWonViaMiddleRowVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via bottom row victory") public void testFinishedGameWhereOWonViaBottomRowVictory() { assertThat( @@ -122,6 +135,7 @@ public void testFinishedGameWhereOWonViaBottomRowVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via falling diagonal victory") public void testFinishedGameWhereXWonViaFallingDiagonalVictory() { assertThat( @@ -131,6 +145,7 @@ public void testFinishedGameWhereXWonViaFallingDiagonalVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via rising diagonal victory") public void testFinishedGameWhereXWonViaRisingDiagonalVictory() { assertThat( @@ -140,6 +155,7 @@ public void testFinishedGameWhereXWonViaRisingDiagonalVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via falling diagonal victory") public void testFinishedGameWhereOWonViaFallingDiagonalVictory() { assertThat( @@ -149,6 +165,7 @@ public void testFinishedGameWhereOWonViaFallingDiagonalVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where O won via rising diagonal victory") public void testFinishedGameWhereOWonViaRisingDiagonalVictory() { assertThat( @@ -158,6 +175,7 @@ public void testFinishedGameWhereOWonViaRisingDiagonalVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via a row and a column victory") public void testFinishedGameWhereXWonViaARowAndAColumnVictory() { assertThat( @@ -167,6 +185,7 @@ public void testFinishedGameWhereXWonViaARowAndAColumnVictory() { @Disabled("Remove to run test") @Test + @DisplayName("Finished game where X won via two diagonal victories") public void testFinishedGameWhereXWonViaTwoDiagonalVictories() { assertThat( @@ -176,6 +195,7 @@ public void testFinishedGameWhereXWonViaTwoDiagonalVictories() { @Disabled("Remove to run test") @Test + @DisplayName("Drawn games") public void testDraw() { assertThat( @@ -185,6 +205,7 @@ public void testDraw() { @Disabled("Remove to run test") @Test + @DisplayName("Another draw") public void testAnotherDraw() { assertThat( @@ -194,6 +215,7 @@ public void testAnotherDraw() { @Disabled("Remove to run test") @Test + @DisplayName("Ongoing game: one move in") public void testOngoingGameOneMoveIn() { assertThat( @@ -203,6 +225,7 @@ public void testOngoingGameOneMoveIn() { @Disabled("Remove to run test") @Test + @DisplayName("Ongoing game: two moves in") public void testOngoingGameTwoMovesIn() { assertThat( @@ -212,6 +235,7 @@ public void testOngoingGameTwoMovesIn() { @Disabled("Remove to run test") @Test + @DisplayName("Ongoing game: five moves in") public void testOngoingGameFiveMovesIn() { assertThat( @@ -221,6 +245,7 @@ public void testOngoingGameFiveMovesIn() { @Disabled("Remove to run test") @Test + @DisplayName("Invalid board: X went twice") public void testInvalidBoardXWentTwice() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -230,6 +255,7 @@ public void testInvalidBoardXWentTwice() { @Disabled("Remove to run test") @Test + @DisplayName("Invalid board: O started") public void testInvalidBoardOStarted() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -239,6 +265,7 @@ public void testInvalidBoardOStarted() { @Disabled("Remove to run test") @Test + @DisplayName("Invalid board") public void testInvalidBoard() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -248,6 +275,7 @@ public void testInvalidBoard() { @Disabled("Remove to run test") @Test + @DisplayName("Invalid board: players kept playing after a win") public void testInvalidBoardPlayersKeptPlayingAfterAWin() { assertThatExceptionOfType(IllegalArgumentException.class) diff --git a/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/sublist/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/sublist/gradlew b/exercises/practice/sublist/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/sublist/gradlew +++ b/exercises/practice/sublist/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/sublist/gradlew.bat b/exercises/practice/sublist/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/sublist/gradlew.bat +++ b/exercises/practice/sublist/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/sublist/src/test/java/RelationshipComputerTest.java b/exercises/practice/sublist/src/test/java/RelationshipComputerTest.java index e9e4adc62..bcb2d6f8d 100644 --- a/exercises/practice/sublist/src/test/java/RelationshipComputerTest.java +++ b/exercises/practice/sublist/src/test/java/RelationshipComputerTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.List; @@ -10,6 +11,7 @@ public class RelationshipComputerTest { @Test + @DisplayName("empty lists") public void testThatTwoEmptyListsAreConsideredEqual() { Relationship relationship = new RelationshipComputer<>().computeRelationship( emptyList(), @@ -20,6 +22,7 @@ public void testThatTwoEmptyListsAreConsideredEqual() { @Disabled("Remove to run test") @Test + @DisplayName("empty list within non empty list") public void testEmptyListIsSublistOfNonEmptyList() { Relationship relationship = new RelationshipComputer<>().computeRelationship( emptyList(), @@ -30,6 +33,7 @@ public void testEmptyListIsSublistOfNonEmptyList() { @Disabled("Remove to run test") @Test + @DisplayName("non empty list contains empty list") public void testNonEmptyListIsSuperlistOfEmptyList() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList('1', '2', '3'), @@ -40,6 +44,7 @@ public void testNonEmptyListIsSuperlistOfEmptyList() { @Disabled("Remove to run test") @Test + @DisplayName("list equals itself") public void testListIsEqualToItself() { List anyList = asList("1", "2", "3"); @@ -52,6 +57,7 @@ public void testListIsEqualToItself() { @Disabled("Remove to run test") @Test + @DisplayName("different lists") public void testDifferentListsOfTheSameLengthAreUnequal() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList(1, 2, 3), @@ -62,6 +68,7 @@ public void testDifferentListsOfTheSameLengthAreUnequal() { @Disabled("Remove to run test") @Test + @DisplayName("false start") public void testSublistCheckDoesNotAbortAfterFalseStart() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList('1', '2', '5'), @@ -72,6 +79,7 @@ public void testSublistCheckDoesNotAbortAfterFalseStart() { @Disabled("Remove to run test") @Test + @DisplayName("consecutive") public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList("1", "1", "2"), @@ -82,6 +90,7 @@ public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() { @Disabled("Remove to run test") @Test + @DisplayName("sublist at start") public void testSublistAtStart() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList(0, 1, 2), @@ -92,6 +101,7 @@ public void testSublistAtStart() { @Disabled("Remove to run test") @Test + @DisplayName("sublist in middle") public void testSublistInMiddle() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList('2', '3', '4'), @@ -102,6 +112,7 @@ public void testSublistInMiddle() { @Disabled("Remove to run test") @Test + @DisplayName("sublist at end") public void testSublistAtEnd() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList("3", "4", "5"), @@ -112,6 +123,7 @@ public void testSublistAtEnd() { @Disabled("Remove to run test") @Test + @DisplayName("at start of superlist") public void testAtStartOfSuperlist() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList(0, 1, 2, 3, 4, 5), @@ -122,6 +134,7 @@ public void testAtStartOfSuperlist() { @Disabled("Remove to run test") @Test + @DisplayName("in middle of superlist") public void testInMiddleOfSuperlist() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList('0', '1', '2', '3', '4', '5'), @@ -132,6 +145,7 @@ public void testInMiddleOfSuperlist() { @Disabled("Remove to run test") @Test + @DisplayName("at end of superlist") public void testAtEndOfSuperlist() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList("0", "1", "2", "3", "4", "5"), @@ -142,6 +156,7 @@ public void testAtEndOfSuperlist() { @Disabled("Remove to run test") @Test + @DisplayName("first list missing element from second list") public void testFirstListMissingElementFromSecondList() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList(1, 3), @@ -152,6 +167,7 @@ public void testFirstListMissingElementFromSecondList() { @Disabled("Remove to run test") @Test + @DisplayName("second list missing element from first list") public void testSecondListMissingElementFromFirstList() { Relationship relationship = new RelationshipComputer<>().computeRelationship( asList('1', '2', '3'), @@ -162,30 +178,33 @@ public void testSecondListMissingElementFromFirstList() { @Disabled("Remove to run test") @Test - public void testThatListOrderingIsAccountedFor() { + @DisplayName("first list missing additional digits from second list") + public void testFirstListMissingAdditionalDigitsFromSecondList() { Relationship relationship = new RelationshipComputer<>().computeRelationship( - asList("1", "2", "3"), - asList("3", "2", "1")); + asList(1, 2), + asList(1, 22)); assertThat(relationship).isEqualTo(Relationship.UNEQUAL); } @Disabled("Remove to run test") @Test - public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() { + @DisplayName("order matters to a list") + public void testThatListOrderingIsAccountedFor() { Relationship relationship = new RelationshipComputer<>().computeRelationship( - asList(1, 0, 1), - asList(10, 1)); + asList("1", "2", "3"), + asList("3", "2", "1")); assertThat(relationship).isEqualTo(Relationship.UNEQUAL); } @Disabled("Remove to run test") @Test - public void testFirstListMissingAdditionalDigitsFromSecondList() { + @DisplayName("same digits but different numbers") + public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() { Relationship relationship = new RelationshipComputer<>().computeRelationship( - asList(1, 2), - asList(1, 22)); + asList(1, 0, 1), + asList(10, 1)); assertThat(relationship).isEqualTo(Relationship.UNEQUAL); } diff --git a/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/sum-of-multiples/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/sum-of-multiples/gradlew b/exercises/practice/sum-of-multiples/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/sum-of-multiples/gradlew +++ b/exercises/practice/sum-of-multiples/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/sum-of-multiples/gradlew.bat b/exercises/practice/sum-of-multiples/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/sum-of-multiples/gradlew.bat +++ b/exercises/practice/sum-of-multiples/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/sum-of-multiples/src/test/java/SumOfMultiplesTest.java b/exercises/practice/sum-of-multiples/src/test/java/SumOfMultiplesTest.java index c7f7ddfbc..b2736d8bd 100644 --- a/exercises/practice/sum-of-multiples/src/test/java/SumOfMultiplesTest.java +++ b/exercises/practice/sum-of-multiples/src/test/java/SumOfMultiplesTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -6,6 +7,7 @@ public class SumOfMultiplesTest { @Test + @DisplayName("no multiples within limit") public void testNoMultiplesWithinLimit() { int[] set = { @@ -19,6 +21,7 @@ public void testNoMultiplesWithinLimit() { @Disabled("Remove to run test") @Test + @DisplayName("one factor has multiples within limit") public void testOneFactorHasMultiplesWithinLimit() { int[] set = { @@ -32,6 +35,7 @@ public void testOneFactorHasMultiplesWithinLimit() { @Disabled("Remove to run test") @Test + @DisplayName("more than one multiple within limit") public void testMoreThanOneMultipleWithinLimit() { int[] set = { @@ -44,6 +48,7 @@ public void testMoreThanOneMultipleWithinLimit() { @Disabled("Remove to run test") @Test + @DisplayName("more than one factor with multiples within limit") public void testMoreThanOneFactorWithMultiplesWithinLimit() { int[] set = { @@ -57,6 +62,7 @@ public void testMoreThanOneFactorWithMultiplesWithinLimit() { @Disabled("Remove to run test") @Test + @DisplayName("each multiple is only counted once") public void testEachMultipleIsOnlyCountedOnce() { int[] set = { @@ -70,6 +76,7 @@ public void testEachMultipleIsOnlyCountedOnce() { @Disabled("Remove to run test") @Test + @DisplayName("a much larger limit") public void testAMuchLargerLimit() { int[] set = { @@ -83,6 +90,7 @@ public void testAMuchLargerLimit() { @Disabled("Remove to run test") @Test + @DisplayName("three factors") public void testThreeFactors() { int[] set = { @@ -97,6 +105,7 @@ public void testThreeFactors() { @Disabled("Remove to run test") @Test + @DisplayName("factors not relatively prime") public void testFactorsNotRelativelyPrime() { int[] set = { @@ -110,6 +119,7 @@ public void testFactorsNotRelativelyPrime() { @Disabled("Remove to run test") @Test + @DisplayName("some pairs of factors relatively prime and some not") public void testSomePairsOfFactorsRelativelyPrimeAndSomeNot() { int[] set = { @@ -124,6 +134,7 @@ public void testSomePairsOfFactorsRelativelyPrimeAndSomeNot() { @Disabled("Remove to run test") @Test + @DisplayName("one factor is a multiple of another") public void testOneFactorIsAMultipleOfAnother() { int[] set = { @@ -137,6 +148,7 @@ public void testOneFactorIsAMultipleOfAnother() { @Disabled("Remove to run test") @Test + @DisplayName("much larger factors") public void testMuchLargerFactors() { int[] set = { @@ -150,6 +162,7 @@ public void testMuchLargerFactors() { @Disabled("Remove to run test") @Test + @DisplayName("all numbers are multiples of 1") public void testAllNumbersAreMultiplesOf1() { int[] set = { @@ -162,6 +175,7 @@ public void testAllNumbersAreMultiplesOf1() { @Disabled("Remove to run test") @Test + @DisplayName("no factors means an empty sum") public void testNoFactorsMeanAnEmptySum() { int[] set = {}; @@ -172,6 +186,7 @@ public void testNoFactorsMeanAnEmptySum() { @Disabled("Remove to run test") @Test + @DisplayName("the only multiple of 0 is 0") public void testSumOfMultiplesOfZeroIsZero() { int[] set = { @@ -184,6 +199,7 @@ public void testSumOfMultiplesOfZeroIsZero() { @Disabled("Remove to run test") @Test + @DisplayName("the factor 0 does not affect the sum of multiples of other factors") public void testFactorZeroDoesNotAffectTheSumOfMultiplesOfOtherFactors() { int[] set = { @@ -197,6 +213,7 @@ public void testFactorZeroDoesNotAffectTheSumOfMultiplesOfOtherFactors() { @Disabled("Remove to run test") @Test + @DisplayName("solutions using include-exclude must extend to cardinality greater than 3") public void testSolutionsUsingIncludeExcludeMustExtendToCardinalityGreater3() { int[] set = { diff --git a/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/swift-scheduling/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/swift-scheduling/gradlew b/exercises/practice/swift-scheduling/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/swift-scheduling/gradlew +++ b/exercises/practice/swift-scheduling/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/swift-scheduling/gradlew.bat b/exercises/practice/swift-scheduling/gradlew.bat index 93e3f59f1..24c62d56f 100644 --- a/exercises/practice/swift-scheduling/gradlew.bat +++ b/exercises/practice/swift-scheduling/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -43,13 +45,13 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -57,36 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/tournament/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/tournament/gradlew b/exercises/practice/tournament/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/tournament/gradlew +++ b/exercises/practice/tournament/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/tournament/gradlew.bat b/exercises/practice/tournament/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/tournament/gradlew.bat +++ b/exercises/practice/tournament/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/transpose/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/transpose/gradlew b/exercises/practice/transpose/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/transpose/gradlew +++ b/exercises/practice/transpose/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/transpose/gradlew.bat b/exercises/practice/transpose/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/transpose/gradlew.bat +++ b/exercises/practice/transpose/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/transpose/src/test/java/TransposeTest.java b/exercises/practice/transpose/src/test/java/TransposeTest.java index ad8f95f29..8a4b18686 100644 --- a/exercises/practice/transpose/src/test/java/TransposeTest.java +++ b/exercises/practice/transpose/src/test/java/TransposeTest.java @@ -1,6 +1,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeEach; @@ -13,12 +14,14 @@ public void setup() { } @Test + @DisplayName("empty string") public void emptyString() { assertThat(transpose.transpose("")).isEqualTo(""); } @Disabled("Remove to run test") @Test + @DisplayName("two characters in a row") public void twoCharactersInARow() { assertThat(transpose.transpose("A1")) .isEqualTo( @@ -28,6 +31,7 @@ public void twoCharactersInARow() { @Disabled("Remove to run test") @Test + @DisplayName("two characters in a column") public void twoCharactersInAColumn() { assertThat( transpose.transpose( @@ -38,6 +42,7 @@ public void twoCharactersInAColumn() { @Disabled("Remove to run test") @Test + @DisplayName("simple") public void simple() { assertThat( transpose.transpose( @@ -51,6 +56,7 @@ public void simple() { @Disabled("Remove to run test") @Test + @DisplayName("single line") public void singleLine() { assertThat(transpose.transpose("Single line.")) .isEqualTo( @@ -70,6 +76,7 @@ public void singleLine() { @Disabled("Remove to run test") @Test + @DisplayName("first line longer than second line") public void firstLineLongerThanSecondLine() { assertThat( transpose.transpose( @@ -96,6 +103,7 @@ public void firstLineLongerThanSecondLine() { @Disabled("Remove to run test") @Test + @DisplayName("second line longer than first line") public void secondLineLongerThanFirstLine() { assertThat( transpose.transpose( @@ -122,6 +130,7 @@ public void secondLineLongerThanFirstLine() { @Disabled("Remove to run test") @Test + @DisplayName("mixed line length") public void mixedLineLength() { assertThat( transpose.transpose( @@ -151,6 +160,7 @@ public void mixedLineLength() { @Disabled("Remove to run test") @Test + @DisplayName("square") public void square() { assertThat( transpose.transpose( @@ -169,6 +179,7 @@ public void square() { @Disabled("Remove to run test") @Test + @DisplayName("rectangle") public void rectangle() { assertThat( transpose.transpose( @@ -189,6 +200,7 @@ public void rectangle() { @Disabled("Remove to run test") @Test + @DisplayName("triangle") public void triangle() { assertThat( transpose.transpose( @@ -209,6 +221,7 @@ public void triangle() { @Disabled("Remove to run test") @Test + @DisplayName("jagged triangle") public void jaggedTriangle() { assertThat( transpose.transpose( diff --git a/exercises/practice/tree-building/.meta/config.json b/exercises/practice/tree-building/.meta/config.json index 231342712..133865d77 100644 --- a/exercises/practice/tree-building/.meta/config.json +++ b/exercises/practice/tree-building/.meta/config.json @@ -11,7 +11,9 @@ ], "files": { "solution": [ - "src/main/java/BuildTree.java" + "src/main/java/Record.java", + "src/main/java/BuildTree.java", + "src/main/java/TreeNode.java" ], "test": [ "src/test/java/BuildTreeTest.java" @@ -20,9 +22,7 @@ ".meta/src/reference/java/BuildTree.java" ], "editor": [ - "src/main/java/InvalidRecordsException.java", - "src/main/java/Record.java", - "src/main/java/TreeNode.java" + "src/main/java/InvalidRecordsException.java" ], "invalidator": [ "build.gradle" diff --git a/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/tree-building/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/tree-building/gradlew b/exercises/practice/tree-building/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/tree-building/gradlew +++ b/exercises/practice/tree-building/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/tree-building/gradlew.bat b/exercises/practice/tree-building/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/tree-building/gradlew.bat +++ b/exercises/practice/tree-building/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/tree-building/src/test/java/BuildTreeTest.java b/exercises/practice/tree-building/src/test/java/BuildTreeTest.java index c34bb3cc9..e11bc2990 100644 --- a/exercises/practice/tree-building/src/test/java/BuildTreeTest.java +++ b/exercises/practice/tree-building/src/test/java/BuildTreeTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -9,6 +10,7 @@ public class BuildTreeTest { @Test + @DisplayName("Empty list") public void testEmptyList() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); @@ -18,6 +20,7 @@ public void testEmptyList() throws InvalidRecordsException { @Disabled("Remove to run test") @Test + @DisplayName("Single record") public void testOneRecord() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); Record record = new Record(0, 0); @@ -30,6 +33,7 @@ public void testOneRecord() throws InvalidRecordsException { @Disabled("Remove to run test") @Test + @DisplayName("Three records in order") public void testThreeRecordsInOrder() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); records.add(new Record(0, 0)); @@ -48,6 +52,7 @@ public void testThreeRecordsInOrder() throws InvalidRecordsException { @Disabled("Remove to run test") @Test + @DisplayName("Three records in reverse order") public void testThreeRecordsInReverseOrder() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); records.add(new Record(2, 0)); @@ -66,6 +71,7 @@ public void testThreeRecordsInReverseOrder() throws InvalidRecordsException { @Disabled("Remove to run test") @Test + @DisplayName("More than two children") public void testRecordsWithMoreThanTwoChildren() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); records.add(new Record(0, 0)); @@ -83,11 +89,11 @@ public void testRecordsWithMoreThanTwoChildren() throws InvalidRecordsException assertThat(root.getChildren().get(0).getNodeId()).isEqualTo(1); assertThat(root.getChildren().get(1).getNodeId()).isEqualTo(2); assertThat(root.getChildren().get(2).getNodeId()).isEqualTo(3); - } @Disabled("Remove to run test") @Test + @DisplayName("Binary tree") public void testBinaryTree() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); records.add(new Record(6, 2)); @@ -119,6 +125,7 @@ public void testBinaryTree() throws InvalidRecordsException { @Disabled("Remove to run test") @Test + @DisplayName("Unbalanced tree") public void testUnbalancedTree() throws InvalidRecordsException { ArrayList records = new ArrayList<>(); records.add(new Record(0, 0)); @@ -149,6 +156,7 @@ public void testUnbalancedTree() throws InvalidRecordsException { @Disabled("Remove to run test") @Test + @DisplayName("Root has parent") public void testRootNodeHasParent() { ArrayList records = new ArrayList<>(); records.add(new Record(0, 1)); @@ -163,6 +171,7 @@ public void testRootNodeHasParent() { @Disabled("Remove to run test") @Test + @DisplayName("No root node") public void testNoRootNode() { ArrayList records = new ArrayList<>(); records.add(new Record(1, 0)); @@ -177,6 +186,7 @@ public void testNoRootNode() { @Disabled("Remove to run test") @Test + @DisplayName("Non continuous records") public void testNonContinuousRecords() { ArrayList records = new ArrayList<>(); records.add(new Record(2, 0)); @@ -193,6 +203,7 @@ public void testNonContinuousRecords() { @Disabled("Remove to run test") @Test + @DisplayName("Cycle indirectly") public void testCycleIndirectly() { ArrayList records = new ArrayList<>(); records.add(new Record(5, 2)); diff --git a/exercises/practice/triangle/.docs/instructions.md b/exercises/practice/triangle/.docs/instructions.md index 755cb8d19..e9b053dcd 100644 --- a/exercises/practice/triangle/.docs/instructions.md +++ b/exercises/practice/triangle/.docs/instructions.md @@ -14,7 +14,8 @@ A _scalene_ triangle has all sides of different lengths. For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side. ~~~~exercism/note -We opted to not include tests for degenerate triangles (triangles that violate these rules) to keep things simpler. +_Degenerate triangles_ are triangles where the sum of the length of two sides is **equal** to the length of the third side, e.g. `1, 1, 2`. +We opted to not include tests for degenerate triangles in this exercise. You may handle those situations if you wish to do so, or safely ignore them. ~~~~ diff --git a/exercises/practice/triangle/.meta/config.json b/exercises/practice/triangle/.meta/config.json index 1aa400b46..ec8948602 100644 --- a/exercises/practice/triangle/.meta/config.json +++ b/exercises/practice/triangle/.meta/config.json @@ -42,5 +42,5 @@ }, "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", "source": "The Ruby Koans triangle project, parts 1 & 2", - "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" + "source_url": "https://www.rubykoans.com/" } diff --git a/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/triangle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/triangle/gradlew b/exercises/practice/triangle/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/triangle/gradlew +++ b/exercises/practice/triangle/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/triangle/gradlew.bat b/exercises/practice/triangle/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/triangle/gradlew.bat +++ b/exercises/practice/triangle/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/triangle/src/test/java/TriangleTest.java b/exercises/practice/triangle/src/test/java/TriangleTest.java index bd6ad663a..e7dc8f630 100644 --- a/exercises/practice/triangle/src/test/java/TriangleTest.java +++ b/exercises/practice/triangle/src/test/java/TriangleTest.java @@ -3,10 +3,12 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; public class TriangleTest { @Test + @DisplayName("equilateral triangle") public void equilateralTrianglesHaveEqualSides() throws TriangleException { Triangle triangle = new Triangle(2, 2, 2); @@ -15,6 +17,7 @@ public void equilateralTrianglesHaveEqualSides() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("any side is unequal") public void trianglesWithOneUnequalSideAreNotEquilateral() throws TriangleException { Triangle triangle = new Triangle(2, 3, 2); @@ -23,6 +26,7 @@ public void trianglesWithOneUnequalSideAreNotEquilateral() throws TriangleExcept @Disabled("Remove to run test") @Test + @DisplayName("no sides are equal") public void trianglesWithNoEqualSidesAreNotEquilateral() throws TriangleException { Triangle triangle = new Triangle(5, 4, 6); @@ -31,12 +35,14 @@ public void trianglesWithNoEqualSidesAreNotEquilateral() throws TriangleExceptio @Disabled("Remove to run test") @Test + @DisplayName("all zero sides is not a triangle") public void trianglesWithNoSizeAreIllegal() { assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(0, 0, 0)); } @Disabled("Remove to run test") @Test + @DisplayName("sides may be floats") public void verySmallTrianglesCanBeEquilateral() throws TriangleException { Triangle triangle = new Triangle(0.5, 0.5, 0.5); @@ -45,6 +51,7 @@ public void verySmallTrianglesCanBeEquilateral() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("last two sides are equal") public void isoscelesTrianglesHaveLastTwoSidesEqual() throws TriangleException { Triangle triangle = new Triangle(3, 4, 4); @@ -53,6 +60,7 @@ public void isoscelesTrianglesHaveLastTwoSidesEqual() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("first two sides are equal") public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws TriangleException { Triangle triangle = new Triangle(4, 4, 3); @@ -61,6 +69,7 @@ public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws TriangleException @Disabled("Remove to run test") @Test + @DisplayName("first and last sides are equal") public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws TriangleException { Triangle triangle = new Triangle(4, 3, 4); @@ -69,6 +78,7 @@ public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws TriangleExcept @Disabled("Remove to run test") @Test + @DisplayName("equilateral triangles are also isosceles") public void equilateralTrianglesAreAlsoIsosceles() throws TriangleException { Triangle triangle = new Triangle(4, 4, 4); @@ -77,6 +87,7 @@ public void equilateralTrianglesAreAlsoIsosceles() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("no sides are equal") public void noSidesAreEqualCantBeIsoceles() throws TriangleException { Triangle triangle = new Triangle(2, 3, 4); @@ -85,24 +96,28 @@ public void noSidesAreEqualCantBeIsoceles() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("first triangle inequality violation") public void firstTriangleInequalityViolation() { assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(1, 1, 3)); } @Disabled("Remove to run test") @Test + @DisplayName("second triangle inequality violation") public void secondTriangleInequalityViolation() { assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(1, 3, 1)); } @Disabled("Remove to run test") @Test + @DisplayName("third triangle inequality violation") public void thirdTriangleInequalityViolation() { assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(3, 1, 1)); } @Disabled("Remove to run test") @Test + @DisplayName("sides may be floats") public void verySmallTrianglesCanBeIsosceles() throws TriangleException { Triangle triangle = new Triangle(0.5, 0.4, 0.5); @@ -111,6 +126,7 @@ public void verySmallTrianglesCanBeIsosceles() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("no sides are equal") public void scaleneTrianglesHaveNoEqualSides() throws TriangleException { Triangle triangle = new Triangle(5, 4, 6); @@ -119,6 +135,7 @@ public void scaleneTrianglesHaveNoEqualSides() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("all sides are equal") public void allSidesEqualAreNotScalene() throws TriangleException { Triangle triangle = new Triangle(4, 4, 4); @@ -127,6 +144,7 @@ public void allSidesEqualAreNotScalene() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("first and second sides are equal") public void twoSidesEqualAreNotScalene() throws TriangleException { Triangle triangle = new Triangle(4, 4, 3); @@ -135,6 +153,7 @@ public void twoSidesEqualAreNotScalene() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("first and third sides are equal") public void firstAndThirdSidesAreEqualAreNotScalene() throws TriangleException { Triangle triangle = new Triangle(3, 4, 3); @@ -143,6 +162,7 @@ public void firstAndThirdSidesAreEqualAreNotScalene() throws TriangleException { @Disabled("Remove to run test") @Test + @DisplayName("second and third sides are equal") public void secondAndThirdSidesAreEqualAreNotScalene() throws TriangleException { Triangle triangle = new Triangle(4, 3, 3); @@ -151,12 +171,14 @@ public void secondAndThirdSidesAreEqualAreNotScalene() throws TriangleException @Disabled("Remove to run test") @Test + @DisplayName("may not violate triangle inequality") public void mayNotViolateTriangleInequality() { assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(7, 3, 2)); } @Disabled("Remove to run test") @Test + @DisplayName("sides may be floats") public void verySmallTrianglesCanBeScalene() throws TriangleException { Triangle triangle = new Triangle(0.5, 0.4, 0.6); diff --git a/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/twelve-days/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/twelve-days/gradlew b/exercises/practice/twelve-days/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/twelve-days/gradlew +++ b/exercises/practice/twelve-days/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/twelve-days/gradlew.bat b/exercises/practice/twelve-days/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/twelve-days/gradlew.bat +++ b/exercises/practice/twelve-days/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/twelve-days/src/test/java/TwelveDaysTest.java b/exercises/practice/twelve-days/src/test/java/TwelveDaysTest.java index d046235eb..a6827ee51 100644 --- a/exercises/practice/twelve-days/src/test/java/TwelveDaysTest.java +++ b/exercises/practice/twelve-days/src/test/java/TwelveDaysTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -13,6 +14,7 @@ public void setup() { } @Test + @DisplayName("first day a partridge in a pear tree") public void testVerseOne() { String expectedVerseOne = "On the first day of Christmas my true love gave to me: " + "a Partridge in a Pear Tree.\n"; @@ -21,6 +23,7 @@ public void testVerseOne() { @Disabled("Remove to run test") @Test + @DisplayName("second day two turtle doves") public void testVerseTwo() { String expectedVerseTwo = "On the second day of Christmas my true love gave to me: two Turtle Doves, " + "and a Partridge in a Pear Tree.\n"; @@ -29,6 +32,7 @@ public void testVerseTwo() { @Disabled("Remove to run test") @Test + @DisplayName("third day three french hens") public void testVerseThree() { String expectedVerseThree = "On the third day of Christmas my true love gave to me: three French Hens, " + "two Turtle Doves, and a Partridge in a Pear Tree.\n"; @@ -37,6 +41,7 @@ public void testVerseThree() { @Disabled("Remove to run test") @Test + @DisplayName("fourth day four calling birds") public void testVerseFour() { String expectedVerseFour = "On the fourth day of Christmas my true love gave to me: four Calling Birds, " + "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; @@ -45,6 +50,7 @@ public void testVerseFour() { @Disabled("Remove to run test") @Test + @DisplayName("fifth day five gold rings") public void testVerseFive() { String expectedVerseFive = "On the fifth day of Christmas my true love gave to me: five Gold Rings, " + "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; @@ -53,6 +59,7 @@ public void testVerseFive() { @Disabled("Remove to run test") @Test + @DisplayName("sixth day six geese-a-laying") public void testVerseSix() { String expectedVerseSix = "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, " + "five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " + @@ -62,6 +69,7 @@ public void testVerseSix() { @Disabled("Remove to run test") @Test + @DisplayName("seventh day seven swans-a-swimming") public void testVerseSeven() { String expectedVerseSeven = "On the seventh day of Christmas my true love gave to me: " + "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " + @@ -71,6 +79,7 @@ public void testVerseSeven() { @Disabled("Remove to run test") @Test + @DisplayName("eighth day eight maids-a-milking") public void testVerseEight() { String expectedVerseEight = "On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking," + " seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " + @@ -80,6 +89,7 @@ public void testVerseEight() { @Disabled("Remove to run test") @Test + @DisplayName("ninth day nine ladies dancing") public void testVerseNine() { String expectedVerseNine = "On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, " + "eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " + @@ -89,6 +99,7 @@ public void testVerseNine() { @Disabled("Remove to run test") @Test + @DisplayName("tenth day ten lords-a-leaping") public void testVerseTen() { String expectedVerseTen = "On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, " + "nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, " + @@ -99,6 +110,7 @@ public void testVerseTen() { @Disabled("Remove to run test") @Test + @DisplayName("eleventh day eleven pipers piping") public void testVerseEleven() { String expectedVerseEleven = "On the eleventh day of Christmas my true love gave to me: " + "eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " + @@ -109,6 +121,7 @@ public void testVerseEleven() { @Disabled("Remove to run test") @Test + @DisplayName("twelfth day twelve drummers drumming") public void testVerseTwelve() { String expectedVerseTwelve = "On the twelfth day of Christmas my true love gave to me: " + "twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, " + @@ -119,6 +132,7 @@ public void testVerseTwelve() { @Disabled("Remove to run test") @Test + @DisplayName("recites first three verses of the song") public void testFirstThreeVerses() { String expectedVersesOneToThree = "On the first day of Christmas my true love gave to me: " + "a Partridge in a Pear Tree.\n\n" + @@ -131,6 +145,7 @@ public void testFirstThreeVerses() { @Disabled("Remove to run test") @Test + @DisplayName("recites three verses from the middle of the song") public void testFourthToSixthVerses() { String expectedVersesFourToSix = "On the fourth day of Christmas my true love gave to me: " + "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n\n" + @@ -143,6 +158,7 @@ public void testFourthToSixthVerses() { @Disabled("Remove to run test") @Test + @DisplayName("recites the whole song") public void testSingWholeSong() { String expectedSong = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\n" + "\n" + diff --git a/exercises/practice/two-bucket/.meta/config.json b/exercises/practice/two-bucket/.meta/config.json index 4f45ff4a4..57c7007b7 100644 --- a/exercises/practice/two-bucket/.meta/config.json +++ b/exercises/practice/two-bucket/.meta/config.json @@ -14,7 +14,8 @@ "muzimuzhi", "sjwarner-bp", "SleeplessByte", - "sshine" + "sshine", + "Xinri" ], "files": { "solution": [ diff --git a/exercises/practice/two-bucket/.meta/tests.toml b/exercises/practice/two-bucket/.meta/tests.toml index d6ff02f53..a3fe533ec 100644 --- a/exercises/practice/two-bucket/.meta/tests.toml +++ b/exercises/practice/two-bucket/.meta/tests.toml @@ -27,6 +27,12 @@ description = "Measure one step using bucket one of size 1 and bucket two of siz [eb329c63-5540-4735-b30b-97f7f4df0f84] description = "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two" +[58d70152-bf2b-46bb-ad54-be58ebe94c03] +description = "Measure using bucket one much bigger than bucket two" + +[9dbe6499-caa5-4a58-b5ce-c988d71b8981] +description = "Measure using bucket one much smaller than bucket two" + [449be72d-b10a-4f4b-a959-ca741e333b72] description = "Not possible to reach the goal" diff --git a/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/two-bucket/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/two-bucket/gradlew b/exercises/practice/two-bucket/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/two-bucket/gradlew +++ b/exercises/practice/two-bucket/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/two-bucket/gradlew.bat b/exercises/practice/two-bucket/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/two-bucket/gradlew.bat +++ b/exercises/practice/two-bucket/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/two-bucket/src/main/java/TwoBucket.java b/exercises/practice/two-bucket/src/main/java/TwoBucket.java index 5cd0e4d87..1bc771a94 100644 --- a/exercises/practice/two-bucket/src/main/java/TwoBucket.java +++ b/exercises/practice/two-bucket/src/main/java/TwoBucket.java @@ -1,11 +1,11 @@ class TwoBucket { TwoBucket(int bucketOneCap, int bucketTwoCap, int desiredLiters, String startBucket) { - throw new UnsupportedOperationException("Please implement the TwoBucket(int, int, int, String) constructor."); + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); } Result getResult() { - throw new UnsupportedOperationException("Please implement the TwoBucket(int, int, int, String) constructor."); + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); } } diff --git a/exercises/practice/two-bucket/src/test/java/TwoBucketTest.java b/exercises/practice/two-bucket/src/test/java/TwoBucketTest.java index 3564951ab..80d39f0ac 100644 --- a/exercises/practice/two-bucket/src/test/java/TwoBucketTest.java +++ b/exercises/practice/two-bucket/src/test/java/TwoBucketTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -7,6 +8,7 @@ public class TwoBucketTest { @Test + @DisplayName("Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one") public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithOne() { Result bucketResult = new TwoBucket(3, 5, 1, "one").getResult(); @@ -19,6 +21,7 @@ public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithOne() { @Disabled("Remove to run test") @Test + @DisplayName("Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two") public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithTwo() { Result bucketResult = new TwoBucket(3, 5, 1, "two").getResult(); @@ -31,6 +34,7 @@ public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithTwo() { @Disabled("Remove to run test") @Test + @DisplayName("Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one") public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithOne() { Result bucketResult = new TwoBucket(7, 11, 2, "one").getResult(); @@ -43,6 +47,7 @@ public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithOne() { @Disabled("Remove to run test") @Test + @DisplayName("Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two") public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithTwo() { Result bucketResult = new TwoBucket(7, 11, 2, "two").getResult(); @@ -55,6 +60,7 @@ public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithTwo() { @Disabled("Remove to run test") @Test + @DisplayName("Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two") public void testBucketOneSizeOneBucketTwoSizeThreeStartWithTwo() { Result bucketResult = new TwoBucket(1, 3, 3, "two").getResult(); @@ -67,6 +73,10 @@ public void testBucketOneSizeOneBucketTwoSizeThreeStartWithTwo() { @Disabled("Remove to run test") @Test + @DisplayName( + "Measure using bucket one of size 2 and bucket two of size 3 - " + + "start with bucket one and end with bucket two" + ) public void testBucketOneSizeTwoBucketTwoSizeThreeStartWithOne() { Result bucketResult = new TwoBucket(2, 3, 3, "one").getResult(); @@ -79,8 +89,35 @@ public void testBucketOneSizeTwoBucketTwoSizeThreeStartWithOne() { @Disabled("Remove to run test") @Test + @DisplayName("Measure using bucket one much bigger than bucket two") + public void testBucketOneMuchBiggerThanBucketTwo() { + + Result bucketResult = new TwoBucket(5, 1, 2, "one").getResult(); + + assertThat(bucketResult.getTotalMoves()).isEqualTo(6); + assertThat(bucketResult.getFinalBucket()).isEqualTo("one"); + assertThat(bucketResult.getOtherBucket()).isEqualTo(1); + + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Measure using bucket one much smaller than bucket two") + public void testBucketOneMuchSmallerThanBucketTwo() { + + Result bucketResult = new TwoBucket(3, 15, 9, "one").getResult(); + + assertThat(bucketResult.getTotalMoves()).isEqualTo(6); + assertThat(bucketResult.getFinalBucket()).isEqualTo("two"); + assertThat(bucketResult.getOtherBucket()).isEqualTo(0); + + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Not possible to reach the goal") public void testReachingGoalIsImpossible() { - + assertThatExceptionOfType(UnreachableGoalException.class) .isThrownBy(() -> new TwoBucket(6, 15, 5, "one").getResult()); @@ -88,6 +125,7 @@ public void testReachingGoalIsImpossible() { @Disabled("Remove to run test") @Test + @DisplayName("With the same buckets but a different goal, then it is possible") public void testBucketOneSizeSixBucketTwoSizeFifteenStartWithOne() { Result bucketResult = new TwoBucket(6, 15, 9, "one").getResult(); @@ -96,10 +134,11 @@ public void testBucketOneSizeSixBucketTwoSizeFifteenStartWithOne() { assertThat(bucketResult.getFinalBucket()).isEqualTo("two"); assertThat(bucketResult.getOtherBucket()).isEqualTo(0); - } + } @Disabled("Remove to run test") @Test + @DisplayName("Goal larger than both buckets is impossible") public void testGoalLargerThanBothBucketsIsImpossible() { assertThatExceptionOfType(UnreachableGoalException.class) diff --git a/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/two-fer/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/two-fer/gradlew b/exercises/practice/two-fer/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/two-fer/gradlew +++ b/exercises/practice/two-fer/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/two-fer/gradlew.bat b/exercises/practice/two-fer/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/two-fer/gradlew.bat +++ b/exercises/practice/two-fer/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/two-fer/src/test/java/TwoferTest.java b/exercises/practice/two-fer/src/test/java/TwoferTest.java index 67dd68646..3993057d6 100644 --- a/exercises/practice/two-fer/src/test/java/TwoferTest.java +++ b/exercises/practice/two-fer/src/test/java/TwoferTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,6 +15,7 @@ public void setup() { } @Test + @DisplayName("no name given") public void noNameGiven() { assertThat(twofer.twofer(null)) .isEqualTo("One for you, one for me."); @@ -21,6 +23,7 @@ public void noNameGiven() { @Disabled("Remove to run test") @Test + @DisplayName("a name given") public void aNameGiven() { assertThat(twofer.twofer("Alice")) .isEqualTo("One for Alice, one for me."); @@ -28,6 +31,7 @@ public void aNameGiven() { @Disabled("Remove to run test") @Test + @DisplayName("another name given") public void anotherNameGiven() { assertThat(twofer.twofer("Bob")) .isEqualTo("One for Bob, one for me."); diff --git a/exercises/practice/variable-length-quantity/.meta/config.json b/exercises/practice/variable-length-quantity/.meta/config.json index 1949d7e7b..331713ee2 100644 --- a/exercises/practice/variable-length-quantity/.meta/config.json +++ b/exercises/practice/variable-length-quantity/.meta/config.json @@ -12,7 +12,8 @@ "muzimuzhi", "SleeplessByte", "sshine", - "vpondala" + "vpondala", + "Xinri" ], "files": { "solution": [ diff --git a/exercises/practice/variable-length-quantity/.meta/tests.toml b/exercises/practice/variable-length-quantity/.meta/tests.toml index 923fa0c1a..53be789a3 100644 --- a/exercises/practice/variable-length-quantity/.meta/tests.toml +++ b/exercises/practice/variable-length-quantity/.meta/tests.toml @@ -1,81 +1,103 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [35c9db2e-f781-4c52-b73b-8e76427defd0] -description = "zero" +description = "Encode a series of integers, producing a series of bytes. -> zero" [be44d299-a151-4604-a10e-d4b867f41540] -description = "arbitrary single byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte" + +[890bc344-cb80-45af-b316-6806a6971e81] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric single byte" [ea399615-d274-4af6-bbef-a1c23c9e1346] -description = "largest single byte" +description = "Encode a series of integers, producing a series of bytes. -> largest single byte" [77b07086-bd3f-4882-8476-8dcafee79b1c] -description = "smallest double byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest double byte" [63955a49-2690-4e22-a556-0040648d6b2d] -description = "arbitrary double byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte" + +[4977d113-251b-4d10-a3ad-2f5a7756bb58] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric double byte" [29da7031-0067-43d3-83a7-4f14b29ed97a] -description = "largest double byte" +description = "Encode a series of integers, producing a series of bytes. -> largest double byte" [3345d2e3-79a9-4999-869e-d4856e3a8e01] -description = "smallest triple byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest triple byte" [5df0bc2d-2a57-4300-a653-a75ee4bd0bee] -description = "arbitrary triple byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte" + +[6731045f-1e00-4192-b5ae-98b22e17e9f7] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric triple byte" [f51d8539-312d-4db1-945c-250222c6aa22] -description = "largest triple byte" +description = "Encode a series of integers, producing a series of bytes. -> largest triple byte" [da78228b-544f-47b7-8bfe-d16b35bbe570] -description = "smallest quadruple byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest quadruple byte" [11ed3469-a933-46f1-996f-2231e05d7bb6] -description = "arbitrary quadruple byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte" + +[b45ef770-cbba-48c2-bd3c-c6362679516e] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric quadruple byte" [d5f3f3c3-e0f1-4e7f-aad0-18a44f223d1c] -description = "largest quadruple byte" +description = "Encode a series of integers, producing a series of bytes. -> largest quadruple byte" [91a18b33-24e7-4bfb-bbca-eca78ff4fc47] -description = "smallest quintuple byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest quintuple byte" [5f34ff12-2952-4669-95fe-2d11b693d331] -description = "arbitrary quintuple byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte" + +[9be46731-7cd5-415c-b960-48061cbc1154] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte" [7489694b-88c3-4078-9864-6fe802411009] -description = "maximum 32-bit integer input" +description = "Encode a series of integers, producing a series of bytes. -> maximum 32-bit integer input" [f9b91821-cada-4a73-9421-3c81d6ff3661] -description = "two single-byte values" +description = "Encode a series of integers, producing a series of bytes. -> two single-byte values" [68694449-25d2-4974-ba75-fa7bb36db212] -description = "two multi-byte values" +description = "Encode a series of integers, producing a series of bytes. -> two multi-byte values" [51a06b5c-de1b-4487-9a50-9db1b8930d85] -description = "many multi-byte values" +description = "Encode a series of integers, producing a series of bytes. -> many multi-byte values" [baa73993-4514-4915-bac0-f7f585e0e59a] -description = "one byte" +description = "Decode a series of bytes, producing a series of integers. -> one byte" [72e94369-29f9-46f2-8c95-6c5b7a595aee] -description = "two bytes" +description = "Decode a series of bytes, producing a series of integers. -> two bytes" [df5a44c4-56f7-464e-a997-1db5f63ce691] -description = "three bytes" +description = "Decode a series of bytes, producing a series of integers. -> three bytes" [1bb58684-f2dc-450a-8406-1f3452aa1947] -description = "four bytes" +description = "Decode a series of bytes, producing a series of integers. -> four bytes" [cecd5233-49f1-4dd1-a41a-9840a40f09cd] -description = "maximum 32-bit integer" +description = "Decode a series of bytes, producing a series of integers. -> maximum 32-bit integer" [e7d74ba3-8b8e-4bcb-858d-d08302e15695] -description = "incomplete sequence causes error" +description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error" [aa378291-9043-4724-bc53-aca1b4a3fcb6] -description = "incomplete sequence causes error, even if value is zero" +description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error, even if value is zero" [a91e6f5a-c64a-48e3-8a75-ce1a81e0ebee] -description = "multiple values" +description = "Decode a series of bytes, producing a series of integers. -> multiple values" diff --git a/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/variable-length-quantity/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/variable-length-quantity/gradlew b/exercises/practice/variable-length-quantity/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/variable-length-quantity/gradlew +++ b/exercises/practice/variable-length-quantity/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/variable-length-quantity/gradlew.bat b/exercises/practice/variable-length-quantity/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/variable-length-quantity/gradlew.bat +++ b/exercises/practice/variable-length-quantity/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java b/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java index 5b25441e7..5e3059937 100644 --- a/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java +++ b/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -13,6 +14,7 @@ public class VariableLengthQuantityTest { new VariableLengthQuantity(); @Test + @DisplayName("zero") public void testZero() { List expected = Arrays.asList("0x0"); List numbers = Arrays.asList(0x0L); @@ -22,6 +24,7 @@ public void testZero() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary single byte") public void testArbitrarySingleByte() { List expected = Arrays.asList("0x40"); List numbers = Arrays.asList(0x40L); @@ -31,6 +34,17 @@ public void testArbitrarySingleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric single byte") + public void testAsymmetricSingleByte() { + List expected = Arrays.asList("0x53"); + List numbers = Arrays.asList(0x53L); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest single byte") public void testLargestSingleByte() { List expected = Arrays.asList("0x7f"); List numbers = Arrays.asList(0x7fL); @@ -40,6 +54,7 @@ public void testLargestSingleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest double byte") public void testSmallestDoubleByte() { List expected = Arrays.asList("0x81", "0x0"); List numbers = Arrays.asList(0x80L); @@ -49,6 +64,7 @@ public void testSmallestDoubleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary double byte") public void testArbitraryDoubleByte() { List expected = Arrays.asList("0xc0", "0x0"); List numbers = Arrays.asList(0x2000L); @@ -58,6 +74,17 @@ public void testArbitraryDoubleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric double byte") + public void testAsymmetricDoubleByte() { + List expected = Arrays.asList("0x81", "0x2d"); + List numbers = Arrays.asList(0xadL); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest double byte") public void testLargestDoubleByte() { List expected = Arrays.asList("0xff", "0x7f"); List numbers = Arrays.asList(0x3fffL); @@ -67,6 +94,7 @@ public void testLargestDoubleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest triple byte") public void testSmallestTripleByte() { List expected = Arrays.asList("0x81", "0x80", "0x0"); List numbers = Arrays.asList(0x4000L); @@ -76,6 +104,7 @@ public void testSmallestTripleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary triple byte") public void testArbitraryTripleByte() { List expected = Arrays.asList("0xc0", "0x80", "0x0"); List numbers = Arrays.asList(0x100000L); @@ -85,6 +114,17 @@ public void testArbitraryTripleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric triple byte") + public void testAsymmetricTripleByte() { + List expected = Arrays.asList("0x87", "0xab", "0x1c"); + List numbers = Arrays.asList(0x1d59cL); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest triple byte") public void testLargestTripleByte() { List expected = Arrays.asList("0xff", "0xff", "0x7f"); List numbers = Arrays.asList(0x1fffffL); @@ -94,6 +134,7 @@ public void testLargestTripleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest quadruple byte") public void testSmallestQuadrupleByte() { List expected = Arrays.asList("0x81", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0x200000L); @@ -103,6 +144,7 @@ public void testSmallestQuadrupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary quadruple byte") public void testArbitraryQuadrupleByte() { List expected = Arrays.asList("0xc0", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0x8000000L); @@ -112,6 +154,17 @@ public void testArbitraryQuadrupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric quadruple byte") + public void testAsymmetricQuadrupleByte() { + List expected = Arrays.asList("0x81", "0xd5", "0xee", "0x4"); + List numbers = Arrays.asList(0x357704L); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest quadruple byte") public void testLargestQuadrupleByte() { List expected = Arrays.asList("0xff", "0xff", "0xff", "0x7f"); List numbers = Arrays.asList(0xfffffffL); @@ -121,6 +174,7 @@ public void testLargestQuadrupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest quintuple byte") public void testSmallestQuintupleByte() { List expected = Arrays.asList("0x81", "0x80", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0x10000000L); @@ -130,6 +184,7 @@ public void testSmallestQuintupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary quintuple byte") public void testArbitraryQuintupleByte() { List expected = Arrays.asList("0x8f", "0xf8", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0xff000000L); @@ -139,6 +194,17 @@ public void testArbitraryQuintupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric quintuple byte") + public void testAsymmetricQuintupleByte() { + List expected = Arrays.asList("0x88", "0xb3", "0x95", "0xc2", "0x5"); + List numbers = Arrays.asList(0x86656105L); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("maximum 32-bit integer input") public void testMaximum32BitIntegerInput() { List expected = Arrays.asList("0x8f", "0xff", "0xff", "0xff", "0x7f"); List numbers = Arrays.asList(0xffffffffL); @@ -148,6 +214,7 @@ public void testMaximum32BitIntegerInput() { @Disabled("Remove to run test") @Test + @DisplayName("two single-byte values") public void testTwoSingleByteValues() { List expected = Arrays.asList("0x40", "0x7f"); List numbers = Arrays.asList(0x40L, 0x7fL); @@ -157,6 +224,7 @@ public void testTwoSingleByteValues() { @Disabled("Remove to run test") @Test + @DisplayName("two multi-byte values") public void testTwoMultiByteValues() { List expected = Arrays.asList("0x81", "0x80", "0x0", "0xc8", "0xe8", "0x56"); List numbers = Arrays.asList(0x4000L, 0x123456L); @@ -166,6 +234,7 @@ public void testTwoMultiByteValues() { @Disabled("Remove to run test") @Test + @DisplayName("many multi-byte values") public void testManyMultiByteValues() { List expected = Arrays.asList("0xc0", "0x0", "0xc8", "0xe8", "0x56", "0xff", "0xff", "0xff", @@ -179,6 +248,7 @@ public void testManyMultiByteValues() { @Disabled("Remove to run test") @Test + @DisplayName("one byte") public void testDecodeOneByte() { List expected = Arrays.asList("0x7f"); List bytes = Arrays.asList(0x7fL); @@ -188,6 +258,7 @@ public void testDecodeOneByte() { @Disabled("Remove to run test") @Test + @DisplayName("two bytes") public void testDecodeTwoBytes() { List expected = Arrays.asList("0x2000"); List bytes = Arrays.asList(0xc0L, 0x0L); @@ -197,6 +268,7 @@ public void testDecodeTwoBytes() { @Disabled("Remove to run test") @Test + @DisplayName("three bytes") public void testDecodeThreeBytes() { List expected = Arrays.asList("0x1fffff"); List bytes = Arrays.asList(0xffL, 0xffL, 0x7fL); @@ -206,6 +278,7 @@ public void testDecodeThreeBytes() { @Disabled("Remove to run test") @Test + @DisplayName("four bytes") public void testDecodeFourBytes() { List expected = Arrays.asList("0x200000"); List bytes = Arrays.asList(0x81L, 0x80L, 0x80L, 0x0L); @@ -215,6 +288,7 @@ public void testDecodeFourBytes() { @Disabled("Remove to run test") @Test + @DisplayName("maximum 32-bit integer") public void testDecodeMaximum32BitInteger() { List expected = Arrays.asList("0xffffffff"); List bytes = Arrays.asList(0x8fL, 0xffL, 0xffL, 0xffL, 0x7fL); @@ -224,6 +298,7 @@ public void testDecodeMaximum32BitInteger() { @Disabled("Remove to run test") @Test + @DisplayName("incomplete sequence causes error") public void testCannotDecodeIncompleteSequence() { List bytes = Arrays.asList(0xffL); @@ -234,6 +309,7 @@ public void testCannotDecodeIncompleteSequence() { @Disabled("Remove to run test") @Test + @DisplayName("incomplete sequence causes error, even if value is zero") public void testCannotDecodeIncompleteSequenceEvenIfValueIsZero() { List bytes = Arrays.asList(0x80L); @@ -244,6 +320,7 @@ public void testCannotDecodeIncompleteSequenceEvenIfValueIsZero() { @Disabled("Remove to run test") @Test + @DisplayName("multiple values") public void testDecodeMultipleBytes() { List expected = Arrays.asList("0x2000", "0x123456", "0xfffffff", "0x0", "0x3fff", diff --git a/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/word-count/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/word-count/gradlew b/exercises/practice/word-count/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/word-count/gradlew +++ b/exercises/practice/word-count/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/word-count/gradlew.bat b/exercises/practice/word-count/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/word-count/gradlew.bat +++ b/exercises/practice/word-count/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/word-count/src/test/java/WordCountTest.java b/exercises/practice/word-count/src/test/java/WordCountTest.java index bd5f70fdb..0c2cd4e01 100644 --- a/exercises/practice/word-count/src/test/java/WordCountTest.java +++ b/exercises/practice/word-count/src/test/java/WordCountTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -21,6 +22,7 @@ public void setup() { @Test + @DisplayName("count one word") public void countOneWord() { expectedWordCount.put("word", 1); @@ -30,6 +32,7 @@ public void countOneWord() { @Disabled("Remove to run test") @Test + @DisplayName("count one of each word") public void countOneOfEachWord() { expectedWordCount.put("one", 1); expectedWordCount.put("of", 1); @@ -41,6 +44,7 @@ public void countOneOfEachWord() { @Disabled("Remove to run test") @Test + @DisplayName("multiple occurrences of a word") public void multipleOccurrencesOfAWord() { expectedWordCount.put("one", 1); expectedWordCount.put("fish", 4); @@ -54,6 +58,7 @@ public void multipleOccurrencesOfAWord() { @Disabled("Remove to run test") @Test + @DisplayName("handles cramped lists") public void handlesCrampedLists() { expectedWordCount.put("one", 1); expectedWordCount.put("two", 1); @@ -65,6 +70,7 @@ public void handlesCrampedLists() { @Disabled("Remove to run test") @Test + @DisplayName("handles expanded lists") public void handlesExpandedLists() { expectedWordCount.put("one", 1); expectedWordCount.put("two", 1); @@ -76,6 +82,7 @@ public void handlesExpandedLists() { @Disabled("Remove to run test") @Test + @DisplayName("ignore punctuation") public void ignorePunctuation() { expectedWordCount.put("car", 1); expectedWordCount.put("carpet", 1); @@ -90,6 +97,7 @@ public void ignorePunctuation() { @Disabled("Remove to run test") @Test + @DisplayName("include numbers") public void includeNumbers() { expectedWordCount.put("testing", 2); expectedWordCount.put("1", 1); @@ -101,6 +109,7 @@ public void includeNumbers() { @Disabled("Remove to run test") @Test + @DisplayName("normalize case") public void normalizeCase() { expectedWordCount.put("go", 3); expectedWordCount.put("stop", 2); @@ -111,6 +120,7 @@ public void normalizeCase() { @Disabled("Remove to run test") @Test + @DisplayName("with apostrophes") public void withApostrophes() { expectedWordCount.put("first", 1); expectedWordCount.put("don't", 2); @@ -127,36 +137,39 @@ public void withApostrophes() { @Disabled("Remove to run test") @Test - public void substringsFromTheBeginning() { + @DisplayName("with quotations") + public void withQuotations() { expectedWordCount.put("joe", 1); expectedWordCount.put("can't", 1); expectedWordCount.put("tell", 1); expectedWordCount.put("between", 1); - expectedWordCount.put("app", 1); - expectedWordCount.put("apple", 1); + expectedWordCount.put("large", 2); expectedWordCount.put("and", 1); - expectedWordCount.put("a", 1); - actualWordCount = wordCount.phrase("Joe can't tell between app, apple and a."); + actualWordCount = wordCount.phrase("Joe can't tell between 'large' and large."); assertThat(actualWordCount).isEqualTo(expectedWordCount); } @Disabled("Remove to run test") @Test - public void withQuotations() { + @DisplayName("substrings from the beginning") + public void substringsFromTheBeginning() { expectedWordCount.put("joe", 1); expectedWordCount.put("can't", 1); expectedWordCount.put("tell", 1); expectedWordCount.put("between", 1); - expectedWordCount.put("large", 2); + expectedWordCount.put("app", 1); + expectedWordCount.put("apple", 1); expectedWordCount.put("and", 1); + expectedWordCount.put("a", 1); - actualWordCount = wordCount.phrase("Joe can't tell between 'large' and large."); + actualWordCount = wordCount.phrase("Joe can't tell between app, apple and a."); assertThat(actualWordCount).isEqualTo(expectedWordCount); } @Disabled("Remove to run test") @Test + @DisplayName("multiple spaces not detected as a word") public void multipleSpacesNotDetectedAsAWord() { expectedWordCount.put("multiple", 1); expectedWordCount.put("whitespaces", 1); @@ -167,6 +180,7 @@ public void multipleSpacesNotDetectedAsAWord() { @Disabled("Remove to run test") @Test + @DisplayName("alternating word separators not detected as a word") public void alternatingWordSeperatorsNotDetectedAsAWord() { expectedWordCount.put("one", 1); expectedWordCount.put("two", 1); @@ -178,6 +192,7 @@ public void alternatingWordSeperatorsNotDetectedAsAWord() { @Disabled("Remove to run test") @Test + @DisplayName("quotation for word with apostrophe") public void quotationForWordWithApostrophe() { expectedWordCount.put("can", 1); expectedWordCount.put("can't", 2); diff --git a/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/word-search/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/word-search/gradlew b/exercises/practice/word-search/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/word-search/gradlew +++ b/exercises/practice/word-search/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/word-search/gradlew.bat b/exercises/practice/word-search/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/word-search/gradlew.bat +++ b/exercises/practice/word-search/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/word-search/src/test/java/WordSearcherTest.java b/exercises/practice/word-search/src/test/java/WordSearcherTest.java index 8460366c5..3a7d9291e 100644 --- a/exercises/practice/word-search/src/test/java/WordSearcherTest.java +++ b/exercises/practice/word-search/src/test/java/WordSearcherTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -19,6 +20,7 @@ public void setUp() { } @Test + @DisplayName("Should accept an initial game grid and a target search word") public void testAcceptsInitialGridAndTargetWord() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.empty()); @@ -37,6 +39,7 @@ public void testAcceptsInitialGridAndTargetWord() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate one word written left to right") public void testLocatesOneWordWrittenLeftToRight() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 1), new Pair(7, 1)))); @@ -55,6 +58,7 @@ public void testLocatesOneWordWrittenLeftToRight() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate the same word written left to right in a different position") public void testShouldLocateTheSameWordLeftToRightInDifferentPosition() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(3, 1), new Pair(9, 1)))); @@ -73,6 +77,7 @@ public void testShouldLocateTheSameWordLeftToRightInDifferentPosition() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate a different left to right word") public void testShouldLocateADifferentLeftToRightWord() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("coffee", Optional.of(new WordLocation(new Pair(1, 1), new Pair(6, 1)))); @@ -91,6 +96,7 @@ public void testShouldLocateADifferentLeftToRightWord() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate that different left to right word in a different position") public void testShouldLocateThatDifferentLeftToRightWordInADifferentPosition() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("coffee", Optional.of(new WordLocation(new Pair(2, 1), new Pair(7, 1)))); @@ -109,6 +115,7 @@ public void testShouldLocateThatDifferentLeftToRightWordInADifferentPosition() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate a left to right word in two line grid") public void testShouldLocateLeftToRightWordInTwoLineGrid() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(2, 2), new Pair(8, 2)))); @@ -128,6 +135,7 @@ public void testShouldLocateLeftToRightWordInTwoLineGrid() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate a left to right word in three line grid") public void testShouldLocateLeftToRightWordInThreeLineGrid() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 3), new Pair(7, 3)))); @@ -148,6 +156,7 @@ public void testShouldLocateLeftToRightWordInThreeLineGrid() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate a left to right word in ten line grid") public void testLocatesWordWrittenLeftToRightInTenLineGrid() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -175,6 +184,7 @@ public void testLocatesWordWrittenLeftToRightInTenLineGrid() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate that left to right word in a different position in a ten line grid") public void testLocatesSameWordWrittenLeftToRightInDifferentTenLineGrid() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 9), new Pair(7, 9)))); @@ -202,6 +212,7 @@ public void testLocatesSameWordWrittenLeftToRightInDifferentTenLineGrid() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate a different left to right word in a ten line grid") public void testLocatesDifferentWordWrittenLeftToRightInTenLineGrid() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("fortran", Optional.of(new WordLocation(new Pair(1, 7), new Pair(7, 7)))); @@ -229,6 +240,7 @@ public void testLocatesDifferentWordWrittenLeftToRightInTenLineGrid() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate multiple words") public void testShouldLocateMultipleWords() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("fortran", Optional.of(new WordLocation(new Pair(1, 7), new Pair(7, 7)))); @@ -257,6 +269,7 @@ public void testShouldLocateMultipleWords() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate a single word written right to left") public void testShouldLocateASingleWordRightToLeft() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("elixir", Optional.of(new WordLocation(new Pair(6, 1), new Pair(1, 1)))); @@ -275,6 +288,7 @@ public void testShouldLocateASingleWordRightToLeft() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate multiple words written in different horizontal directions") public void testShouldLocateMultipleWordsWrittenInDifferentHorizontalDirections() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("elixir", Optional.of(new WordLocation(new Pair(6, 5), new Pair(1, 5)))); @@ -303,6 +317,7 @@ public void testShouldLocateMultipleWordsWrittenInDifferentHorizontalDirections( @Disabled("Remove to run test") @Test + @DisplayName("Should locate words written top to bottom") public void testLocatesWordsWrittenTopToBottom() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -332,6 +347,7 @@ public void testLocatesWordsWrittenTopToBottom() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate words written bottom to top") public void testLocatesWordsWrittenBottomToTop() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -360,6 +376,7 @@ public void testLocatesWordsWrittenBottomToTop() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate words written top left to bottom right") public void testLocatesWordsWrittenTopLeftToBottomRight() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -389,6 +406,7 @@ public void testLocatesWordsWrittenTopLeftToBottomRight() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate words written bottom right to top left") public void testLocatesWordsWrittenBottomRightToTopLeft() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -419,6 +437,7 @@ public void testLocatesWordsWrittenBottomRightToTopLeft() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate words written bottom left to top right") public void testLocatesWordsWrittenBottomLeftToTopRight() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -450,6 +469,7 @@ public void testLocatesWordsWrittenBottomLeftToTopRight() { @Disabled("Remove to run test") @Test + @DisplayName("Should locate words written top right to bottom left") public void testLocatesWordsWrittenTopRightToBottomLeft() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -482,6 +502,7 @@ public void testLocatesWordsWrittenTopRightToBottomLeft() { @Disabled("Remove to run test") @Test + @DisplayName("Should fail to locate a word that is not in the puzzle") public void testFailsToLocateAWordsThatIsNotInThePuzzle() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10)))); @@ -515,6 +536,7 @@ public void testFailsToLocateAWordsThatIsNotInThePuzzle() { @Disabled("Remove to run test") @Test + @DisplayName("Should fail to locate words that are not on horizontal, vertical, or diagonal lines") public void testFailToLocateWordsThatAreNotOnHorizontalVerticalOrDiagonalLines() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("aef", Optional.empty()); @@ -535,6 +557,7 @@ public void testFailToLocateWordsThatAreNotOnHorizontalVerticalOrDiagonalLines() @Disabled("Remove to run test") @Test + @DisplayName("Should not concatenate different lines to find a horizontal word") public void testNotConcatenateDifferentLinesToFindAHorizontalWord() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("elixir", Optional.empty()); @@ -552,6 +575,7 @@ public void testNotConcatenateDifferentLinesToFindAHorizontalWord() { @Disabled("Remove to run test") @Test + @DisplayName("Should not wrap around horizontally to find a word") public void testNotWrapAroundHorizontallyToFindAWord() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("lisp", Optional.empty()); @@ -570,6 +594,7 @@ public void testNotWrapAroundHorizontallyToFindAWord() { @Disabled("Remove to run test") @Test + @DisplayName("Should not wrap around vertically to find a word") public void testNotWrapAroundVerticallyToFindAWord() { Map> expectedLocations = new HashMap<>(); expectedLocations.put("rust", Optional.empty()); diff --git a/exercises/practice/wordy/.meta/config.json b/exercises/practice/wordy/.meta/config.json index 2e6e383fd..78f4c3f91 100644 --- a/exercises/practice/wordy/.meta/config.json +++ b/exercises/practice/wordy/.meta/config.json @@ -21,6 +21,7 @@ "vasouv", "vivshaw", "vpondala", + "Xinri", "Zaldrick" ], "files": { diff --git a/exercises/practice/wordy/.meta/tests.toml b/exercises/practice/wordy/.meta/tests.toml index 912d57600..a0a83ed0b 100644 --- a/exercises/practice/wordy/.meta/tests.toml +++ b/exercises/practice/wordy/.meta/tests.toml @@ -1,13 +1,32 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [88bf4b28-0de3-4883-93c7-db1b14aa806e] description = "just a number" +[18983214-1dfc-4ebd-ac77-c110dde699ce] +description = "just a zero" + +[607c08ee-2241-4288-916d-dae5455c87e6] +description = "just a negative number" + [bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0] description = "addition" +[bb9f2082-171c-46ad-ad4e-c3f72087c1b5] +description = "addition with a left hand zero" + +[6fa05f17-405a-4742-80ae-5d1a8edb0d5d] +description = "addition with a right hand zero" + [79e49e06-c5ae-40aa-a352-7a3a01f70015] description = "more addition" diff --git a/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/wordy/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/wordy/gradlew b/exercises/practice/wordy/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/wordy/gradlew +++ b/exercises/practice/wordy/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/wordy/gradlew.bat b/exercises/practice/wordy/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/wordy/gradlew.bat +++ b/exercises/practice/wordy/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java b/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java index 70f0a1c30..79c4a1d41 100644 --- a/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java +++ b/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -9,129 +10,175 @@ public class WordProblemSolverTest { WordProblemSolver solver = new WordProblemSolver(); @Test + @DisplayName("just a number") public void testJustANumber() { assertThat(solver.solve("What is 5?")).isEqualTo(5); } + @Test + @DisplayName("just a zero") + public void testJustAZero() { + assertThat(solver.solve("What is 0?")).isEqualTo(0); + } + + @Test + @DisplayName("just a negative number") + public void testJustANegativeNumber() { + assertThat(solver.solve("What is -123?")).isEqualTo(-123); + } + @Disabled("Remove to run test") @Test + @DisplayName("addition") public void testSingleAddition1() { assertThat(solver.solve("What is 1 plus 1?")).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("addition with a left hand zero") + public void testAdditionWithALeftHandZero() { + assertThat(solver.solve("What is 0 plus 2?")).isEqualTo(2); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("addition with a right hand zero") + public void testAdditionWithARightHandZero() { + assertThat(solver.solve("What is 3 plus 0?")).isEqualTo(3); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("more addition") public void testSingleAddition2() { assertThat(solver.solve("What is 53 plus 2?")).isEqualTo(55); } @Disabled("Remove to run test") @Test + @DisplayName("addition with negative numbers") public void testSingleAdditionWithNegativeNumbers() { assertThat(solver.solve("What is -1 plus -10?")).isEqualTo(-11); } @Disabled("Remove to run test") @Test + @DisplayName("large addition") public void testSingleAdditionOfLargeNumbers() { assertThat(solver.solve("What is 123 plus 45678?")).isEqualTo(45801); } @Disabled("Remove to run test") @Test + @DisplayName("subtraction") public void testSingleSubtraction() { assertThat(solver.solve("What is 4 minus -12?")).isEqualTo(16); } @Disabled("Remove to run test") @Test + @DisplayName("multiplication") public void testSingleMultiplication() { assertThat(solver.solve("What is -3 multiplied by 25?")).isEqualTo(-75); } @Disabled("Remove to run test") @Test + @DisplayName("division") public void testSingleDivision() { assertThat(solver.solve("What is 33 divided by -3?")).isEqualTo(-11); } @Disabled("Remove to run test") @Test + @DisplayName("multiple additions") public void testMultipleAdditions() { assertThat(solver.solve("What is 1 plus 1 plus 1?")).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("addition and subtraction") public void testAdditionThenSubtraction() { assertThat(solver.solve("What is 1 plus 5 minus -2?")).isEqualTo(8); } @Disabled("Remove to run test") @Test + @DisplayName("multiple subtraction") public void testMultipleSubtractions() { assertThat(solver.solve("What is 20 minus 4 minus 13?")).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("subtraction then addition") public void testSubtractionThenAddition() { assertThat(solver.solve("What is 17 minus 6 plus 3?")).isEqualTo(14); } @Disabled("Remove to run test") @Test + @DisplayName("multiple multiplication") public void testMultipleMultiplications() { assertThat(solver.solve("What is 2 multiplied by -2 multiplied by 3?")).isEqualTo(-12); } @Disabled("Remove to run test") @Test + @DisplayName("addition and multiplication") public void testAdditionThenMultiplication() { assertThat(solver.solve("What is -3 plus 7 multiplied by -2?")).isEqualTo(-8); } @Disabled("Remove to run test") @Test + @DisplayName("multiple division") public void testMultipleDivisions() { assertThat(solver.solve("What is -12 divided by 2 divided by -3?")).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("unknown operation") public void testUnknownOperation() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("What is 52 cubed?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("What is 52 cubed?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("Non math question") public void testNonMathQuestion() { // See https://en.wikipedia.org/wiki/President_of_the_United_States if you really need to know! assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("Who is the President of the United States?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("Who is the President of the United States?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("reject problem missing an operand") public void testMissingAnOperand() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("What is 1 plus?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("What is 1 plus?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("reject problem with no operands or operator") public void testNoOperandsOrOperators() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("What is?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("What is?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("reject two operations in a row") public void testTwoOperationsInARow() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is 1 plus plus 2?")) @@ -140,6 +187,7 @@ public void testTwoOperationsInARow() { @Disabled("Remove to run test") @Test + @DisplayName("reject two numbers in a row") public void testTwoNumbersAfterOperation() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is 1 plus 2 1?")) @@ -148,6 +196,7 @@ public void testTwoNumbersAfterOperation() { @Disabled("Remove to run test") @Test + @DisplayName("reject postfix notation") public void testPostfixNotation() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is 1 2 plus?")) @@ -156,6 +205,7 @@ public void testPostfixNotation() { @Disabled("Remove to run test") @Test + @DisplayName("reject prefix notation") public void testPrefixNotation() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is plus 1 2?")) diff --git a/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/yacht/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/yacht/gradlew b/exercises/practice/yacht/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/yacht/gradlew +++ b/exercises/practice/yacht/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/yacht/gradlew.bat b/exercises/practice/yacht/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/yacht/gradlew.bat +++ b/exercises/practice/yacht/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/yacht/src/test/java/YachtTest.java b/exercises/practice/yacht/src/test/java/YachtTest.java index b2792817b..2a5e873e6 100644 --- a/exercises/practice/yacht/src/test/java/YachtTest.java +++ b/exercises/practice/yacht/src/test/java/YachtTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -6,6 +7,7 @@ public class YachtTest { @Test + @DisplayName("Yacht") public void yacht() { Yacht yacht = new Yacht(new int[]{ 5, 5, 5, 5, 5 }, YachtCategory.YACHT); assertThat(yacht.score()).isEqualTo(50); @@ -13,6 +15,7 @@ public void yacht() { @Disabled("Remove to run test") @Test + @DisplayName("Not Yacht") public void notYacht() { Yacht yacht = new Yacht(new int[]{ 1, 3, 3, 2, 5 }, YachtCategory.YACHT); assertThat(yacht.score()).isEqualTo(0); @@ -20,6 +23,7 @@ public void notYacht() { @Disabled("Remove to run test") @Test + @DisplayName("Ones") public void ones() { Yacht yacht = new Yacht(new int[]{ 1, 1, 1, 3, 5 }, YachtCategory.ONES); assertThat(yacht.score()).isEqualTo(3); @@ -27,6 +31,7 @@ public void ones() { @Disabled("Remove to run test") @Test + @DisplayName("Ones, out of order") public void onesOutOfOrder() { Yacht yacht = new Yacht(new int[]{ 3, 1, 1, 5, 1 }, YachtCategory.ONES); assertThat(yacht.score()).isEqualTo(3); @@ -34,6 +39,7 @@ public void onesOutOfOrder() { @Disabled("Remove to run test") @Test + @DisplayName("No ones") public void noOnes() { Yacht yacht = new Yacht(new int[]{ 4, 3, 6, 5, 5 }, YachtCategory.ONES); assertThat(yacht.score()).isEqualTo(0); @@ -41,6 +47,7 @@ public void noOnes() { @Disabled("Remove to run test") @Test + @DisplayName("Twos") public void twos() { Yacht yacht = new Yacht(new int[]{ 2, 3, 4, 5, 6 }, YachtCategory.TWOS); assertThat(yacht.score()).isEqualTo(2); @@ -48,6 +55,7 @@ public void twos() { @Disabled("Remove to run test") @Test + @DisplayName("Fours") public void fours() { Yacht yacht = new Yacht(new int[]{ 1, 4, 1, 4, 1 }, YachtCategory.FOURS); assertThat(yacht.score()).isEqualTo(8); @@ -55,6 +63,7 @@ public void fours() { @Disabled("Remove to run test") @Test + @DisplayName("Yacht counted as threes") public void yachtCountedAsThrees() { Yacht yacht = new Yacht(new int[]{ 3, 3, 3, 3, 3 }, YachtCategory.THREES); assertThat(yacht.score()).isEqualTo(15); @@ -62,6 +71,7 @@ public void yachtCountedAsThrees() { @Disabled("Remove to run test") @Test + @DisplayName("Yacht of 3s counted as fives") public void yachtOfThreesCountedAsFives() { Yacht yacht = new Yacht(new int[]{ 3, 3, 3, 3, 3 }, YachtCategory.FIVES); assertThat(yacht.score()).isEqualTo(0); @@ -69,6 +79,7 @@ public void yachtOfThreesCountedAsFives() { @Disabled("Remove to run test") @Test + @DisplayName("Fives") public void fives() { Yacht yacht = new Yacht(new int[]{ 1, 5, 3, 5, 3 }, YachtCategory.FIVES); assertThat(yacht.score()).isEqualTo(10); @@ -76,6 +87,7 @@ public void fives() { @Disabled("Remove to run test") @Test + @DisplayName("Sixes") public void sixes() { Yacht yacht = new Yacht(new int[]{ 2, 3, 4, 5, 6 }, YachtCategory.SIXES); assertThat(yacht.score()).isEqualTo(6); @@ -83,6 +95,7 @@ public void sixes() { @Disabled("Remove to run test") @Test + @DisplayName("Full house two small, three big") public void fullHouseTwoSmallThreeBig() { Yacht yacht = new Yacht(new int[]{ 2, 2, 4, 4, 4 }, YachtCategory.FULL_HOUSE); assertThat(yacht.score()).isEqualTo(16); @@ -90,6 +103,7 @@ public void fullHouseTwoSmallThreeBig() { @Disabled("Remove to run test") @Test + @DisplayName("Full house three small, two big") public void fullHouseThreeSmallTwoBig() { Yacht yacht = new Yacht(new int[]{ 5, 3, 3, 5, 3 }, YachtCategory.FULL_HOUSE); assertThat(yacht.score()).isEqualTo(19); @@ -97,6 +111,7 @@ public void fullHouseThreeSmallTwoBig() { @Disabled("Remove to run test") @Test + @DisplayName("Two pair is not a full house") public void twoPairIsNotAFullHouse() { Yacht yacht = new Yacht(new int[]{ 2, 2, 4, 4, 5 }, YachtCategory.FULL_HOUSE); assertThat(yacht.score()).isEqualTo(0); @@ -104,6 +119,7 @@ public void twoPairIsNotAFullHouse() { @Disabled("Remove to run test") @Test + @DisplayName("Four of a kind is not a full house") public void fourOfAKindIsNotAFullHouse() { Yacht yacht = new Yacht(new int[]{ 1, 4, 4, 4, 4 }, YachtCategory.FULL_HOUSE); assertThat(yacht.score()).isEqualTo(0); @@ -111,6 +127,7 @@ public void fourOfAKindIsNotAFullHouse() { @Disabled("Remove to run test") @Test + @DisplayName("Yacht is not a full house") public void yachtIsNotAFullHouse() { Yacht yacht = new Yacht(new int[]{ 2, 2, 2, 2, 2 }, YachtCategory.FULL_HOUSE); assertThat(yacht.score()).isEqualTo(0); @@ -118,6 +135,7 @@ public void yachtIsNotAFullHouse() { @Disabled("Remove to run test") @Test + @DisplayName("Four of a Kind") public void fourOfAKind() { Yacht yacht = new Yacht(new int[]{ 6, 6, 4, 6, 6 }, YachtCategory.FOUR_OF_A_KIND); assertThat(yacht.score()).isEqualTo(24); @@ -125,6 +143,7 @@ public void fourOfAKind() { @Disabled("Remove to run test") @Test + @DisplayName("Yacht can be scored as Four of a Kind") public void yachtCanBeScoredAsFourOfAKind() { Yacht yacht = new Yacht(new int[]{ 3, 3, 3, 3, 3 }, YachtCategory.FOUR_OF_A_KIND); assertThat(yacht.score()).isEqualTo(12); @@ -132,6 +151,7 @@ public void yachtCanBeScoredAsFourOfAKind() { @Disabled("Remove to run test") @Test + @DisplayName("Full house is not Four of a Kind") public void fullHouseIsNotFourOfAKind() { Yacht yacht = new Yacht(new int[]{ 3, 3, 3, 5, 5 }, YachtCategory.FOUR_OF_A_KIND); assertThat(yacht.score()).isEqualTo(0); @@ -139,6 +159,7 @@ public void fullHouseIsNotFourOfAKind() { @Disabled("Remove to run test") @Test + @DisplayName("Little Straight") public void littleStraight() { Yacht yacht = new Yacht(new int[]{ 3, 5, 4, 1, 2 }, YachtCategory.LITTLE_STRAIGHT); assertThat(yacht.score()).isEqualTo(30); @@ -146,6 +167,7 @@ public void littleStraight() { @Disabled("Remove to run test") @Test + @DisplayName("Little Straight as Big Straight") public void littleStraightAsBigStraight() { Yacht yacht = new Yacht(new int[]{ 1, 2, 3, 4, 5 }, YachtCategory.BIG_STRAIGHT); assertThat(yacht.score()).isEqualTo(0); @@ -153,6 +175,7 @@ public void littleStraightAsBigStraight() { @Disabled("Remove to run test") @Test + @DisplayName("Four in order but not a little straight") public void fourInOrderButNotALittleStraight() { Yacht yacht = new Yacht(new int[]{ 1, 1, 2, 3, 4 }, YachtCategory.LITTLE_STRAIGHT); assertThat(yacht.score()).isEqualTo(0); @@ -160,6 +183,7 @@ public void fourInOrderButNotALittleStraight() { @Disabled("Remove to run test") @Test + @DisplayName("No pairs but not a little straight") public void noPairsButNotALittleStraight() { Yacht yacht = new Yacht(new int[]{ 1, 2, 3, 4, 6 }, YachtCategory.LITTLE_STRAIGHT); assertThat(yacht.score()).isEqualTo(0); @@ -167,6 +191,7 @@ public void noPairsButNotALittleStraight() { @Disabled("Remove to run test") @Test + @DisplayName("Minimum is 1, maximum is 5, but not a little straight") public void minimumIs1MaximumIs5ButNotALittleStraight() { Yacht yacht = new Yacht(new int[]{ 1, 1, 3, 4, 5 }, YachtCategory.LITTLE_STRAIGHT); assertThat(yacht.score()).isEqualTo(0); @@ -174,6 +199,7 @@ public void minimumIs1MaximumIs5ButNotALittleStraight() { @Disabled("Remove to run test") @Test + @DisplayName("Big Straight") public void bigStraight() { Yacht yacht = new Yacht(new int[]{ 4, 6, 2, 5, 3 }, YachtCategory.BIG_STRAIGHT); assertThat(yacht.score()).isEqualTo(30); @@ -181,6 +207,7 @@ public void bigStraight() { @Disabled("Remove to run test") @Test + @DisplayName("Big Straight as little straight") public void bigStraightAsLittleStraight() { Yacht yacht = new Yacht(new int[]{ 6, 5, 4, 3, 2 }, YachtCategory.LITTLE_STRAIGHT); assertThat(yacht.score()).isEqualTo(0); @@ -188,6 +215,7 @@ public void bigStraightAsLittleStraight() { @Disabled("Remove to run test") @Test + @DisplayName("No pairs but not a big straight") public void noPairsButNotABigStraight() { Yacht yacht = new Yacht(new int[]{ 6, 5, 4, 3, 1 }, YachtCategory.BIG_STRAIGHT); assertThat(yacht.score()).isEqualTo(0); @@ -195,6 +223,7 @@ public void noPairsButNotABigStraight() { @Disabled("Remove to run test") @Test + @DisplayName("Choice") public void choice() { Yacht yacht = new Yacht(new int[]{ 3, 3, 5, 6, 6 }, YachtCategory.CHOICE); assertThat(yacht.score()).isEqualTo(23); @@ -202,6 +231,7 @@ public void choice() { @Disabled("Remove to run test") @Test + @DisplayName("Yacht as choice") public void yachtAsChoice() { Yacht yacht = new Yacht(new int[]{ 2, 2, 2, 2, 2 }, YachtCategory.CHOICE); assertThat(yacht.score()).isEqualTo(10); diff --git a/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/zebra-puzzle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/zebra-puzzle/gradlew b/exercises/practice/zebra-puzzle/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/zebra-puzzle/gradlew +++ b/exercises/practice/zebra-puzzle/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/zebra-puzzle/gradlew.bat b/exercises/practice/zebra-puzzle/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/zebra-puzzle/gradlew.bat +++ b/exercises/practice/zebra-puzzle/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/zebra-puzzle/src/test/java/ZebraPuzzleTest.java b/exercises/practice/zebra-puzzle/src/test/java/ZebraPuzzleTest.java index 911ebae5c..b0bb118fe 100644 --- a/exercises/practice/zebra-puzzle/src/test/java/ZebraPuzzleTest.java +++ b/exercises/practice/zebra-puzzle/src/test/java/ZebraPuzzleTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -6,6 +7,7 @@ public class ZebraPuzzleTest { @Test + @DisplayName("resident who drinks water") public void residentWhoDrinksWater() { ZebraPuzzle zebraPuzzle = new ZebraPuzzle(); assertThat(zebraPuzzle.getWaterDrinker()).isEqualTo("Norwegian"); @@ -13,6 +15,7 @@ public void residentWhoDrinksWater() { @Disabled("Remove to run test") @Test + @DisplayName("resident who owns zebra") public void residentWhoOwnsZebra() { ZebraPuzzle zebraPuzzle = new ZebraPuzzle(); assertThat(zebraPuzzle.getZebraOwner()).isEqualTo("Japanese"); diff --git a/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.jar index e6441136f..b1b8ef56b 100644 Binary files a/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.jar and b/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.properties index 2deab89d5..6394b4647 100644 --- a/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.properties +++ b/exercises/practice/zipper/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/exercises/practice/zipper/gradlew b/exercises/practice/zipper/gradlew index 1aa94a426..b9bb139f7 100755 --- a/exercises/practice/zipper/gradlew +++ b/exercises/practice/zipper/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/exercises/practice/zipper/gradlew.bat b/exercises/practice/zipper/gradlew.bat index 25da30dbd..24c62d56f 100644 --- a/exercises/practice/zipper/gradlew.bat +++ b/exercises/practice/zipper/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -21,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -49,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -63,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/exercises/practice/zipper/src/test/java/ZipperTest.java b/exercises/practice/zipper/src/test/java/ZipperTest.java index 842ca8be2..d8797814f 100644 --- a/exercises/practice/zipper/src/test/java/ZipperTest.java +++ b/exercises/practice/zipper/src/test/java/ZipperTest.java @@ -1,6 +1,7 @@ +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; import static org.assertj.core.api.Assertions.assertThat; @@ -21,12 +22,14 @@ public void setup() { } @Test + @DisplayName("data is retained") public void testToTree() { assertThat(zipper.toTree()).isEqualTo(binaryTree); } @Disabled("Remove to run test") @Test + @DisplayName("left, right and value") public void testLeftRightAndValue() { zipper = binaryTree.getRoot(); assertThat(zipper.left.right.getValue()).isEqualTo(3); @@ -34,6 +37,7 @@ public void testLeftRightAndValue() { @Disabled("Remove to run test") @Test + @DisplayName("dead end") public void testDeadEnd() { zipper = binaryTree.getRoot(); assertThat(zipper.left.left).isNull(); @@ -41,6 +45,7 @@ public void testDeadEnd() { @Disabled("Remove to run test") @Test + @DisplayName("tree from deep focus") public void testToTreeFromDeepFocus() { zipper = binaryTree.getRoot(); assertThat(zipper.left.right.toTree()).isEqualTo(binaryTree); @@ -48,6 +53,7 @@ public void testToTreeFromDeepFocus() { @Disabled("Remove to run test") @Test + @DisplayName("traversing up from top") public void testTraversingUpFromTop() { zipper = binaryTree.getRoot(); assertThat(zipper.up).isNull(); @@ -55,6 +61,7 @@ public void testTraversingUpFromTop() { @Disabled("Remove to run test") @Test + @DisplayName("left, right, and up") public void testLeftRightAndUp() { zipper = binaryTree.getRoot(); assertThat(zipper.left.up.right.up.left.right.getValue()).isEqualTo(3); @@ -62,6 +69,7 @@ public void testLeftRightAndUp() { @Disabled("Remove to run test") @Test + @DisplayName("test ability to descend multiple levels and return") public void testAbilityToReturnAfterMultipleLevelDescend() { zipper = binaryTree.getRoot(); assertThat(zipper.left.right.up.up.getValue()).isEqualTo(1); @@ -69,6 +77,7 @@ public void testAbilityToReturnAfterMultipleLevelDescend() { @Disabled("Remove to run test") @Test + @DisplayName("set_value") public void testSetValue() { zipper = binaryTree.getRoot(); zipper = zipper.left; @@ -91,6 +100,7 @@ public void testSetValue() { @Disabled("Remove to run test") @Test + @DisplayName("set_value after traversing up") public void testSetValueAfterTraversingUp() { zipper = binaryTree.getRoot(); zipper = zipper.left.right.up; @@ -113,6 +123,7 @@ public void testSetValueAfterTraversingUp() { @Disabled("Remove to run test") @Test + @DisplayName("set_left with leaf") public void testSetLeftWithLeaf() { zipper = binaryTree.getRoot(); zipper = zipper.left; @@ -138,6 +149,7 @@ public void testSetLeftWithLeaf() { @Disabled("Remove to run test") @Test + @DisplayName("set_right with null") public void testSetRightWithNull() { zipper = binaryTree.getRoot(); zipper = zipper.left; @@ -151,6 +163,7 @@ public void testSetRightWithNull() { @Disabled("Remove to run test") @Test + @DisplayName("set_right with subtree") public void testSetRightWithSubtree() { BinaryTree subtree = new BinaryTree(6); subtree.getRoot().setLeft(new Zipper(7)); @@ -181,6 +194,7 @@ public void testSetRightWithSubtree() { @Disabled("Remove to run test") @Test + @DisplayName("set_value on deep focus") public void testSetValueOnDeepFocus() { zipper = binaryTree.getRoot(); zipper = zipper.left.right; @@ -203,6 +217,7 @@ public void testSetValueOnDeepFocus() { @Disabled("Remove to run test") @Test + @DisplayName("different paths to same zipper") public void differentPathToSameZipper() { Zipper zipper1 = binaryTree.getRoot().left.up.right; Zipper zipper2 = binaryTree.getRoot().right; diff --git a/exercises/settings.gradle b/exercises/settings.gradle index 1119f4b98..28f6eca2d 100644 --- a/exercises/settings.gradle +++ b/exercises/settings.gradle @@ -40,10 +40,12 @@ include 'practice:bank-account' // include 'practice:binary' // deprecated include 'practice:binary-search' include 'practice:binary-search-tree' +include 'practice:baffling-birthdays' include 'practice:bob' include 'practice:book-store' include 'practice:bottle-song' include 'practice:bowling' +include 'practice:camicia' include 'practice:change' include 'practice:circular-buffer' include 'practice:clock' @@ -109,6 +111,7 @@ include 'practice:phone-number' include 'practice:piecing-it-together' include 'practice:pig-latin' include 'practice:poker' +include 'practice:prism' include 'practice:eliuds-eggs' include 'practice:pov' include 'practice:prime-factors' diff --git a/reference/how-to-update-gradle.md b/reference/how-to-update-gradle.md index 18ce1b793..7360afccf 100644 --- a/reference/how-to-update-gradle.md +++ b/reference/how-to-update-gradle.md @@ -12,4 +12,8 @@ Then, update the Gradle wrappers for each exercise to match the root version: ./gradlew allWrappers ``` +Copy the updated Gradle resources to the [exercise template directory][template-resource]. + Finally, commit and push your changes. + +[template-resource]: https://github.com/exercism/java/tree/main/resources/exercise-template diff --git a/resources/exercise-template/build.gradle b/resources/exercise-template/build.gradle index dd3862eb9..d28f35dee 100644 --- a/resources/exercise-template/build.gradle +++ b/resources/exercise-template/build.gradle @@ -1,25 +1,25 @@ plugins { - id "java" + id "java" } repositories { - mavenCentral() + mavenCentral() } dependencies { - testImplementation platform("org.junit:junit-bom:5.10.0") - testImplementation "org.junit.jupiter:junit-jupiter" - testImplementation "org.assertj:assertj-core:3.25.1" + testImplementation platform("org.junit:junit-bom:5.10.0") + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "org.assertj:assertj-core:3.25.1" - testRuntimeOnly "org.junit.platform:junit-platform-launcher" + testRuntimeOnly "org.junit.platform:junit-platform-launcher" } test { - useJUnitPlatform() + useJUnitPlatform() - testLogging { - exceptionFormat = "full" - showStandardStreams = true - events = ["passed", "failed", "skipped"] - } + testLogging { + exceptionFormat = "full" + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } } diff --git a/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar b/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar index e6441136f..61285a659 100644 Binary files a/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar and b/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar differ diff --git a/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties b/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..8d9046d01 100644 --- a/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties +++ b/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/resources/exercise-template/gradlew b/resources/exercise-template/gradlew index 1aa94a426..adff685a0 100755 --- a/resources/exercise-template/gradlew +++ b/resources/exercise-template/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/resources/exercise-template/gradlew.bat b/resources/exercise-template/gradlew.bat index 93e3f59f1..c4bdd3ab8 100644 --- a/resources/exercise-template/gradlew.bat +++ b/resources/exercise-template/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,21 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell