Skip to content

Commit d447132

Browse files
committed
chore: kotlin 2.2.20-Beta1 updates and misc changes
# Conflicts: # gradle/libs.versions.toml
1 parent 8424fd1 commit d447132

13 files changed

+370
-92
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
- main
1818

1919
schedule:
20-
- cron: "0 0 * * *"
20+
- cron: "0 0 * * 0"
2121

2222
workflow_dispatch:
2323

.junie/guidelines.md

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# Build Commons Dev Guidelines
2+
3+
This document provides advanced development guidelines for the build-commons project. For basic setup and overview, refer to the main [README.md](../README.md).
4+
5+
## Project Architecture
6+
7+
This is a Gradle composite build with the following structure:
8+
9+
- **gradle/build-logic/**: Included build containing precompiled script plugins and build logic
10+
- **plugins/**: Main plugin modules
11+
- **plugins/project/**: Project-level plugins (kotlin.jvm, kotlin.mpp, common, etc.)
12+
- **plugins/settings/**: Settings-level plugins (repos configuration)
13+
- **plugins/shared/**: Shared utilities and extensions
14+
- **catalog/**: Version catalog module
15+
- **sandbox/**: Testing sandbox project demonstrating plugin usage
16+
17+
## Build Configuration
18+
19+
### Key Gradle Properties
20+
21+
The project uses specific Gradle configurations in `gradle.properties`:
22+
23+
```properties
24+
# Performance optimizations
25+
org.gradle.jvmargs=-Xmx2g
26+
org.gradle.parallel=true
27+
org.gradle.caching=true
28+
org.gradle.configuration-cache=true
29+
org.gradle.configuration-cache.parallel=true
30+
31+
# Kotlin settings
32+
kotlin.code.style=official
33+
kotlin.jvm.target.validation.mode=warning
34+
35+
# Dokka experimental features
36+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
37+
org.jetbrains.dokka.experimental.tryK2=true
38+
```
39+
40+
### Version Catalog Integration
41+
42+
The project uses a sophisticated version catalog system (`gradle/libs.versions.toml`) with:
43+
- Centralized dependency versions
44+
- Plugin dependency management
45+
- Custom extension for accessing catalog in precompiled plugins
46+
47+
### JTE (Java Template Engine) Integration
48+
49+
The project uses JTE for code generation:
50+
- Templates in `src/main/jte/`
51+
- Kotlin model generation enabled
52+
- BuildConfig generation for project metadata
53+
54+
## Testing Guidelines
55+
56+
### Test Structure
57+
58+
Tests should follow Kotlin multiplatform conventions:
59+
- **JVM tests**: `src/jvmTest/kotlin/`
60+
- **Common tests**: `src/commonTest/kotlin/`
61+
- **Platform-specific tests**: `src/{platform}Test/kotlin/`
62+
63+
### Testing Framework Configuration
64+
65+
The plugins automatically configure:
66+
- **kotlin-test** for multiplatform testing
67+
- **JUnit 5** for JVM tests
68+
- **Testcontainers** for integration testing
69+
- **kotlinx-coroutines-test** for coroutine testing
70+
71+
72+
### Running Tests
73+
74+
```bash
75+
# Run all tests
76+
./gradlew test
77+
78+
# Run tests for specific module
79+
./gradlew -p sandbox test
80+
81+
# Run tests with specific system properties
82+
./gradlew test -PktorTest -Pk8sTest
83+
84+
# Skip tests during build
85+
./gradlew build -Pskip.test=true
86+
```
87+
88+
### Test Configuration Features
89+
90+
The plugins provide automatic test configuration:
91+
- **JVM target validation** with warning mode
92+
- **Test logging** with configurable events
93+
- **System properties** for test environment (ktorTest, k8sTest)
94+
- **Custom hosts file** support for integration tests
95+
- **Testcontainers BOM** for container-based testing
96+
97+
## Code Style and Formatting
98+
99+
### Kotlin Compiler Options
100+
101+
Standard compiler options are configured:
102+
- **JVM target**: Configurable via version catalog
103+
- **Context parameters**: Enabled for better debugging
104+
- **Opt-ins**: Pre-configured for experimental APIs
105+
- **Assertions**: Disabled for performance in build scripts
106+
107+
### Code Style Guidelines
108+
109+
1. **Use official Kotlin code style** (`kotlin.code.style=official`)
110+
2. **All warnings as errors** in Kotlin DSL (`org.gradle.kotlin.dsl.allWarningsAsErrors=true`)
111+
3. **Consistent formatting** with ktfmt
112+
4. **Explicit API mode** for library modules
113+
5. **Proper package structure** following reverse domain naming
114+
115+
## Plugin Development
116+
117+
### Creating New Plugins
118+
119+
1. **Precompiled Script Plugins**: Place in `plugins/project/src/main/kotlin/`
120+
2. **Class-based Plugins**: Implement in `plugins/project/src/main/kotlin/plugins/`
121+
3. **Settings Plugins**: Place in `plugins/settings/src/main/kotlin/`
122+
123+
### Plugin Registration
124+
125+
Register plugins in `build.gradle.kts`:
126+
127+
```kotlin
128+
gradlePlugin {
129+
plugins {
130+
register("My Plugin") {
131+
id = "dev.suresh.plugin.myplugin"
132+
implementationClass = "plugins.MyPlugin"
133+
displayName = "My Plugin"
134+
description = "Description of my plugin"
135+
tags = listOf("My Plugin", "build-logic")
136+
}
137+
}
138+
}
139+
```
140+
141+
### Accessing Version Catalog in Plugins
142+
143+
Use the catalog hack for accessing versions in precompiled plugins:
144+
145+
```kotlin
146+
dependencies {
147+
// Hack to access the version catalog from pre-compiled script plugins
148+
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
149+
}
150+
```
151+
152+
## Build Performance
153+
154+
### Configuration Cache
155+
156+
The project uses Gradle's configuration cache for improved performance:
157+
- **Parallel configuration cache** enabled
158+
- **Problems as warnings** to avoid build failures
159+
- **Stable configuration cache** feature enabled
160+
161+
### Build Optimizations
162+
163+
1. **Parallel execution** enabled
164+
2. **Build caching** enabled
165+
3. **Configuration on demand** enabled
166+
4. **Daemon with 2GB heap** for better performance
167+
5. **Isolated projects** disabled (experimental)
168+
169+
## Semantic Versioning
170+
171+
### Configuration
172+
173+
```properties
174+
semver.tagPrefix=v
175+
semver.project.tagPrefix=v
176+
semver.checkClean=false
177+
semver.commitsMaxCount=100
178+
semver.logOnlyOnRootProject=true
179+
```
180+
181+
### Usage
182+
183+
```bash
184+
# Check current version
185+
./gradlew printSemver
186+
187+
# Create and push version tag
188+
./gradlew pushSemverTag "-Psemver.scope=patch"
189+
190+
# Print next version without creating tag
191+
./gradlew printSemver "-Psemver.scope=minor"
192+
```
193+
194+
## Debugging and Troubleshooting
195+
196+
### Common Issues
197+
198+
1. **Configuration cache problems**: Use `--no-configuration-cache` flag
199+
2. **Memory issues**: Increase heap size in `gradle.properties`
200+
3. **Plugin classpath issues**: Check with `./gradlew buildEnvironment`
201+
4. **Version conflicts**: Use `./gradlew dependencyInsight --dependency <name>`
202+
203+
### Useful Debug Commands
204+
205+
```bash
206+
# Show all tasks
207+
./gradlew tasks --all
208+
209+
# Show project dependencies
210+
./gradlew dependencies
211+
212+
# Show plugin classpath
213+
./gradlew buildEnvironment
214+
215+
# Clean all projects
216+
./gradlew cleanAll
217+
218+
# Check for dependency updates
219+
./gradlew dependencyUpdates --no-configuration-cache
220+
```
221+
222+
## Development Workflow
223+
224+
### Local Development
225+
226+
1. **Make changes** to plugin code
227+
2. **Test in sandbox**: `./gradlew publishToMavenLocal && ./gradlew -p sandbox :build`
228+
3. **Run formatting**: `./gradlew spotlessApply`
229+
4. **Run tests**: `./gradlew test`
230+
5. **Build all**: `./gradlew build`
231+
232+
### Publishing Workflow
233+
234+
1. **Create version tag**: `./gradlew pushSemverTag "-Psemver.scope=patch"`
235+
2. **GitHub Actions** automatically publishes to Maven Central
236+
3. **Verify publication** at https://repo.maven.apache.org/maven2/dev/suresh/build/
237+
238+
## Advanced Features
239+
240+
### BuildConfig Generation
241+
242+
The plugins generate BuildConfig classes with project metadata:
243+
- Project name, version, description
244+
- Git commit information
245+
- Kotlin/Java versions
246+
- Version catalog entries
247+
248+
### Multi-Release JAR Support
249+
250+
The plugins support creating multi-release JARs for different Java versions.
251+
252+
### GraalVM Native Image
253+
254+
Automatic configuration for GraalVM native image compilation with:
255+
- Agent-based configuration
256+
- Custom build arguments
257+
- Resource configuration
258+
259+
### Container Image Building
260+
261+
Integration with Jib for building container images:
262+
- Automatic base image selection
263+
- Optimized layering
264+
- Multi-architecture support
265+
266+
---
267+
268+
*Last updated: 2025-07-13*

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Kotlin/Java projects, handling the boilerplate and common tasks so you can get s
6565
$ ./gradlew build
6666

6767
# Check dep updates
68+
$ caupain --gradle-stability-level=milestone
69+
70+
# OR
6871
$ ./gradlew dependencyUpdates --no-configuration-cache
6972
```
7073

0 commit comments

Comments
 (0)