Mappie is a Kotlin compiler plugin which comes with a Gradle plugin to automatically apply and configure the compiler plugin. We can apply Mappie by adding the following plugin to the Gradle build file

When using mappie version below 1.0.0 or when you want to add the mappie-api dependency manually, the mappie-api dependency can be added as follows

The most recent version of Mappie can be found at the releases page.

Configuration #

Mappie can be configured via Gradle or per Mapper. The following configuration options are available

mappie {
    useDefaultArguments = false // Disable using default arguments in implicit mappings
    strictness {
        enums = false // Do not report an error if not all enum sources are mapped
        platformTypeNullability = true // Enable strict nullability checks for platform types in mappings
        visibility = true // Allow calling constructors not visible from the calling scope
    }
    reporting {
        enabled = true // Enable report generation
    }
}

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

Gradle Option Annotation Default Value
useDefaultArguments @UseDefaultArguments true
strictness.enums @UseStrictEnums true
strictness.platformTypeNullability @UseStrictPlatformTypeNullabilityValidation true
strictness.visibility @UseStrictVisibility false
reporting.enabled false
reporting.directory $buildDir/mappie