Gradle: Is there no such property for a class error thrown into a submodule?

I am trying to declare dependencies in my gradle project using the method described in this answer .

However, when I do this, I get this error:

 No such property: libraries for class 

How can i fix this?

The dependencies declared as top level properties of build.gradle are as follows:

 ext.libraries = [ junit: 'junit:junit:4.10' ] 

Trying to get a dependency in the module level of build.gradle (where the error occurs):

 testCompile([ libraries.junit ]) 

Mistake:

 No such property: libraries for class: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 
+5
java properties dependencies gradle
Dec 17 '15 at 15:54
source share
1 answer
  • At the top level settings.gradle enable your subproject:

     include 'subproject' 
  • At the top level of build.gradle specify ext properties:

     ext.libraries = [junit: 'junit:junit:4.10'] 

it doesn't have to be a map if you use only one value, but I stick to your formatting.

  1. To use this in your subproject build.gradle :

     dependencies{ testCompile libraries.junit } 
+3
Dec 21 '15 at 16:18
source share



All Articles