revolut-engineering / jooq-plugin

Plugin for generating jOOQ classes using dockerized databases
Apache License 2.0
72 stars 28 forks source link

Support a feature flag to disable generating unchanged files #20

Open elie321 opened 2 years ago

elie321 commented 2 years ago

Every-time I generate JOOQ using the plugin, it generates unnecessary changes with new date and serialVersionUid.

These changes are superficial and I always end up inspecting them one by one and discarding them.

I am requesting a feature flag. When enabled, it would avoid generating these files (that has no real changes) and as a result wouldn't need committed.

lukaseder commented 2 years ago

Note that in vanilla jOOQ, you can configure all of these things, see:

elie321 commented 2 years ago

I may be missing something. I pinned jooq 3.16.6 in gradle. Im unable to find any feature to enable generating serialVersionUID as hash for example or as constant on the org.jooq.meta.jaxb.Generate object.

lukaseder commented 2 years ago

I'm not affiliated with this plugin, just thought this might help. From the readme, I'd expect the generate content to be available via customizeGenerator?

See: https://github.com/revolut-engineering/jooq-plugin/blob/master/README.md

elie321 commented 2 years ago

Yes, this is how I had a reference to the Generate object

tasks {
    generateJooqClasses {
        customizeGenerator {
            generate.examplePropertyName = exampleValue
        }
    }
}

to close the loop on this one, I was able to set the generatedSerialVersionUID via the withGroovyBuilder. This is a decent work around. I wasn't aware of this Groovy builder. But it seems like the Kotlin object doesn't expose certain properties? if that is the case , I feel like there's room for improvement (at least to enhance discoverability of these features/props).

tasks {
    generateJooqClasses {
        customizeGenerator {
            generate.examplePropertyName = exampleValue
            generate.withGroovyBuilder {
                setProperty("generatedSerialVersionUID", "HASH")
            }
        }
    }
}

Thank you! I appreciate your input and time.

monosoul commented 2 years ago

You can do it like that:

tasks {
    generateJooqClasses {
        customizeGenerator {
            generate.generatedSerialVersionUID = org.jooq.meta.jaxb.GeneratedSerialVersionUID.HASH
        }
    }
}

Btw, this plugin seems to be abandoned, so I forked it and published it under a new group. It's available here: https://plugins.gradle.org/plugin/dev.monosoul.jooq-docker ( https://github.com/monosoul/jooq-gradle-plugin )