-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
Milestone
Description
When creating an extension on a task, Gradle fails to inject services (ObjectFactory, ProviderFactory, etc).
Expected Behavior
When adding extensions to the project or objects created using ObjectFactory.newInstance
, services are correctly injected into the extension's constructor. This does not work for extensions created on tasks, but probably should.
Current Behavior
Creation of the task extension fails with missing parameter of type <service>, or no service of type <service>
.
Steps to Reproduce
class MyExt {
Property<String> myProp
@javax.inject.Inject
MyExt( ObjectFactory objectFactory, String target ) {
println "target: ${target}, service: ${objectFactory}"
myProp = objectFactory.property( String )
myProp.set( target )
}
}
interface MyType {
}
[
project: project,
object: objects.newInstance( MyType ),
task: tasks.create( 'myTask' )
].each { t, o ->
o.extensions.create( 'myExt', MyExt, t )
println o.myExt.myProp.get()
}
Your Environment
Tested on Gradle 6.8.3, 7.0.