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
Summary
Calling customTypeMapping.put without first calling set is ignored.
Version
2.4.6 (Gradle 6.7.1)
Description
To my surprise Gradle seems to ignore calls such as MapProperty.put if the property is not present. Here's some concrete examples:
apollo {
// Prints `null`println(customTypeMapping.orNull)
customTypeMapping.put("foo", "bar")
// Prints `null`println(customTypeMapping.orNull)
customTypeMapping.set(emptyMap())
customTypeMapping.put("foo", "bar")
// Prints `{foo=bar}`println(customTypeMapping.orNull)
}
The fix for this is simple, the Apollo Gradle Plugin just needs to set emptyMap() as the default value. Using convention does not work unfortunately.
The reason why I prefer put is because I often set up my Gradle scripts using custom Gradle plugins in buildSrc which can add some common default values.
The text was updated successfully, but these errors were encountered:
Yup, this behaviour is super weird. Recent versions of Gradle have a MapProperty.convention() method that allows to set a default value and distinguish between empty vs unset. Tentative fix there: #2803
Summary
Calling
customTypeMapping.put
without first callingset
is ignored.Version
2.4.6 (Gradle 6.7.1)
Description
To my surprise Gradle seems to ignore calls such as
MapProperty.put
if the property is not present. Here's some concrete examples:The fix for this is simple, the Apollo Gradle Plugin just needs to set
emptyMap()
as the default value. Usingconvention
does not work unfortunately.The reason why I prefer
put
is because I often set up my Gradle scripts using custom Gradle plugins inbuildSrc
which can add some common default values.The text was updated successfully, but these errors were encountered: