Hello.
I’m using the great composite build feature to share some modules across multiple Java projects.
My shared modules define some test fixtures in another source set (each module has main, test and testFixtures source sets).
I would like the modules of my main build (the one that defines the composite build with the shared modules) to depend on the shared modules’ test fixtures in their tests.
To depend on their main source set, I define a dependency using the ${project.group}:${project.name}
declaration as explained in the documentation. Gradle automatically substitutes it by the corresponding composite build’s module. This works very well but I don’t know how to do the same thing with the testFixtures source set.
I saw in the documentation that we can manually configure the dependency substitution. My idea was to define the substitution of a virtual artifact (that does not really exists) by a dependency to a project. Something like that (inspired from the documentation):
includeBuild('../share-build') {
dependencySubstitution {
substitute module('org.sample:module1-test-fixtures') with project(path: ':shared-build:module1', configuration: 'testFixturesCompile')
}
}
When I write that in my settings.gradle
file, I get the following error:
Could not find method project() for arguments [{path=:shared-build:module1, configuration=testFixturesCompile}] on object of type org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DefaultDependencySubstitutions.
Did I do something wrong? Is there a bug? Should I use another approach to solve this issue (if yes, which one)?
Thanks a lot!