Help with using a dependency on a configuration


(Rob Reece) #1

According to this documentation, I should be able to declare a dependency on another configuration in my project. However, Gradle fails to compile my project when I do this. I have to actually extend the configuration myself and add the configuration output to the compilation classpath of the dependent configuration.

The non-working syntax is

dependencies {
  compile configurations.apiCompile
}

However, what I actually have to do is

configurations {
  apiCompile
  compile.extendsFrom apiComplie
}

sourceSets {
  main {
    java {
      compileClasspath += api.output
    }
  }
}

Maybe I have the syntax wrong in my first approach?