vlsi / vlsi-release-plugins

A set of plugins to simplify Gradle release tasks
Apache License 2.0
41 stars 13 forks source link

[Gradle Extensions Plugin] Typed property delegates for required properties #65

Closed endorh closed 1 year ago

endorh commented 1 year ago

Hi, thanks for making this plugin. I've tried many times to achieve this with simple script plugins, but they don't go well with property delegates 😅.

However, it bothers me that only Boolean properties can omit their default value when used as property delegates. I think it would be nice if the delegates could be used as follows:

val jvmToolchainVersion by props.int

which rather than defaulting to 0 should use the property as required, since I'd prefer not having default values at all in the build script but rather in the properties file.

I understand that for Boolean properties having default values may make sense, but for version properties it feels wrong having versions declared in two places (For instance, gradle plugin versions, which are required by the pluginManagement block in settings.gradle.kts and thus must be in the gradle.properties file).

Don't get me wrong, I don't mean to replace the delegates with default values, I'm just asking for an alternative for required properties.

I wouldn't mind making a PR for this if that's alright.

vlsi commented 1 year ago

It would be nice if you could submit a PR. I guess string and int properties should not have defaults indeed.

By the way, have you seen https://github.com/gradlex-org/build-parameters ?

Frankly speaking, I used to declare versions in properties, however, Renovate can update dependencies if they are listed explicitly, so I’ve migrated pgjdbc to build-parameters.

endorh commented 1 year ago

Sure, will do.

By the way, have you seen https://github.com/gradlex-org/build-parameters ?

I had not, so thanks for sharing it, I think I'll find it useful. Thanks for your sharing your insight, the pgjdbc repo seems like a great example of proper Gradle configuration. 😄