This message was deleted.
# plugin-development
s
This message was deleted.
j
Inject is optional except if you are injecting something
p
Only required
String name
by
NamedDomainObjectContainer
, like below:
Copy code
project.objects.newInstance(
    DockerComposeRunSettings,
    name
)
t
We were able to go really simple with containers, no factory (assuming that your
newInstance
is in a factory): We have `abstract class NexusRepository @Inject constructor(@Input val name: String) { ... bunch of other properties`, I just tried without
@Inject
and all the tests pass on Gradle 8.2.1.
Your point is still a good one though, I tried to remove more @Injects and some of them are hard required.
p
OK, It looks like
project.objects.newInstance
requires
@Inject
. Thanks for the hint with
project.objects.domainObjectContainer()
without factory. It correctly creates an instance of my
DockerComposeRunSettings
class, without the
@Inject
annotation, and correctly passes the
String name
parameter.
t
Btw, is there a reason you're against @Inject? It signals to the reader that the instances of a class are created by a framework, not directly.
p
I have nothing against @Inject, except that when it is required and not set, the Gradle Build ends with an exception that
@Inject
should be set, instead of that it must be set.