我有一个gradle java项目。我最近将我的源文件重新组织到dub文件夹中。
最初我所有的源文件都在文件夹里..。
project_root/src/main/java
现在我有Foo.java班在..。
project_root/src/main/java/folderA
我有Bar.java班在..。
project_root/src/main/java/folderB
酒吧靠的是福。当我更改类Foo时,类Bar不会重新编译。因为Foo已经改变了,类Bar应该有编译错误,但是它们没有命中。
我的build.gradle文件如下…
apply plugin: 'java'
// Use maven repository
repositories {
mavenCentral()
google()
}
dependencies {
implementation 'org.eclipse.jetty:jetty-servlet:9.4.19.v20190610'
implementation 'org.eclipse.jetty:jetty-client:9.4.19.v20190610'
implementation 'mysql:mysql-connector-java:8.0.16'
implementation 'org.apache.commons:commons-dbcp2:2.7.0'
implementation 'org.jdbi:jdbi3-core:3.10.1'
implementation 'com.google.firebase:firebase-admin:6.11.0'
compile 'com.google.apis:google-api-services-oauth2:v1-rev155-1.25.0'
// implementation 'com.google.gms:google-services:4.3.3'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
compile project('chesslib')
runtime files('../../chesslib/build/libs/chesslib-1.1.12.jar')
}
task runServer(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'ChessServer'
}
task runClient(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'ChessClient'
standardInput = System.in // without this, using Scanner on System.in won't work
}
task runCLITestApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'CLITestApp'
standardInput = System.in
}发布于 2020-03-05 09:14:07
如文献资料中所述,在Gradle中遇到增量编译的限制。
如果包声明与源文件的目录结构不匹配(例如/MyClass.java),那么增量编译会产生中断的输出。错误的类可能被重新编译,输出中可能有剩余的类文件。
因此,建议使用经典的包到文件夹结构,或者禁用增量编译:
compileJava {
options.incremental = false
}发布于 2020-03-02 02:10:41
“当我更改类Foo时,类Bar不会重新编译。”它不会自动重新编译,您需要重新构建项目
https://stackoverflow.com/questions/60480743
复制相似问题