【发布时间】:2019-09-06 19:35:49
【问题描述】:
我在 Gradle 中有一个多模块项目。
我将常用功能重构为一个名为common 的模块。
我在使用common 模块的src/main/java 下的类的多模块项目的不同模块(比如说module A)中进行了测试。
我可以从module A 的测试类中的common 模块导入这些类,但是当我运行测试时,我收到以下错误:
错误:包 'common.bla...' 不存在。
这是 module A 的 build.gradle 文件,它依赖于 common 模块进行测试(我已经尝试了所有这些选项):
dependencies {
compile project(':common')
testCompile project(':common')
testRuntime project(':common')
runtime project(':common')
implementation project(":common")
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
implementation 'junit:junit:4.12'
testCompileOnly project(':common')
testRuntimeOnly project(':common')
testImplementation project(':common')
runtimeOnly project(':common')
testCompile project(":common").sourceSets.test.output
compile project(":common").sourceSets.test.output
testRuntime fileTree(dir: 'libs', include: ['*.jar'])
}
我还验证了在 common/build/libs 中创建了一个 jar。
我还能尝试什么?
【问题讨论】:
-
您能否添加一些屏幕,您的项目结构在 IDE 中的外观如何?
标签: java gradle dependency-management multi-module