jabel icon indicating copy to clipboard operation
jabel copied to clipboard

Support / example of applying Jabel only to main code on jdk8 and having test code run/compile on jdk13

Open astubbs opened this issue 5 years ago • 2 comments

As described here: https://stackoverflow.com/questions/1213897/different-maven-compiler-versions-for-test-and-main

An example would be great to include in the instructions.

astubbs avatar Aug 12 '20 12:08 astubbs

I appear to have it working via adding two different executions as per the stack over flow question:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <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>
                </configuration>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <!-- jabel setup -->
                            <!-- Make sure we're not using Java 9+ APIs - restricts JDK APIs to those in 8 -->
                            <release>8</release>
                            <annotationProcessors>
                                <annotationProcessor>com.github.bsideup.jabel.JabelJavacProcessor</annotationProcessor>
                                <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
                            </annotationProcessors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <release>13</release>
<!-- only run Lombok, don't use Jabel on test classes -->
                            <annotationProcessors>
                              <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
                            </annotationProcessors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

astubbs avatar Aug 12 '20 12:08 astubbs

FYI I've moved away from this now, and am instead compiling everything on 13, targeting 8, but running fail safe multiple times on different jvms.

astubbs avatar Aug 13 '20 16:08 astubbs