I want to determine the dependency type at runtime

In our project we have something like 50 components. Our teams have the concept of workspaces. Whether components have project dependencies between each other or establish an external dependency depends on which of them are checked out in the workspace as source projects. How can we model that with Gradle?

You could do something like this:

dependencies {
  def createDependency(componentName) {
   if (isCheckedOutInWorkSpace()) {
      return project(":$componentName")
   } else {
      return "org.mycompo:$componentName:$versionNumber"

Of course you would need some dynamic stuff in the settings.gradle that add all the source projects to the multi-project build.

I tried this snippet - but it doesn’t seem to work. I presume we can have createDependency with no input . I am deciding the dependency based on properties passed in the build command line -pMyValue=test