You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Grgit silently puts a null reference in gradle.properties when it can not find a git repo. This leads to a build failure when processResources task is executed.
Error:
When building without a git repo, the following abbreviated error is shown:
Could not copy file...
Invalid filter specification for org.apache.tools.ant.filters.ReplaceTokens...
Cannot cast object {insert property file data here} with class 'java.util.HashMap' to class 'java.util.Hashtable'
due to: java.lang.NullPointerException
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 the processResources task.
The task now looks like this:
processResources {
filesMatching(['**/*.json', '**/*.yml']) {
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
tokens: rootProject.ext.properties.collectEntries{ k, v -> [k, v ?: '']}
}
}
This does not have any consequences because the resulting plugin.yaml version field will just be concatenated with unknown as specified by versionMetadata method:
if (grgit == null) {
return '-unknown'
}
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: