简体   繁体   English

Tycho 编译器插件无法生成 lombok 函数

[英]Tycho compiler plugin fail to generate lombok functions

We have an OSGI framework and we are introducing Lombok in it.我们有一个 OSGI 框架,我们正在其中引入 Lombok。 In the pom.xml we added the dependency在 pom.xml 我们添加了依赖

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.22</version>
</dependency>

but mvn install compilation still fail with但 mvn install 编译仍然失败

org.eclipse.tycho:tycho-compiler-plugin:2.0.0:compile (default-compile) on project XXX: Compilation failure: Compilation failure: [ERROR] ... [ERROR] ... [ERROR] The method setXXX(String) is undefined for the type XXX org.eclipse.tycho:tycho-compiler-plugin:2.0.0:compile (default-compile) on project XXX: Compilation failure: Compilation failure: [ERROR] ... [ERROR] ... [ERROR] 方法setXXX(String)未定义类型 XXX

From Eclipse, everything compile and is working fine.在 Eclipse 中,一切都可以编译并且工作正常。 lombok.jar was also added to Bundle-ClassPath of MANIFEST.MF We added the annotationProcessorPaths to the pom.xml without success lombok.jar也被添加到了MANIFEST.MFBundle-ClassPath我们在pom.xml中添加了annotationProcessorPaths没有成功

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <annotationProcessorPaths>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.22</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

EDIT Even when configuring tycho compiler it doesn't work编辑即使在配置 tycho 编译器时它也不起作用

        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-compiler-plugin</artifactId>
            <version>${tycho-version}</version>
            <configuration>
                <source>${compileSource}</source>
                <target>${compileSource}</target>
                <compilerArguments>
                    <processor> lombok.launch.AnnotationProcessorHider$AnnotationProcessor
                    </processor>
                </compilerArguments>
            </configuration>
        </plugin>

when I added set MAVEN_OPTS="-javaagent:C:\\Eclipse\\lombok.jar" compilation worked, so is there any way to add this argument inside the compiler configuration in the pom.xml with a generic path to the lombok.jar当我添加set MAVEN_OPTS="-javaagent:C:\\Eclipse\\lombok.jar"编译工作时,有没有办法在pom.xml的编译器配置中添加这个参数,并带有到lombok.jar

I'm succeeded in using Lombok within a eclipse plugin, and building the plugin with tycho.我成功地在 Eclipse 插件中使用了 Lombok,并使用 tycho 构建了插件。 https://github.com/poul-m/tycho-lombokizer https://github.com/poul-m/tycho-lombokizer

when I added set MAVEN_OPTS="-javaagent:C:\Eclipse\lombok.jar" compilation worked, so is there any way to add this argument inside the compiler configuration in the pom.xml with a generic path to the lombok.jar当我添加 set MAVEN_OPTS="-javaagent:C:\Eclipse\lombok.jar" 编译工作时,有没有办法在 pom.xml 的编译器配置中添加这个参数,并带有到 lombok.jar 的通用路径

I was able to create .mvn/jvm.config in my project directory and configure a path relative to the project directory in there.我能够在我的项目目录中创建.mvn/jvm.config并在其中配置相对于项目目录的路径。 Maven Tycho then successfully build my project with Lombok annotations:然后 Maven Tycho 使用 Lombok 注释成功构建了我的项目:

This would be the content of the jvm.config:这将是 jvm.config 的内容:

-javaagent:project/relative/path/to/lombok.jar

https://maven.apache.org/configure.html https://maven.apache.org/configure.html

Edit: I only tried it with Maven Tycho 2.7.0编辑:我只用 Maven Tycho 2.7.0 尝试过

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM