Skip to content

Commit e89f243

Browse files
build: migrate to Kotlin Toolchain
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e3a3141 commit e89f243

50 files changed

Lines changed: 2371 additions & 485 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ updates:
88
day: "monday"
99
open-pull-requests-limit: 5
1010
groups:
11-
kotlin:
12-
patterns:
13-
- "org.jetbrains.kotlin*"
1411
ktor:
1512
patterns:
1613
- "io.ktor*"
@@ -24,6 +21,21 @@ updates:
2421
exposed:
2522
patterns:
2623
- "org.jetbrains.exposed*"
24+
detekt:
25+
patterns:
26+
- "io.gitlab.arturbosch.detekt*"
27+
- "com.github.marc0der*"
28+
ktlint:
29+
patterns:
30+
- "com.pinterest.ktlint*"
31+
jib:
32+
patterns:
33+
- "com.google.cloud.tools*"
34+
release-plugin:
35+
patterns:
36+
- "org.eclipse.jgit*"
37+
- "org.bouncycastle*"
38+
- "org.slf4j*"
2739

2840
# GitHub Actions
2941
- package-ecosystem: "github-actions"

.github/workflows/ci.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212

13+
env:
14+
KOTLIN_CLI_NO_WELCOME_BANNER: "1"
15+
1316
steps:
1417
- uses: actions/checkout@v6
1518
with:
16-
fetch-depth: 0 # Needed for Axion-release to determine version correctly
17-
18-
- name: Set up JDK 21
19-
uses: actions/setup-java@v5
20-
with:
21-
java-version: '21'
22-
distribution: 'temurin'
23-
cache: gradle
24-
25-
- name: Grant execute permission for gradlew
26-
run: chmod +x gradlew
19+
fetch-depth: 0 # Needed for the release plugin to determine the version from git tags
2720

28-
- name: Build with Gradle
29-
run: ./gradlew build --scan --info
21+
- name: Build with Kotlin Toolchain
22+
run: |
23+
./kotlin build
24+
./kotlin check
25+
./kotlin do package
3026
3127
- name: Upload build artifacts
3228
uses: actions/upload-artifact@v7

.github/workflows/release.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- main
88

99
# Only release the latest commit; cancel superseded runs so back-to-back
10-
# merges don't fail axion's aheadOfRemote check by racing each other.
10+
# merges don't fail the release plugin's aheadOfRemote check by racing each other.
1111
concurrency:
1212
group: release-main
1313
cancel-in-progress: true
@@ -19,6 +19,8 @@ jobs:
1919
build:
2020
name: "Release"
2121
runs-on: ubuntu-latest
22+
env:
23+
KOTLIN_CLI_NO_WELCOME_BANNER: "1"
2224
steps:
2325
- name: Install doctl
2426
uses: digitalocean/action-doctl@v2
@@ -33,29 +35,21 @@ jobs:
3335
with:
3436
fetch-depth: 0
3537

36-
- name: Set up JDK 21
37-
uses: actions/setup-java@v5
38-
with:
39-
java-version: '21'
40-
distribution: 'temurin'
41-
cache: gradle
42-
43-
- name: Gradle check
44-
run: ./gradlew clean check
38+
- name: Verify
39+
run: ./kotlin check
4540

46-
- name: Gradle release
47-
run: ./gradlew release
41+
- name: Tag release
42+
run: ./kotlin do release
4843

49-
- name: Propagate current release version
44+
- name: Resolve current release version
5045
id: tag_version
5146
run: |
52-
current_version=$(./gradlew currentVersion -q | grep "Project version" | awk '{print $3}')
47+
current_version=$(./kotlin do currentVersion 2>/dev/null | tail -n1)
5348
echo "Version set to: $current_version"
5449
echo "version=$current_version" >> $GITHUB_OUTPUT
5550
5651
- name: Build and publish Docker image
5752
run: |
5853
version="${{ steps.tag_version.outputs.version }}"
5954
commit_hash=$(git rev-parse --short=8 HEAD)
60-
./gradlew build jib -Djib.to.tags=$commit_hash,$version,latest
61-
55+
./kotlin do jib --setting "jib.targetImage.tags=[$version,$commit_hash,latest]"

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# Gradle
2-
.gradle/
1+
# Kotlin Toolchain
32
build/
4-
gradle-app.setting
5-
!gradle-wrapper.jar
63

74
# IDE files
85
.idea/

.mcp.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.sdkmanrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Enable auto-env through the sdkman_auto_env config
22
# Add key=value pairs of SDKs to use below
33
java=21.0.7-tem
4+
kotlintoolchain=0.11.0

CLAUDE.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,34 @@ SDKMAN Broker is a Kotlin-based Ktor application that brokers SDKMAN candidate a
88

99
## Build & Run
1010

11-
- **Run service:** `./gradlew run` (starts Ktor on port 8080; requires MongoDB and PostgreSQL — see Database Setup below)
11+
Built with the Kotlin Toolchain (Amper engine). The `./kotlin` wrapper auto-provisions both the JDK and the toolchain; no `setup-java` or local install required.
12+
13+
- **Run service:** `./kotlin run` (starts Ktor on port 8080; requires MongoDB and PostgreSQL — see Database Setup below)
1214

