Semantic Versioning and dependency resolution

I’m wondering if there’s any way to hook into the dependency resolution functionality of Gradle to add custom resolution rules. Let me give you an example of what I am trying to achieve:

Suppose that my build depends on on some dependency sample that is versioned according to the semantic versioning rules. Also, let’s suppose that there are feature branches for this dependency which are built by a CI server. This produces artifacts that are deployed to an Artifactory repository.

This results in JAR dependencies like those:
and so on.

The goal would then be to specify a dependency that refers to the latest build of a feature branch:
dependencies { compile "company:sample:0.1.0-feature_branch*" }
(syntax is completely made up)

If this is possible at all, I’d be grateful if you could point me into the right direction on how to do this.

You should be able to use a component selection rule for this. For example:

dependencies {
    compile 'company:sample:+'

configurations.compile.resolutionStrategy.componentSelection {
    withModule('company:sample') { ComponentSelection selection ->
        if (!selection.candidate.version.contains('feature_branch') {
            selection.reject("branch does not match 'feature_branch'")