Pick Version with Branchname as Classifier with Gradle

社会主义新天地 提交于 2019-12-23 20:10:00

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/22779806/pick-version-with-branchname-as-classifier-with-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!