A kotlin compiler plugin to generate toString like data class.
First, you need to apply this gradle plugin
plugins {
id("org.jetbrains.kotlin.jvm") version "<kotlin version>"
id("com.anatawa12.auto-tostring") version "<version>"
}
To add compile-time library, add code below:
autoToString {
// for compileOnly configuration
addLib()
// for <source-set>CompileOnly configuration
addLib "sourceSet"
addLib sourceSet: "sourceSet"
// for your configuration
addLib configuration: "yourConfiguration"
}
To generate toString function, add @AutoToString
annotation to class.
For kotlin.String
or string it typed fields, This plugin surrounded the value with "
like SomeClass(value="string body")
and also surrounded with '
for kotlin.Char
s.
You can customize wrapping with @SurroundedWith(begin=, end=)
. see KDoc for more details.