You'll have to write some code to achieve this. For example, you could copy the configuration, set classifiers for the copied configuration via resolutionStrategy.eachDependency
, resolve the copied configuration via configuration.resolvedConfiguration.lenientConfiguration
, check which dependencies could be resolved, and then choose classifiers for the original configuration accordingly (again via resolutionStrategy.eachDependency
). The best place to do all of this is in configuration.incoming.beforeResolve
.
Pick Version with Branchname as Classifier with Gradle
-
25-06-2023 - |
Frage
I am evaluating gradle for our project. We have multiple small project that contain small util libraries. Most projects are in an extra repository and cannot use a shared buildscript. When working across multiple project the same feature branch is used. I already managed to get gradle to put the branchname into the created maven artifact as classifier. For our continous integration it would be really helpful to resolve a dependency to such a library to the one using its own branch name if it exists. If it doesn't it should fallback to the normal declared version.
I managed to change the versions via resolutionStrategy.eachDependency but I couldn't find a way to implement the fallback if no version for this branch exists.
Is there any way this can be achived?
Regards, arne
Lösung