Skip to content

Add Kotlin support with automatic kapt configuration - #27

Merged
AkaZver merged 1 commit into
masterfrom
feature/update-26.07.2026-4
Jul 29, 2026
Merged

AkaZver merged 1 commit into
masterfrom
feature/update-26.07.2026-4

Conversation

@AkaZver

@AkaZver AkaZver commented Jul 26, 2026 •

Copy link
Copy Markdown
Owner

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:

  • Detects Kotlin via kotlin extension (consistent with other framework detection)
  • Automatically applies org.jetbrains.kotlin.kapt plugin when Kotlin is detected
  • Adds mapstruct-processor to kapt configuration instead of annotationProcessor
  • Updates optional dependencies (Lombok binding, Spring extensions) to use kapt when Kotlin is present

Implementation details:

  • Unified addDependencies() method that handles both required and optional dependencies
  • Kotlin detection via hasExtension("kotlin") for consistency with other frameworks
  • Simplified addDependency() overloads to reduce code duplication
  • Removed hasPlugin() method in favor of extension-based detection

Testing

Added comprehensive test coverage:

  • addDependenciesWithKotlinPlugin - verifies kapt is applied and processor is in kapt configuration
  • addDependenciesWithKotlinPluginAndSpring - verifies Kotlin works correctly with other frameworks
  • Added Kotlin Gradle Plugin 2.0.21 to test dependencies

All existing tests pass - no regressions introduced

Documentation

README.md updates:

  • Added Kotlin to the "How it works" section

Testing

All tests pass successfully:

  • 17 tests total (15 existing + 2 new Kotlin tests)
  • No regressions in existing functionality
  • Kotlin tests verify both standalone and combined scenarios

Files Changed

  • DependencyManager.java - Added Kotlin detection, unified dependency addition logic
  • MapstructPlugin.java - Simplified to single addDependencies() call
  • DependencyTest.java - Added Kotlin test cases
  • build.gradle - Added Kotlin Gradle Plugin to test dependencies, reordered plugins
  • README.md - Added Kotlin to "How it works" section

@AkaZver AkaZver self-assigned this Jul 26, 2026
@AkaZver AkaZver added the enhancement New feature or request label Jul 26, 2026
@AkaZver
AkaZver marked this pull request as draft July 26, 2026 18:32
@AkaZver AkaZver closed this Jul 26, 2026
@AkaZver AkaZver reopened this Jul 29, 2026
@AkaZver
AkaZver force-pushed the feature/update-26.07.2026-4 branch from 1b4859c to 402d6ad Compare July 29, 2026 12:03
- 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
AkaZver force-pushed the feature/update-26.07.2026-4 branch from 402d6ad to b674111 Compare July 29, 2026 13:15
@sonarqubecloud

Copy link
Copy Markdown

@AkaZver
AkaZver marked this pull request as ready for review July 29, 2026 13:17
@AkaZver
AkaZver merged commit 228814d into master Jul 29, 2026
6 checks passed
@AkaZver
AkaZver deleted the feature/update-26.07.2026-4 branch July 29, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant