robfletcher

    robfletcher

    2 years ago
    That looks amazing
    Michael

    Michael

    2 years ago
    well...not yet. But I'll put in some effort. 🙂 thanks!
    robfletcher

    robfletcher

    2 years ago
    It’s a great idea. Had certainly crossed my mind but I’d never put any serious thought into how it could be done.
    Michael

    Michael

    2 years ago
    It's pretty gross tbh and I could not have done it without squareup's libraries around kotlin metadata.
    kapt
    is straightforward, but it does not give you the necessary type information to generate assertions. Will have to do more testing before expanding from data classes to other types (classes, sealed classes, inheritance,...)
    robfletcher

    robfletcher

    2 years ago
    Yeah, I’ve tried to do some stuff inferring Open API schemas from Kotlin types and it’s not beautiful.
    christophsturm

    christophsturm

    2 years ago
    is it possible to do this without annotating the data class? I think tests should not need chages to tested classes.
    Michael

    Michael

    2 years ago
    AFAIK it is possible to run an annotation processor without annotations, but I will have to verify. You will then have to configure the classes you want Assertions to be generated for in the gradle plugin. Could look something like this:
    build.gradle
    strikt {
         sources += com.acme.MyClass //fqcn
    
    }
    Though I have to say that adding one annotation with source retention (annotation isn't stored in binary output) to the main classpath should not really matter...
    🤔 I think I can get rid of the annotation and kapt altogether and just use a gradle plugin. Should simplify things a lot for users. Thanks for the brain stimulus Christoph.
    christophsturm

    christophsturm

    2 years ago
    yay!
    robfletcher

    robfletcher

    2 years ago
    I think that’s a good idea. It feels like it ought to be possible to find classes by package scanning.