diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml index 576a3c65ce..1974a07ad2 100644 --- a/.github/workflows/ant.yml +++ b/.github/workflows/ant.yml @@ -151,3 +151,42 @@ jobs: - name: Compile in container run: docker run --entrypoint="" -v $(pwd)/lombok.jar:/workspace/lombok.jar $IMAGE_NAME /bin/bash -c "cd classpath; ${{ matrix.tool.cmd }}" + + module-tests: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + jdk: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] + dir: [multiReleaseJar, moduleBasedMultiProject] + fail-fast: false + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.jdk }} + distribution: 'zulu' + + - uses: actions/download-artifact@v3 + with: + name: lombok.jar + path: dist + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ivyCache + lib + key: ${{ runner.os }}-${{ hashFiles('**/ivy.xml') }} + restore-keys: | + ${{ runner.os }}- + + - name: Run tests + working-directory: ./test/manual/${{ matrix.dir }}/ + run: ./runTests + diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index cb0065e76d..65e065f7c9 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -55,6 +55,7 @@ + diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index e4f1760222..0d26ca57ee 100755 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2019 The Project Lombok Authors. + * Copyright (C) 2009-2023 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,6 +40,7 @@ import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -323,7 +324,10 @@ public static void main(String[] rawArgs) { } } - delombok.delombok(); + boolean success = delombok.delombok(); + if (!success) { + System.exit(1); + } } catch (Exception e) { if (!args.quiet) { String msg = e.getMessage(); @@ -744,6 +748,11 @@ public boolean delombok() throws IOException { ((BaseFileManager) jfm_).setContext(context); // reinit with options ((BaseFileManager) jfm_).handleOptions(args.getDeferredFileManagerOptions()); } + + if (jfm_.isSupportedOption("--multi-release") == 1) { + List compilerVersionString = Arrays.asList(Integer.toString(Javac.getJavaCompilerVersion())); + jfm_.handleOption("--multi-release", compilerVersionString.iterator()); + } } if (Javac.getJavaCompilerVersion() < 9) { @@ -827,7 +836,7 @@ public boolean delombok() throws IOException { } delegate.close(); - return true; + return compiler.errorCount() == 0; } private String unpackClasspath(String cp) { diff --git a/test/manual/moduleBasedMultiProject/runTests b/test/manual/moduleBasedMultiProject/runTests index 48557b4394..c7976c31b2 100755 --- a/test/manual/moduleBasedMultiProject/runTests +++ b/test/manual/moduleBasedMultiProject/runTests @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash +set -euo pipefail echo 'This will build, module-style, 2 modules with lombok dependencies. If the compilation works without error or warning, lombok is working as designed.' mkdir -p out/projA mkdir -p out/projB diff --git a/test/manual/multiReleaseJar/.gitignore b/test/manual/multiReleaseJar/.gitignore new file mode 100644 index 0000000000..e2e7327cde --- /dev/null +++ b/test/manual/multiReleaseJar/.gitignore @@ -0,0 +1 @@ +/out diff --git a/test/manual/multiReleaseJar/runTests b/test/manual/multiReleaseJar/runTests new file mode 100755 index 0000000000..273db8bac5 --- /dev/null +++ b/test/manual/multiReleaseJar/runTests @@ -0,0 +1,13 @@ +#!/bin/bash +set -euo pipefail +echo 'This will build a project with a multi release jar dependency. If the compilation works without error or warning, lombok is working as designed.' +mkdir -p out/javac + +# We cannot use the link because javac can infer the module name +JAR=$(realpath ../../../lib/test/org.jetbrains-annotations.jar) + +javac --processor-path ../../../dist/lombok.jar -p ../../../dist/lombok.jar:$JAR -d out/javac src/module-info.java src/pkg/MultiReleaseJarTest.java + +echo Now we try to delombok and see if it works as designed. + +java -jar ../../../dist/lombok.jar delombok --module-path $JAR -d out/delombok src diff --git a/test/manual/multiReleaseJar/src/module-info.java b/test/manual/multiReleaseJar/src/module-info.java new file mode 100644 index 0000000000..d1304437c7 --- /dev/null +++ b/test/manual/multiReleaseJar/src/module-info.java @@ -0,0 +1,4 @@ +module pkg { + requires static org.jetbrains.annotations; + requires static lombok; +} \ No newline at end of file diff --git a/test/manual/multiReleaseJar/src/pkg/MultiReleaseJarTest.java b/test/manual/multiReleaseJar/src/pkg/MultiReleaseJarTest.java new file mode 100644 index 0000000000..7678439672 --- /dev/null +++ b/test/manual/multiReleaseJar/src/pkg/MultiReleaseJarTest.java @@ -0,0 +1,10 @@ +package pkg; + +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +@Getter +public class MultiReleaseJarTest { + @NotNull + private String test; +} \ No newline at end of file