有没有办法在 ECJ 中编译 lomboked 代码而不将 lombok 设置为 maven 进程的javaaagent?
下面的代码片段仅在我使用 lombok 作为代理运行 mvn 时才有效
<profile>
<id>ecj</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>eclipse</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
MAVEN_OPTS=-javaagent:lombok.jar mvn -P ecj 结果编译成功。
然而,运行只会mvn -P ecj产生通常的非龙目岛错误,例如:__ cannot be resolved to a type
我尝试使用com.reubenpeeris.maven:lombok-eclipse-compiler:1.3
但失败了Compilation failure
Unrecognized option: target/generated-sources/annotations,我认为这意味着这个编译器太旧了。
我也尝试添加
<fork>true</fork>
<compilerArgs>
<arg>-javaagent:lombok.jar</arg>
</compilerArgs>
Run Code Online (Sandbox Code Playgroud)
但它似乎没有任何效果。