无法使用 javac 和 lombok 在控制台编译 .h 文件。错误:找不到 lombok 包。

huangapple go评论135阅读模式
英文:

Can't compile .h file in console with javac and lombok. Error: package lombok does not exist

问题

我需要为基于JNI的本地库编译.h文件。在我向项目中添加了一些Lombok注解后,我无法使用javac编译.h文件。我正在使用IntelliJ和Gradle。我尝试在IDE控制台中执行以下命令:

javac -h jni src/java/main/com/my/project/*.java

但是会得到错误:

src/java/main/com/my/project/Appjava:3: error: package lombok does not exist
import lombok.AccessLevel;
^ 
src/java/main/com/my/project/App.java:4: error: package lombok does not exist
import lombok.RequiredArgsConstructor;
^ 
src/java/main/com/my/project/App.java:5: error: package lombok does not exist
import lombok.Value;

以及其他类中的许多类似错误。App类中的第3、4和5行:

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.Value;

在构建的Gradle中:

compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'

同时启用了注解处理,并安装了Lombok插件。我可以在IDE中构建项目,但无法执行javac命令。我该如何修复这个问题?

英文:

I need to compile .h file for my native library based on JNI. After I add some lombok annotations to my project I can't compile .h file with javac. I'm using IntelliJ and grade. I'm trying to perform next command in ide console:

javac -h jni src/java/main/com/my/project/*.java

And get error:

 src/java/main/com/my/project/Appjava:3: error: package lombok does not
 exist import lombok.AccessLevel;
              ^ 
src/java/main/com/my/project/App.java:4: error: package lombok does not exist import lombok.RequiredArgsConstructor;
              ^ 
src/java/main/com/my/project/App.java:5: error: package lombok >does not exist import lombok.Value;

and many similar errors in other classes. 3, 4 and 5 lines in App class:

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.Value;

in build gradle:

 compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'

Also annotation processing enabled and lombok plugin installed. I can build project in my ide but can't perform command javac. How I can fix it?

答案1

得分: 2

如果您在命令行上运行 javac,则 Gradle 不会起作用;您需要传递类路径 -cp <all_jars>

英文:

if you are running javac on command line then the gradle won't come into play; you will need to pass the classpath -cp &lt;all_jars&gt;

huangapple
  • 本文由 发表于 2020年7月23日 15:19:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/63048890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定