【发布时间】:2016-02-01 22:33:44
【问题描述】:
我有两个这样定义的 gradle 项目
apiclient(根) |源\ |构建.gradle |--- 安卓(模块) |源\ |构建.gradle这些项目还没有在 maven 上,模块 apiclient.android 依赖于根模块 (apiclient)。
我一直在使用项目结构添加 apiclient...-> 依赖对话框,并且每当我在 gradle 工具窗口中单击刷新时,引用就会不断从 .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'
【问题讨论】:
-
你不是在 gradle 中管理依赖,你能显示你的 build.gradle 文件吗?
-
更新了 build.gradle 文件。
-
你需要在 settings.gradle 文件中包含你的子项目,让 gradle 现在它正在构建一个多项目构建
-
两个项目都列在 settings.gradle 中。
-
appclient.android是什么,是这样命名的文件夹吗?
标签: intellij-idea gradle