About 3rd party types, actually this is just not d...
# akkurate
j
About 3rd party types, actually this is just not documented yet, but it's already possible through a KSP plugin option! You just have to provide a list of FQCN to the validatableClasses option.
d
Lets say I write (in my test module):
Copy code
@Validate
data class Fixture(val foo: Foo, val baz: Baz)
will the ksp plugin generate accessors for Foo and Baz (from the main module), even though ksp is only enabled in the test module, since it has to generate for
Fixture
anyways?
j
No, you will only have accessors generated for
Fixture
The reason I did not do this is to avoid generating to much accessors without the developer being aware of this, I don't want this to snowball. Maybe I will change this behavior in the future, nothing is settled.
d
I'd understand that reasoning, but just as long as you don't generate double accessors (for classes already annotated + transitive), you could always provide an expiremental
@Validate(generateTransitive=true)
or something similar, that way it's only opt-in.
j
I will think about it! But, couldn't the
validatableClasses
option do the trick in your case? It also avoids creating a dummy
Fixture
class.
d
It could, but it's a bit cumbersome to have to provide a very big list of FQCNs...
j
I can understand 🙂
d
internal var validatablePackages: Set<String> = emptySet()
is not yet implemented I suppose?
j
its implemented… privately 😅 the reason is simple: it uses an experimental feature of KSP
but I really don't recommend it!
d
Btw, how do I set that property? Using the
ksp { arg("???", "????" }
block in build.gradle.kts? How would I separate the list of packages, one humongous string?
j
yes, use the
ksp { arg(...) }
block, you can write something like that:
Copy code
ksp {
    arg("validatableClasses", "org.example.Foo|org.example.Bar")
}
Unfortunately, ksp plugins only accept strings as option values, so have to use a "humongous string" like you said 😅, each class separated by a
|
You can improve the readability by joining multiple strings into one:
Copy code
listOf("org.example.Foo", "org.example.Bar").joinToString("|")
👍🏼 1