Alexey Loubyansky
07/23/2025, 8:49 PMtestRuntimeClasspath , resolve it and iterate through the resolved artifacts. But if there are test fixtures, it fails with
> Could not resolve all artifacts for configuration ':app:testRuntimeClasspathCopy'.
> Could not resolve project :app.
Required by:
project :app
> Unable to find a variant with the requested capability: feature 'test-fixtures':
- Variant 'testRuntimeClasspathCopy' provides 'playground:app:unspecified'
It looks like something is missing from the copy of the original configuration. Is this expected? Thanks!
I have a little playground project to reproduce the issue here https://github.com/aloubyansky/playground/tree/gradle-copyRecursive-test-fixtures
Commenting out https://github.com/aloubyansky/playground/blob/gradle-copyRecursive-test-fixtures/plugin/src/main/java/org/example/GreetingTask.java#L21 works.
(I realize referencing a Project from a task is a bad practice, this is just a reproducer).Octavia Togami
07/23/2025, 8:55 PMextendsFrom . Why do you need to use it here?Alexey Loubyansky
07/23/2025, 9:02 PMOctavia Togami
07/23/2025, 9:05 PMgetExtendsFrom()), as it won't be merging dependencies from all superconfigurations.Alexey Loubyansky
07/23/2025, 9:07 PMOctavia Togami
07/23/2025, 9:14 PMcopyRecursive() and creating a new configuration with configurations.resolvable and conf.setExtendsFrom(project.getConfigurations().getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).getExtendsFrom()); results in what looks like expected behavior:
> Task :app:greeting
- app-test-fixtures.jar (project :app)
- app.jar (project :app)
- xom-1.3.9.jar (xom:xom:1.3.9)
- xercesImpl-2.12.2.jar (xerces:xercesImpl:2.12.2)
- xml-apis-1.4.01.jar (xml-apis:xml-apis:1.4.01)
However, you might need to also copy the attributes to get fully correct resolution.Alexey Loubyansky
07/23/2025, 9:21 PMconf.setExtendsFrom(project.getConfigurations().getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)) ?Octavia Togami
07/23/2025, 9:22 PMAlexey Loubyansky
07/23/2025, 9:24 PMbaseConfig.getAllDependencies().forEach(dependency -> {
config.getDependencies().add(dependency);
});
but it resulted in the same error as copyRecursive, so it seems like extendsFrom is the way to goAlexey Loubyansky
07/23/2025, 9:25 PMextendsFromVampire
07/23/2025, 9:40 PMVampire
07/23/2025, 9:42 PMAlexey Loubyansky
07/23/2025, 9:42 PMextendsFrom