1315
## Validation
1416

1517
Run after every implementation to get immediate feedback:
1618

17-
- **Clean build** `./gradlew clean`
18-
- **Full check:** `./gradlew clean check` (clean -> compile → detekt → ktlintCheck → test)
19-
- **Tests only:** `./gradlew test`
20-
- **Lint only:** `./gradlew ktlintCheck`
21-
- **Lint auto-fix:** `./gradlew ktlintFormat`
22-
- **Static analysis:** `./gradlew detekt` (config in `detekt.yml`)
23-
- **Build Docker image:** `./gradlew jib` (or `jibDockerBuild` for local)
19+
- **Clean build:** `./kotlin clean`
20+
- **Full check:** `./kotlin clean && ./kotlin check` (compile → detekt → ktlint → test)
21+
- **Tests only:** `./kotlin test`
22+
- **Lint auto-fix:** `./kotlin do ktlintFormat`
23+
- **Static analysis:** detekt runs as part of `./kotlin check` (config in `detekt.yml`, plugin in `plugins/detekt/`)
24+
- **Build Docker image:** `./kotlin do jib` (pushes to the registry in `module.yaml`; use `./kotlin do jibDockerBuild` for a local Docker daemon load)
25+
- **Current version:** `./kotlin do currentVersion` (derived from git tags by the local release plugin)
2426

2527
Tests spin up MongoDB and PostgreSQL via Testcontainers — no manual database setup is required to run the test suite.
2628

29+
## Build Configuration
30+
31+
- **`module.yaml`** — root module config (dependencies, settings, plugin config). Layout is `maven-like` (`src/main/kotlin`, `src/test/kotlin`, etc.).
32+
- **`project.yaml`** — registers all modules and local plugins.
33+
- **`gradle/libs.versions.toml`** — Gradle-format version catalog reused as the `$libs.*` catalog (the directory name is historical; the file is consumed natively by the Kotlin Toolchain).
34+
- **`plugins/{release,jib,detekt,ktlint}/`** — local plugins replacing the Gradle plugins of the same name. Reimplement behavior here rather than reaching for Gradle plugins.
35+
2736
## Database Setup (Dev Server Only)
2837

29-
The dev server (`./gradlew run`) connects to MongoDB and PostgreSQL on localhost. Start them in Docker:
38+
The dev server (`./kotlin run`) connects to MongoDB and PostgreSQL on localhost. Start them in Docker:
3039

3140
```bash
3241
docker run -d --restart=always -p=27017:27017 --name mongo mongo:3.2

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,44 @@ This application implements a health check endpoint that performs a deep health
1414

1515
### Prerequisites
1616

17-
- JDK 21 (Temurin recommended)
1817
- MongoDB (or use Docker)
1918
- Postgres (or use Docker)
20-
- Gradle
19+
- The Kotlin Toolchain (formerly Amper) — auto-provisioned by the bundled `./kotlin` wrapper. Installing it globally is optional.
2120

2221
### SDKMAN Setup
2322

24-
This project uses SDKMAN to manage the JDK version:
23+
This project uses SDKMAN to manage the JDK and the Kotlin Toolchain CLI:
2524

2625
```
2726
sdk env
2827
```
2928

29+
That installs the JDK declared in `.sdkmanrc` and the Kotlin Toolchain CLI. Alternatively, the `./kotlin` wrapper checked into the project root auto-provisions both on first use.
30+
3031
### Building and Testing
3132

3233
Build the project:
3334

3435
```
35-
./gradlew build
36+
./kotlin build
3637
```
3738

3839
Run tests:
3940

4041
```
41-
./gradlew check
42+
./kotlin test
43+
```
44+
45+
Run all verification checks (detekt + ktlint):
46+
47+
```
48+
./kotlin check
49+
```
50+
51+
Auto-format Kotlin sources:
52+
53+
```
54+
./kotlin do ktlintFormat
4255
```
4356

4457
### Running Locally
@@ -78,7 +91,7 @@ mongosh --eval 'db.getSiblingDB("sdkman").application.insertOne({ alive: "OK", s
7891
Run the application:
7992

8093
```
81-
./gradlew run
94+
./kotlin run
8295
```
8396

8497
## API Endpoints
@@ -138,14 +151,14 @@ This project uses GitHub Actions for CI/CD:
138151
- Builds a Docker image and pushes it to Digital Ocean Container Registry
139152
- The image is tagged with the version number, commit hash, and "latest"
140153

141-
The version is managed by the Axion Release Plugin based on Git tags.
154+
The version is managed by the local `release` Kotlin Toolchain plugin (`plugins/release/`), which derives the version from Git tags.
142155

143156
### Checking the Current Version
144157

145158
To check the current version of the application, run:
146159

147160
```
148-
./gradlew currentVersion
161+
./kotlin do currentVersion
149162
```
150163

151-
This will display the current version as determined by the Axion Release Plugin.
164+
This will display the current version as determined by the local release plugin.

0 commit comments

Comments
 (0)