[英]Lombok module not found with Java 11 and Gradle
Currently, I cannot get this project to run, somehow the Gradle cannot find the Lombok module.目前,我无法让这个项目运行,不知何故 Gradle 找不到 Lombok 模块。 I'm using我在用着
Based on this github issue , then the problem should be solved at this version, but it doesn't work for me.基于这个github issue ,那么问题应该在这个版本解决了,但是对我不起作用。
Here is the error这是错误
> Task :Model-library:compileJava FAILED
/home/dauto98/path..to..project/src/main/java/module-info.java:2: error: module not found: lombok
requires static lombok;
below is my gradle.build.kts file下面是我的 gradle.build.kts 文件
plugins {
java
`java-library`
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("junit", "junit", "4.12")
compileOnly("org.projectlombok:lombok:1.18.12")
annotationProcessor("org.projectlombok:lombok:1.18.12")
testCompileOnly("org.projectlombok:lombok:1.18.12")
testAnnotationProcessor("org.projectlombok:lombok:1.18.12")
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_11
}
my module-info.java
file我的module-info.java
文件
module my.module.main {
requires static lombok;
}
After a while, I found out that the problem is I didn't turn on module path inference explicitly in the Gradle build file as stated in here一段时间后,我发现问题是我没有在 Gradle 构建文件中显式打开模块路径推断,如此处所述
Add this to the gradle.build.kts
file:将此添加到gradle.build.kts
文件:
plugins.withType<JavaPlugin>().configureEach {
configure<JavaPluginExtension> {
modularity.inferModulePath.set(true)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.