Hey there, :wave: I'm looking at the sample <of s...
# community-support
n
Hey there, 👋 I'm looking at the sample of sharing artifacts between projects with Gradle. Is there a way of setting this up so that the consuming project doesn't have to know the names of the dependent projects? Specifically this line:
Copy code
dependencies {
    add("instrumentedRuntime", project(":producer"))
}
`project(":producer") requires me to know the name of the producing project. It seems to me there is a way to do this without knowing the names of the producing project like the aggregate test reports plugin does.
👀 1
m
Currently the only way is to depend on all projects and do a lenient configuration. I wish/hope there is something else but haven't found anything so far
n
thank you
Wait how does the test report aggregation plugin do this?
or is it not project isolation compatible?
m
This would be my guess
n
i see
thank you very much!
m
Actually, looks like
test-report-aggregation
also requires you to explicitely name the dependencies? https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_test_aggregation_standalone.html
Copy code
Declare dependencies using the testReportAggregation configuration
n
oh you are right!
m
No silver bullet 😞
v
Yes and no. The two aggregation plugins aggregate the projects you depend on. If you have projects
a
,
b
,
c
,
d
,
a
depends on
b
,
b
depends on
c
,
c
depends on
b
, and you use one of the aggregation plugins on
a
, then it inherits the dependencies you declared, so will try to aggregate on
a
,
b
, and
c
, but not
d
, and uses an artifact view to filter only the project dependencies and by using an artifact view only getting those that actually provide that variant. Alternatively, you can declare explicitly which projects to aggregate, if you for example also want to include
d
in the aggregation.
For own sharing it is basically the same. Either make sure all projects provide the variant (even if empty) and depend on all projects, or declare explicitly on what to depend, or use an artifact view or a lenient configuration to only get those the provide that variant.
Copy code
dependencies {
    allprojects.forEach {
        add("instrumentedRuntime", it)
    }
}
should be project isolation compatible I'd guess, as you neither read from nor write to the model of the other projects but just depend on them.
allprojects { ... }
is evil even without project isolation,
allprojects
is not, if you just use it like that and not to reach into the models.
👍 1
n
Thanks for that clarification!
👌 1