IntelliJ gradle - unknown properties

Error:

Build the file 'C: \ Users \ Me \ Dev \ project \ app \ build.gradle' line: 21

  • What went wrong: There was a problem evaluating the root project "application". Failed to get unknown "library" properties for an object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

inside app.gradle

dependencies{ compile libraries.my_lib deploy libraries.my_lib } 

inside project.gradle

 ext.libraries = { my_lib: 'com.myCompany:my-lib:1.0.0' } 

inside pom.xml

 <modules> <module>my-lib</modules> </modules> 

Pressing CTRL + Space in app.gradle libaries. shows the my_lib library, which can be autocomplete, but when compiled using gradle clean deploy it fails and returns the message above.

This only happened after I updated the IDE to the latest version of IntelliJ.

+5
source share
1 answer

ext defines extensions only for the project in which it was called. In your case, libraries.my_lib is defined in project.gradle (I think it is build.gradle in the project directory) and thus is not available in another build file ( app.gradle , which I think is build.gradle in app again )) if project not the parent of the app . Projects for children have access to parent properties, and this is the only way to share ext : projects must be connected to each other.

BTW, you can define the properties in the gradle.properties file. There can be many, one for each project in your assembly. Placing one gradle.properties in the root of your assembly, you apply its contents to the root of your project tree, thereby making properties available worldwide (the same applies to the ext block of the root object, as follows from the previous paragraph).

+2
source

Source: https://habr.com/ru/post/1273101/


All Articles