How to iterate over dependencies that have type "Project"?

How to iterate over dependencies that have type “Project”?

If I have the following dependencies in build.gradle:

dependencies {
        compile "org.apache.commons:commons-lang3:3.1@jar"
        compile project(":App1")
        runtime "postgresql:postgresql:9.1-901.jdbc4@jar"
                runtime project(":App2")
}

Can I iterate over all dependencies and identify when the dependency is a project?

for instance: I want to do an iteration as i described below:

project.configurations.runtime.each {
  it ->
   if ( it.isProject() ) {
     println "Project dependency: ${it.name}"
   }
    } ;

And the output will be:

Project dependency: App1
Project dependency: App2

You probably want something like,

project.configurations
  .collectMany { it.allDependencies }
  .findAll { it instanceof ProjectDependency }
2 Likes

works!! thanks!!