Skip to content

Commit eb0a937

Browse files
authored
Add update-kotlin-version skill to automate repetitive steps in multiple files (JetBrains#2920)
## Testing N/A ## Release Notes N/A
1 parent 6cbdd56 commit eb0a937

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
name: update-kotlin-version
3+
description: This skill should be used when the user asks to "update Kotlin version", "upgrade Kotlin", "change Kotlin to X.Y.Z", or mentions updating the Kotlin compiler version in the project.
4+
version: 1.0.0
5+
---
6+
7+
# Update Kotlin Version — Compose Multiplatform Core
8+
9+
This skill helps update the Kotlin version across the project. The process involves updating several files to ensure consistency.
10+
11+
## Important Rule
12+
13+
`JETBRAINS_COMPILE_KOTLIN_VERSION` must not be the latest version, but rather the newest - 1. For example, if we use Kotlin 2.3.20 as the latest, `JETBRAINS_COMPILE_KOTLIN_VERSION` should be `KOTLIN_2_2`.
14+
15+
## Required Information
16+
17+
Before starting, ask the user for:
18+
- The target Kotlin version (e.g., "2.3.20")
19+
20+
## Update Process
21+
22+
Perform the following steps in order:
23+
24+
### 1. Update `gradle/libs.versions.toml`
25+
26+
Update three main entries in the `[versions]` section:
27+
28+
a. **Update `composeCompilerPlugin`** to the new Kotlin version:
29+
```toml
30+
composeCompilerPlugin = "X.Y.Z"
31+
```
32+
33+
b. **Update `kotlin`** to the new Kotlin version:
34+
```toml
35+
kotlin = "X.Y.Z"
36+
```
37+
38+
c. **Update or add patch versions** (under the comment `# Use the most up-to-date patch`):
39+
- If a version entry for this major.minor already exists (e.g., `kotlin23` for 2.3.x), update it
40+
- If this is a new major.minor version, add a new entry (e.g., `kotlin24 = "2.4.Z"`)
41+
42+
Example:
43+
```toml
44+
# Use the most up-to-date patch
45+
kotlin21 = "2.1.20"
46+
kotlin22 = "2.2.20"
47+
kotlin23 = "2.3.20"
48+
kotlin = "2.3.20"
49+
```
50+
51+
### 2. Update `buildSrc/public/src/main/kotlin/org/jetbrains/androidx/build/JetBrainsCompatibilityVersions.kt`
52+
53+
Update `JETBRAINS_COMPILE_KOTLIN_VERSION` to be the **previous major.minor version**, not the latest:
54+
55+
```kotlin
56+
val JETBRAINS_COMPILE_KOTLIN_VERSION = KOTLIN_X_Y
57+
```
58+
59+
For example:
60+
- If updating to Kotlin 2.3.20, set to `KOTLIN_2_2`
61+
- If updating to Kotlin 2.4.0, set to `KOTLIN_2_3`
62+
63+
### 3. Check `buildSrc/public/src/main/kotlin/androidx/build/AndroidXConfiguration.kt`
64+
65+
If this is a new major.minor version (e.g., moving from 2.3 to 2.4):
66+
67+
a. Add a new enum entry in the `KotlinTarget` enum:
68+
```kotlin
69+
KOTLIN_2_4(KotlinVersion.KOTLIN_2_4, "kotlin24"),
70+
```
71+
72+
b. Update the `LATEST` entry to point to the new version:
73+
```kotlin
74+
LATEST(KOTLIN_2_4);
75+
```
76+
77+
If this is just a patch update (e.g., 2.3.10 → 2.3.20), no changes are needed in this file.
78+
79+
### 4. Verify the Changes
80+
81+
After making all updates:
82+
1. Confirm that `JETBRAINS_COMPILE_KOTLIN_VERSION` is set to the previous major.minor version, not the latest
83+
2. Verify that all three version entries in `libs.versions.toml` are updated consistently
84+
3. If a new major.minor version was added, confirm the `KotlinTarget` enum includes it
85+
86+
## Key Files
87+
88+
- `gradle/libs.versions.toml` - Version catalog with Kotlin versions
89+
- `buildSrc/public/src/main/kotlin/org/jetbrains/androidx/build/JetBrainsCompatibilityVersions.kt` - Compatibility version settings
90+
- `buildSrc/public/src/main/kotlin/androidx/build/AndroidXConfiguration.kt` - Kotlin target configuration (updated only for new major.minor versions)

0 commit comments

Comments
 (0)