Why the gradle Android plugin does not generate dependencies for the intellij idea module

I have a gradle project with four subprojects and I use the idea plugin to create the idea project and modules. One of the subprojects is the android module.

Here is the build.gradle code:

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.6' } } apply plugin: 'android' android { buildToolsVersion "18.1.1" compileSdkVersion 16 sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aild.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } instrumentTest.setRoot('tests') } } repositories { mavenCentral() } dependencies { compile( ['org.atmosphere:wasync:1.1.0'], ['org.codehaus.jackson:jackson-mapper-lgpl:1.9.13'], ['org.projectlombok:lombok:0.+'], ['org.apache.httpcomponents:httpmime:4.3.1'], ['commons-io:commons-io:2.+'], ['com.google.guava:guava:14.+'] ) compile fileTree(dir: 'libs', include: '*.jar') } 

The problem is this: when using "gradle idea" to generate intelligent modules of the idea, as a result of the android module there are no dependencies, and I can not understand why. Is there something wrong with my configuration?

Other subprojects (using the java plugin) have no problems imported into idea modules without problems.

I am using gradle 1.7.

+6
source share
2 answers

Importing a gradle project into Idea solved a dependency problem that was not imported for the android module, but caused a bunch of more (and worse) problems described in this question: IntelliJ, Android, and Gradle

+3
source

Idea plugin can handle the configuration of the compile java plugin, but not the Android plugin (at the moment). But this can be solved manually, place it next to the android {} and apply plugin: blocks:

 beforeEvaluate { idea.module.scopes.put("COMPILE", ["plus": [], "minus": []]) idea.module.scopes.COMPILE.plus += configurations.compile idea.module.sourceDirs += file('src') } 

The first line is related to the internal details of the idea plugin, the second actually adds the dependencies declared in the compile configuration inside closure dependencies . Thirdly, this is not related to the issue, but adds the src folder to Idea sources.

0
source

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


All Articles