This message was deleted.
# community-support
s
This message was deleted.
d
This is a good example that I was able to reproduce myself locally https://github.com/square/anvil/blob/main/settings.gradle#L17-L21 it replaces the plugin definition here with the module in the project
m
thank you I actually made it work the same way However, I'm confused, if we intent to substitute plugin, why don't we make so from
pluginManagement {}
block? The way we do it - from flat settings - leads to just replace dependency in some
dependencies {}
block which is then used to locate classes used in implementation, or plugins applied in precompiled-scripts used when we make convention plugins. I believe, it would be more natural if we could substitute plugin, not a dependency (which is then supposed to provide that plugin), as we normally do in
pluginManagement -> resolutionStrategy {}
block, as I shown in my sample. In other words, I'd like not to replace dependency given its group:artifact, but plugin given it's id and applied in
plugins {}
block. I'd like it to work for any
plugins {}
block in the composite project. Because, if I use the approach replacing dependency with it's group:artifact, that means I HAVE TO make convention-plugin wrapper, that would wrap
plugins {}
block with the plugin I'd like to substitute. And hence, I have to apply that convention-plugin everywhere instead of appliance raw plugin I want to substitute explicitly in each subproject in
plugins {}
block. Does it make sense?
btw,
dependencySubstitution {}
block is not available for
includeBuild()
from
pluginManagement
. Ok, but when I tried to do the same with
pluginManagement -> resolutionStrategy {}
, I failed to substitute - it was always using original 3rd-party
org.sonarqube
plugin instead of those provided from included-build.
v
You should neither need a custom name, nor a manual resolution rule, nor a manual dependency substitution. Just
includeBuild
the build and it should work usually. Having the
includeBuild
outside the
pluginManagement
comes from not so far times where only the outer one existed. But for plugins it is preferable and for settings plugins even required to do it inside the
pluginManagement
block.
I also tried it in a play project and it works perfectly fine for the SQ Gradle scanner plugin. If it does not for you, please show an MCVE where it does not work.
m
it worked for me, when I put a single line
Copy code
includeBuild("/Users/mymac/Soft/OPENSOURCE/sonar-scanner-gradle")
outside any block in my
settings.gradle
. my convention plugin was declaring dependency on
Copy code
implementation org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3
but after adding
includeBuild()
, for it to be substituted I had to change this declaration to
Copy code
implementation org.sonarsource.scanner.gradle:sonarqube-gradle-plugin
after that, my convention plugin had the local changes I made in my local version of
org.sonarqube
plugin.
v
Ah, yes, in that case it is used as a dependency, not as plugin, so you need it outside the plugin management block. But you shouldn't need to change the declaration. The included build should always win.
❤️ 1
m
so, if i'm going to just use
org.sonarqube
plugin applied from
plugins {}
block in some of my subprojects, w/o having any convention plugins (not using as a dependency), then I'd just need to add
Copy code
includeBuild("/Users/mymac/Soft/OPENSOURCE/sonar-scanner-gradle")
inside
pluginManagement {}
block and that's it? And it will silently substitute every appliance of
org.sonarqube
with my local version of it without any changes in any build scripts required?
v
Yes, that's how it should work
1