Options
Konvert provides a few options, which you can define either globally for the complete run, or per mapping.
How to set options
Globally with Gradle
If you use gradle, you can define options using the ksp
block:
ksp {
arg("konvert.konverter.generate-class", "true")
}
Globally with Maven
If you use maven together with the com.dyescape:kotlin-maven-symbol-processing
dependency (as shown here TODO), you can add options to your pom.xml
in the <configuration>
block of kotlin-maven-plugin
:
<pluginOptions>
<option>ksp:apoption=konvert.konverter.generate-class=true</option>
</pluginOptions>
Local for one annotation
The annotations @Konverter
, @Konvert
, @KonvertTo
and @KonvertFrom
all offer the possibility to set options. The processing of these annotations will run with a copy of the inherited options (e.g. globally set ones) combined with their defined options. In case you have options in @Konverter
and @Konvert
, then the later one will inherit the other options and override/complement with its own.
@Konverter(options=[
Konfig(key="konvert.enforce-not-null", value="true")
])
Available Options
Tip | Have a look in the package io.mcarle.konvert.api.config for all provided options. |
General Options
Option | Possible values | Default | Description |
---|---|---|---|
|
|
| When set to
|
Example
Will generate:
| |||
| any string |
| This setting will change the suffix/trailing part of the generated filenames. |
Example
Will generate a file | |||
|
|
| This setting will add the |
Example
Will generate:
| |||
| list of | empty list | All listed |
Example
| |||
|
|
| When set to Otherwise, it will generate code that uses the generated implementation directly. |
Example
Will generate the following extension functions for
| |||
| any string |
| Only effective if set globally. This setting defines the suffix for the generated module type. Any non word character will be replaced with an empty string. |
|
|
| Only effective if set globally. This setting defines if the deprecated META-INF files should be parsed to load generated konverter functions. Will be removed in one of the next releases. |
@Konverter
Options
Option | Possible values | Default | Description |
---|---|---|---|
|
|
| When set to |
Example
Will generate:
|
Injector Options
Anvil
Option | Possible values | Default | Description |
---|---|---|---|
|
|
| Append some injection method by default to all generated mapper classes. Requires |
| fully qualified class name |
| Has to be set to qualified name of anvil scope class, like AppScope. Only used when |
ExampleGlobal settings (e.g. in
Will generate:
|
Koin
Option | Possible values | Default | Description |
---|---|---|---|
|
|
| Append some injection method by default to all generated mapper classes. Requires |
| fully qualified class name or any string |
| Use this scope by default when
|
ExampleGlobal settings (e.g. in
Will generate:
|