Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works with Lombok? #35

Open
astubbs opened this issue Aug 11, 2020 · 5 comments
Open

Works with Lombok? #35

astubbs opened this issue Aug 11, 2020 · 5 comments

Comments

@astubbs
Copy link

astubbs commented Aug 11, 2020

Does this work also when you're using Lombok as an active compiler plugin? I have Lombok included as a compiler annotation processor, but I add Jabel and it's annotationProcessors class directive, and the Lombok enhancements don't seem to be active anymore.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.google.auto.service</groupId>
                            <artifactId>auto-service</artifactId>
                            <version>${auto-service.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <!-- jabel setup-->
                        <path>
                            <groupId>com.github.bsideup.jabel</groupId>
                            <artifactId>jabel-javac-plugin</artifactId>
                            <version>0.2.0</version>
                        </path>
                    </annotationProcessorPaths>
                    <!-- enable language preview features -->
                    <target>13</target>
                    <!-- jabel setup -->
                    <!-- Make sure we're not using Java 9+ APIs -->
                    <release>8</release>
                    <annotationProcessors>
                        <annotationProcessor>com.github.bsideup.jabel.JabelJavacProcessor</annotationProcessor>
                    </annotationProcessors>
                </configuration>
            </plugin>
@astubbs astubbs changed the title works with Lombok? Works with Lombok? Aug 11, 2020
@astubbs
Copy link
Author

astubbs commented Aug 12, 2020

Given the popularity of Lombok and maven, including a working example of using jabel with maven would be awesome. I'll keep looking into it. My first clue is this:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessors

<annotationProcessors>
Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.

Which implies to me, that because Jabel seems to require listing it as an explicit annotationProcessor, this causes the the default annotation processors discovery process to be disabled (as it "only applies of annotationProcessors is not set. Apparently... Which might mean that Lombok even though is listed, is not even being run because in this setup it relies on the auto discovery process...

@astubbs
Copy link
Author

astubbs commented Aug 12, 2020

@astubbs
Copy link
Author

astubbs commented Aug 12, 2020

Ok, tracked down the Lombok annotation processor classes;

As the automatic detection method is turned off when any processor is configured explicitly, I add this to my list:
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>

Now m configuration as this the compile passes:

                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <!-- jabel setup-->
                        <path>
                            <groupId>com.github.bsideup.jabel</groupId>
                            <artifactId>jabel-javac-plugin</artifactId>
                            <version>0.2.0</version>
                        </path>
                    </annotationProcessorPaths>
                    <!-- enable language preview features -->
                    <target>13</target>
                    <!-- jabel setup -->
                    <!-- Make sure we're not using Java 9+ APIs -->
<!--                    <release>8</release>-->
                    <annotationProcessors>
                        <annotationProcessor>com.github.bsideup.jabel.JabelJavacProcessor</annotationProcessor>
                        <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
                    </annotationProcessors>
                </configuration>

@astubbs
Copy link
Author

astubbs commented Aug 12, 2020

FYI this does seem to make IDEA complain with

Error:java: Annotation processor 'lombok.launch.AnnotationProcessorHider.AnnotationProcessor' not found
and warns;
Warning:java: Supported source version 'RELEASE_8' from annotation processor 'com.github.bsideup.jabel.JabelJavacProcessor' less than -source '13'

So added to the override in the IDEA profile by setting the annotationProcessors tree to empty, seems to have relaxed Intellij:

        <profile>
            <id>intellij-idea-only</id>
            <activation>
                <property>
                    <name>idea.maven.embedder.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <release>13</release>
                            <compilerArgs>
                                <arg>--enable-preview</arg>
                            </compilerArgs>
                            <annotationProcessors>
                            </annotationProcessors>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

@magicprinc
Copy link

magicprinc commented Mar 13, 2023

It works! :-)

See more information here
#175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants