Closed goatfanboi23 closed 1 month ago
Always enjoy a detailed issue write-up :). Sure thing, send in a PR.
The vast majority of folks just clone the repo and build, hence the broken failsafe stuff I wrote never functioned correctly as I didn't quite bother to test it. But this would be nice for those who download the source zip.
Overview:
Grgit silently puts a null reference in
gradle.properties
when it can not find a git repo. This leads to a build failure whenprocessResources
task is executed.Error:
When building without a git repo, the following abbreviated error is shown:
Inside the {insert property file data here} is the line
grgit=null
, which—as previously mentioned—is inserted by grgit when it can not find a git repo.Possible Solutions:
without making any changes to the underlying logic, you can simply replace all null vales in the
gradle.properties
file with an empty string. This can be done by concatenating.collectEntries{ k, v -> [k, v ?: '']}
to the filter call in theprocessResources
task. The task now looks like this:This does not have any consequences because the resulting plugin.yaml version field will just be concatenated with
unknown
as specified byversionMetadata
method:This fix however could potentially down the line introduce errors when devolving if a property is null but gets copied as an empty string. To only replace the
grgit=null
entry you can use the following code:The merge function replaces the key
grgit
with''
if null otherwise it uses the original value. Hopefully this helps anyone with the same error, and please let me know if you would like me to make a PR.