Intellij-idea gradle子模块会忘记根项目依赖性

时间:2016-02-01 22:33:44

标签: intellij-idea gradle

我有两个gradle项目,如此定义

apiclient (root)
  | src\
  | build.gradle
  |--- android (module)
         | src\
         | build.gradle

这些项目不在maven上,而模块apiclient.android依赖于根模块(apiclient)。

我继续使用项目结构添加apiclient ... - >每当我在gradle工具窗口中单击refresh时,依赖关系对话框和引用就会从.iml文件中删除。

如何让子模块忘记忘记父模块依赖?

编辑:根据请求生成build.gradle文件。

apiclient build.gradle

group 'emby.apiclient'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.7

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'com.google.guava:guava:18.0'
    compile 'org.java-websocket:Java-WebSocket:1.3.0'
}

apiclient.android build.gradle

group 'emby.apiclient'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.7

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'com.google.code.gson:gson:2.5'
    compile 'com.mcxiaoke.volley:library:1.0.16'
    compile 'com.squareup.okhttp:okhttp:2.1.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
    compile 'emby.apiclient:apiclient:1.0-SNAPSHOT'
}

最后一行compile 'emby.apiclient:apiclient:1.0-SNAPSHOT'在gradle项目窗口中以红色下划线标出红色。我也尝试了compile project 'apiclient',结果没有改变。

settings.gradle

rootProject.name = 'apiclient'
include 'android'
findProject(':android')?.name = 'emby.apiclient.android'

1 个答案:

答案 0 :(得分:0)

在/ android build.gradle文件中,您需要将compile project(":apiclient")添加到依赖项列表中。我发现IntelliJ的“你想在类路径中添加依赖关系”对话框的难点只是将它添加到.iml文件中,该文件不是作为构建的一部分运行的。