Is there a workaround for the `Calling non-final f...
# gradle
s
Is there a workaround for the
Calling non-final function 'function' in constructor
warning when configuring subclasses of Gradle tasks? For example:
Copy code
open class ChildJavaExec: JavaExec() {
    init {
         workingDir("foo/bar")
    }
}
Not sure if I should just ignore it? Tasks need to be non-final in order for Gradle to inject and construct them.
c
There is this tidbit in docs: https://kotlinlang.org/docs/reference/classes.html#derived-class-initialization-order Which explains why it's dangerous to do it. If you're fine with it, you can ignore. The risk is always there but it doesn't always matter.
s
Agreed, I was already aware of why this is a bad pattern and is being linted. I suppose the workaround in this particular case is to explicitly call that method in the parent with
super