我有一个带有gradle构建文件的IntelliJ项目,该文件包含来自maven中央存储库的多个项目。一个这样的依赖是Geb。
当我浏览课程时,我偶尔会遇到一个看起来很有趣的Geb课程。我选择"转到声明" 并得到一个悲伤的"找不到声明转到" 。
显然这是因为IntelliJ没有加载Geb源文件。但是如果不将Geb作为我的项目中的源代码,我该怎么做呢?我不希望Geb从源代码编译到我的项目中,因为我已将它作为依赖项包含在我的gradle构建文件中。
gradle脚本的相关部分:
apply plugin: 'groovy'
apply plugin: 'idea'
dependencies {
// need to depend on geb-spock
testCompile "org.gebish:geb-spock:0.13.1"
testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
testCompile "org.apache.commons:commons-lang3:3.4"
testCompile "io.github.bonigarcia:webdrivermanager:1.5.0"
testRuntime "org.seleniumhq.selenium:selenium-support:2.53.1"
}
idea {
module {
downloadJavadoc = true // defaults to false
downloadSources = true
}
}
答案 0 :(得分:1)
这是一个完整的构建脚本,可以下载所有依赖项:
apply plugin: 'java'
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true // defaults to false
downloadSources = true
}
}
repositories {
mavenCentral()
}
dependencies {
// need to depend on geb-spock
testCompile "org.gebish:geb-spock:0.13.1"
testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
testCompile "org.apache.commons:commons-lang3:3.4"
testCompile "io.github.bonigarcia:webdrivermanager:1.5.0"
testRuntime "org.seleniumhq.selenium:selenium-support:2.53.1"
}
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
}
依赖项显示在列表中:
我可以浏览源代码,你可以在那里看到评论:
可能的解释之一可能是您的存储库列表中有一个repo,例如mavenLocal或缓存Artifactory,它没有源依赖项。
存储库的顺序很重要,因此如果mavenLocal是第一个并且源不可用,我相信它们不会被下载。可能的解决方法是从mavenLocal中删除依赖项并重新下载它,更改依赖项的顺序,或者如果它是父脚本,则在添加存储库时豁免子项目:
configure(allprojects - project(':my-subproj')) {
repositories {
...
}
}
我不认为有任何方法可以阻止子项目的构建脚本。它必须在父母身上完成。