title: Conditional dependencies
body: <p>On Gradle (more specifically with Android) how can I have conditional dependency so that they get loaded either from the parent project like this:</p>
  
  <pre><code>compile project(':lib') 
  </code></pre>
  
  <p>or from a repository is not present in the parent project:</p>
  
  <pre><code>compile 'com.sample:lib:+'
  </code></pre>
  
  <p>one possible solution I thought of is to do this:</p>
  
  <pre><code>compile allprojects.find({ it.name.equal('lib')}) != null  ? project(':lib') : 'com.sample:lib:+'
  </code></pre>
  
  <p>but the allProjects property is not available in the dependencies task.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>The reason I'm searching for this because we have two setups, one with our sub-projects imported from different git repositories at the development machines and the second one importing the dependencies from our dependencies server for CI.</p>
  
  <p>An alternative I've tried is to set this in the parent project:</p>
  
  <pre><code>ext.projectNames = allprojects.collect{ it.name }
  </code></pre>
  
  <p>and in the subproject I'm doing this:</p>
  
  <pre><code>compile projectNames.contains('lib') ? project(':lib') : 'com.sample:lib:+'
  </code></pre>
  
  <p>This works, but however since in the current setup we run just one of the subproject in the CI server this property won't exist and will fail so may have to extract this behaviour to a plugin and maybe play with getParent()</p>