Can I somehow specify dependency substitutions for...
# community-support
s
Can I somehow specify dependency substitutions for a build that’s included via
--include-build
rather than programmatically?
v
Not with commandline parameters afaik. The best is, if projects do not manipulate the coordinates on publishing so that no substitution is necessary. If that is not possible, you might be able to use an init script that you can the specify using
-I
from the commandline that can configure the necessary substitution.
s
Can I do this programmatically, conditioned on whether the build is included or not? I can’t access gradle.includedBuilds from settings.gradle
v
You cannot access it as it does not exist on
gradle
. You need
gradle...settings...
don't know from the top of my head.
beforeSettings
or
afterSettings
or
settingsEvaluated
or something like that.
s
It does exist but it’s apparently too early to access it in settings.
v
It is not for adding included builds, it is the list of included builds for depending on tasks in them for example
Ah, sorry had misread your message. Why would you want to try evaluating whether it is included. You will do the
includeBuild
within the init script.
s
I have a build that is currently completely separate and I want to integrate it with the main build. Initially, I thought of adding a property to the project to specify whether the build should be included or not, but then I figured that there's already a
--include-build
option that I could use instead of the property. But since the build being integrated is not written nicely, it produces multiple artifacts and its name doesn't match the produced artifact so the default substitution heuristic of Gradle doesn't work. Okay, I thought, I could override that, but it turns out I can only do that within
includeBuild
in settings but not "if this build is included via
--include-build
then substitute those dependencies this way". So I'll fall back to using the property anyway, I just thought that I could avoid it.
v
As I said, you can by using an init script (I think :-D)
s
yes but that would be a more complicated solution than a property
v
Might be, yes. If you anyway can modify the including build, probably. The
--include-build
is more for ad-hoc including or when you cannot or do not want to modify the including build.