Add Kotlin support with automatic kapt configuration - #27
Merged
Merged
Conversation
AkaZver
marked this pull request as draft
July 26, 2026 18:32
AkaZver
force-pushed
the
feature/update-26.07.2026-4
branch
from
July 29, 2026 12:03
1b4859c to
402d6ad
Compare
- Detect Kotlin plugin (org.jetbrains.kotlin.jvm) in project - Automatically apply kapt plugin when Kotlin is detected - Add mapstruct-processor to kapt configuration instead of annotationProcessor - Update optional dependencies (Lombok, Spring) to use kapt when Kotlin is present - Add comprehensive tests for Kotlin support - Update README with Kotlin examples and detection mechanism - Add Kotlin Gradle Plugin 2.0.21 to test dependencies
AkaZver
force-pushed
the
feature/update-26.07.2026-4
branch
from
July 29, 2026 13:15
402d6ad to
b674111
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
This PR adds automatic Kotlin support to the MapStruct Gradle plugin. When the Kotlin plugin is detected in the project, the plugin automatically applies kapt and configures mapstruct-processor in the kapt configuration instead of annotationProcessor.
Changes
Kotlin Support
Automatic detection and configuration:
kotlinextension (consistent with other framework detection)org.jetbrains.kotlin.kaptplugin when Kotlin is detectedmapstruct-processortokaptconfiguration instead ofannotationProcessorkaptwhen Kotlin is presentImplementation details:
addDependencies()method that handles both required and optional dependencieshasExtension("kotlin")for consistency with other frameworksaddDependency()overloads to reduce code duplicationhasPlugin()method in favor of extension-based detectionTesting
Added comprehensive test coverage:
addDependenciesWithKotlinPlugin- verifies kapt is applied and processor is in kapt configurationaddDependenciesWithKotlinPluginAndSpring- verifies Kotlin works correctly with other frameworksAll existing tests pass - no regressions introduced
Documentation
README.md updates:
Testing
All tests pass successfully:
Files Changed
DependencyManager.java- Added Kotlin detection, unified dependency addition logicMapstructPlugin.java- Simplified to singleaddDependencies()callDependencyTest.java- Added Kotlin test casesbuild.gradle- Added Kotlin Gradle Plugin to test dependencies, reordered pluginsREADME.md- Added Kotlin to "How it works" section