Hey folks. I've noticed a few interesting things a...
# plugin-development
j
Hey folks. I've noticed a few interesting things about how other plugins use injected services. Notably, how some plugins in the wild inject types such as
Project
,
ConfigurationContainer
, and
SoftwareComponentFactory
, despite not being listed in the Service Injection userguide page. So my question is, is this page out-of-date or is injecting those other types unsafe? Does Gradle hold the right to make injecting type
Project
stop working at any time?
m
I would be very surprised if you can inject a
Project
in a task/worker, that would break CC completely
j
No, my interest would be injecting
Project
in objects that are created at configuration time.
m
For those, I find you can always pass them explicitely
v
I always use it without much thought. They are no services, so listing them on service injection docs would probably be wrong.
But even the service injection docs are incomplete afair
j
It's just rather unclear what I am allowed to inject with that annotation. I don't want to inject something and then a random Gradle minor version bump breaks it.
v
I don't think it should break. The injection afair is quite explicit from Gradle-side. So I'd expect if something is injected now this should not change without the usual deprecation cycle.
So me when in doubt, I just try whether something can be injected and it works I'm using it.
j
Yeah the documentation on that front needs to be revised for sure. Especially if there are types that are able to stick around. It's a little weird seeing types annotated with
@ServiceScope
yet they are nowhere to be found on either the Javadocs or the user guide.
v
Btw. let me refine my statement. It might be possible to inject something that is in an
internal
package, those I would not rely on and also expect them to be changed without warning.
j
I stay away from anything marked as internal or in an internal package already.
👌 1
v
But as long as the injected thing is in a public API, I would expect the usual backwards compatibility or else open a bug if it broke
j
The only thing that isn't necessarily internal but I am still uncomfortable using is the
StartParameter
class.
It's just kind of sitting out in the open yet it contains important stuff like offline mode and task requests.
It really, really looks like an internal class.
v
And even though, it is not, and that is good sometimes. There were cases when accidentally public classes moved to internal after deprecation. But that class for example, is the only way to replicate
-x
from code.
j
mhm