kopykat-kt / kopykat

Little utilities for more pleasant immutable data in Kotlin
Other
283 stars 16 forks source link

Option for annotating classes to process #46

Closed serras closed 2 years ago

serras commented 2 years ago

The default is still to generate for all classes. This PR adds the option to process only those marked with @KopyKat.

In order to educate people about the defaults, I've added a warning when @KopyKat is used, but still the plug-in is configured in the "generate all" option. This in turn required some tweaks to the testing framework, because KSP warning messages were no correctly recorded.

serras commented 2 years ago

In addition to your comments, I've added an error for those cases in which we detect that a non-data, non-value class has a @CopyExtensions annotation. That way we won't deceive users who may expect those to be generated.

serras commented 2 years ago

I'm marking this as draft because I had another idea. Instead of simply generateAll vs. @CopyExtensions, my idea is to offer a generate option with three options:

That way you can state in your build file "I want copy for all my domain classes in this package", instead of marking each of them by hand. What do you think, @pablisco?

pablisco commented 2 years ago

I'm marking this as draft because I had another idea. Instead of simply generateAll vs. @CopyExtensions, my idea is to offer a generate option with three options:

  • all, the default, which generates the copy for every class,
  • annotated, which only generates those with @CopyExtensions,
  • packages:pk1:pk2:..., which generates for every class in those packages.

That way you can state in your build file "I want copy for all my domain classes in this package", instead of marking each of them by hand. What do you think, @pablisco?

That sounds perfect. Could we also add regex? 🤞

serras commented 2 years ago

Ready again for review!