Currently on a Gradle 7 project, and I have this t...
# plugin-development
k
Currently on a Gradle 7 project, and I have this thing here:
Copy code
abstract class AbstractMyTask : DefaultTask() {
  abstract val base: Provider<String>
  private val derived = base.map { ... }
}

abstract class MyTask : AbstractMyTask {
  override val base = ...
}
It seems Gradle is unable to create
MyTask
instances due to a
NullPointerException
on
derived
in
AbstractMyTask
. Is this a known thing?
v
Sure, that's just normal Kotlin, same as in Java. First
AbstractMyTask
is initialized and later
MyTask
. So the time
derived
is initialized the overridden
base
in
MyTask
is not yet ready. That's why you should not use overridable properties in initializers or constructors.
k
Fair enough.