Runtime dependencies in multiproject build propagate as compile time dependencies


I’m experiencing rather strange gradle behavior projectA-Service depends on projectA-Dal(compile) projectB depends on projectA-Api(compile) and projectA-Services(runtime) projectC depends on projectB(compile)

I can use projectA-Dal in projectC for some reason(if I print dependencies for projectC projectA-Dal appears in compile time dependencies as well) Is it intended behavior? IMO I would expect that it wont be possible and I’ll get compilation error…

gradle version 1.11

thanks in advance

I’ve found the answer

this is due to default dependency resolution for project dependencies

By default, when you declare dependency to projectA, you actually declare dependency to the ‘default’ configuration of the projectA. If you need to depend on a specific configuration of projectA, use map notation for projects: configurationName project(path: ‘:projectA’, configuration: ‘someOtherConfiguration’)