Gradle circular dependency, force ignore

am trying to create a service registry where all the modules are added as compile(project(…)). The service registry module expose an unified function to call any function from any module. This is to reduce the direct coupling between two modules and to provide a proper separation of concern. To call any function from any module one can add dependency of service-registry as project and get the function. But if we do that the project has circular dependency.

Is there a way I can force gradle to ignore circular dependency,

project root
    project A
    -- compile(project(':SR'))
    project B
    -- compile(project(':SR'))
    project SR
    -- compile(project(':A')
    -- compile(project(':B')

I will be moving the dependencies to nexus and use versioning, but in initial phase it would be great if somehow I can force gradle not to do so. Can it be done by doing some condition as

if(calling_project_name!=root) compile(project(':A'),project(':B'))exclude(project(':calling project name')

is it possible to do? Other suggestions are also welcome. I am using gradle 2.7.

Instead of having SR depend on A and B at compile time, can you “register” A and B with SR at runtime? Not knowing anything about the projects, I’m not sure if that causes you issues where A needs B but A is registered before B.

Kind of feels like you’re reinventing something OSGi-like. Perhaps there are platforms/frameworks out there that you can leverage.