我目前有一个项目,其层次结构如下:
shared |
|-consumer
|-provider
共享项目的build.gradle 如下:
apply plugin:'org.springframework.boot' //if i remove this line,everything works fine
apply plugin:'io.spring.dependency-management'
apply plugin:'java'
apply plugin:'application'
mainClassName='A.M'
sourceSets{
main{
java{
srcDir './src'
}
}
}
subprojects{
apply plugin:'java'
apply plugin:'application'
sourceSets{
main{
java{
srcDir './src'
}
}
}
dependencies{
implementation project(':shared')
}
mainClassName = 'B.M'
}
我的 shared:provider 项目的 build.gradle 为空
shared:provider 的主要类别是:
package B;
import A.*;
public class M {
public static void main(String[] args){
}
}
当我执行gradlew build
时,它会报告can't resolve symbol A
C:\Users\ratsafalig\Desktop\Java\HelloDubbo\demo>gradlew build
> Task :shared:provider:compileJava FAILED
C:\Users\ratsafalig\Desktop\Java\HelloDubbo\demo\provider\src\B\M.java:3: 错误: 程序包A不存在
import A.*;
^
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shared:provider:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
25 actionable tasks: 1 executed, 24 up-to-date
我的问题是,当我在apply plugin:'org.springframework.boot'
项目的构建脚本中删除shared
时,一切正常。
这是因为org.springframework.boot
插件会覆盖build
任务还是什么?