Question: What's the difference between this: ```a...
# plugin-development
k
Question: What's the difference between this:
Copy code
abstract class MyTask @Inject constructor(private val layout: ProjectLayout) : DefaultTask()
and this:
Copy code
abstract class MyTask : DefaultTask() {
  private val layout = project.layout
}
It seems like the first is preferred over the second - any insights as to why that is?
v
I usually prefer
Copy code
abstract class MyTask : DefaultTask() {
  @get:Inject
  protected val layout: ProjectLayout
}
But regarding your first and second, it is probably the same, but if you for example also need
ExecOperations
then latest then you need to inject and then it is more consistent to always inject, either like your first or my version.