Does anyone know how to depend on a plugin from a ...
# gradle
d
Does anyone know how to depend on a plugin from a Gradle module in the same project?
Copy code
A and B are modules in a the same Gradle project.

A is a regular module
B exposes a plugin with ID "my.gradle.plugin"

I would like to have the following
A -> B(Plugin)
I know normally you'd use the
plugins
block and use the
id()
method, but I'm not sure how to configure it from another module like you would with a library in the
dependencies
block with
project()
c
are you looking to declare the dependency (if so, just use standard project dependencies), or apply the plugin (B) to (A)? If the latter that idiomatically is done with (B) being a composite project, included, for example, via:
Copy code
pluginManagement {
    includeBuild("build-logic")
}
d
Hmm, that didn't quite do it. Is "build-logic" the module declared in settings.gradle.kts?
c
that snippet would go in settings.gradle.kts. “build-logic” is the directory name of the project to include.
d
Right, I have that in settings.gradle.kts minus the ":". After trying to sync it looks like the version catalog fails to compile since I'm getting an unresolved reference after adding that
c
the include looks right. you’ll need to remove other includes of that project.
d
I've removed the other include to
dan-plugin
. That also didn't work(same version catalog issue pops up right after). I can send whatever you'd like to see since it's a personal project. Thanks for your patience so far too
c
included build composite projects can’t readily share the version catalog; to get it working, break that dependency.
d
Gotcha. I found out one of my plugins was not resolving which caused the issue I was seeing. Currently working through that and then I think this will end up working.
My apologies, I don't believe it's a composite project. In my earlier example, both
A
and
B
live in the same folder/gradle project
A
and
B
would both be subprojects
c
if your goal is to have a build logic / conventions plugin to apply to modules in a project, that is done via the includeBuild as noted earlier.
d
So should
B
be a separate gradle project entirely? With it's own settings.gradle.kts and everything?
c
Not necessary. Composite build works nicely.
d
Interesting, clearly I have some reading to do then. Thank you for your time Chris, it was really helpful and I think I'm working in the right direction now