Mappie is a Kotlin compiler plugin which comes with a Maven plugin to automatically apply and configure the compiler
plugin. We can apply Mappie by adding the following to the kotlin-maven-plugin
configuration in the pom
...
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>...</version>
<configuration>
<compilerPlugins>
<compilerPlugin>mappie</compilerPlugin>
</compilerPlugins>
<pluginOptions>
...
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>tech.mappie</groupId>
<artifactId>mappie-maven-plugin</artifactId>
<version>x.y.z</version>
</dependency>
</dependencies>
</plugin>
...
We must also add the mappie-api
dependency. For example, for the JVM
<dependency>
<groupId>tech.mappie</groupId>
<artifactId>mappie-api-jvm</artifactId>
<version>x.y.z</version>
</dependency>
The most recent version of Mappie can be found at the releases page.
Configuration #
Mappie can be configured via Maven or per Mapper. The following configuration options are available
<pluginOptions>
<option>mappie:use-default-arguments=false</option> <!-- Disable using default arguments in implicit mappings -->
<option>mappie:strict-visibility=true</option> <!-- Allow calling constructors not visible from the calling scope -->
<option>mappie:strict-enums=false</option> <!-- Do not report an error if not all enum sources are mapped -->
</pluginOptions>
Local configuration options are applied as annotations on the class level of mappers, and will override the global configuration option on a per-mapper basis.
The following options exist with their corresponding default values
Maven Option | Annotation | Default Value |
---|---|---|
mappie:use-default-arguments |
@UseDefaultArguments |
true |
mappie:strict-visibility |
@UseStrictVisibility |
false |
mappie:strict-enums |
@UseStrictEnums |
true |
Compatibility #
Mappie depends on some compiler internals, which might be unstable. These dependencies are kept to a minimum,
but are unavoidable. Mappie is tested and compatible with Kotlin versions 1.9.24
, 2.0.0
, and higher.
Versions below 1.9.24
might work, but are untested. If you encounter an issue, please report this as a bug.
Note that incompatible versions might lead to a compilation failure, but never to runtime risks.