aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2020-02-14 00:06:52 +0100
committerRoel Spilker <r.spilker@gmail.com>2020-02-14 00:07:45 +0100
commit0d7540db0cc0c9a2758799522925f09eddeb7420 (patch)
tree10f7b31859ebe9ed670b04ff4007406e5de3dd7a
parenta8dd99d9f080be6839fe507ade104fccac115de4 (diff)
downloadlombok-0d7540db0cc0c9a2758799522925f09eddeb7420.tar.gz
lombok-0d7540db0cc0c9a2758799522925f09eddeb7420.tar.bz2
lombok-0d7540db0cc0c9a2758799522925f09eddeb7420.zip
(#2125) Extract mapstruct binding to separate module.
-rw-r--r--build.xml33
-rw-r--r--src/bindings/mapstruct/lombok/mapstruct/NotifierHider.java35
-rw-r--r--src/bindings/mapstruct/module-info.java29
-rw-r--r--src/core9/module-info.java4
-rw-r--r--src/j9stubs/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.java (renamed from src/j9stubs/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.java)0
-rw-r--r--src/launch/lombok/launch/AnnotationProcessor.java15
6 files changed, 93 insertions, 23 deletions
diff --git a/build.xml b/build.xml
index 891948c6..08adc3e2 100644
--- a/build.xml
+++ b/build.xml
@@ -185,7 +185,6 @@ Your current version is:
anymore until you 'ant clean'. That's very much not desired, so we kill the processor, which stops lombok from running.
We re-create the file at the end of this target. -->
<delete file="build/lombok/META-INF/services/javax.annotation.processing.Processor" quiet="true" />
- <delete file="build/lombok/META-INF/services/org.mapstruct.ap.spi.AstModifyingAnnotationProcessor" quiet="true" />
<ivy:compile destdir="build/stubsstubs" source="1.5" target="1.5" ecj="true" nowarn="true">
<bootclasspath path="${rt-openjdk8}" />
<src path="src/stubsstubs" />
@@ -262,13 +261,6 @@ Your current version is:
<!-- The above is because javac9 warns about 'service interface provided but not exported or used', probably because lombok uses SPI internally, and uses the 'old' classpath discovery system for it. We're fine with this, hence, ignore this warning. -->
<src path="src/core9" />
</javac>
- <mkdir dir="build/lombokMapstruct" />
- <javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/lombokMapstruct">
- <src path="src/j9stubs" />
- <!-- This includes org.mapstruct.ap.spi.AstModifyingAnnotationProcessor; putting this on the classpath doesn't work (needs to be internal or a module) so we just add it and then delete the class file for convenience. -->
- </javac>
- <mkdir dir="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi" />
- <move file="build/lombokMapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class" tofile="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.SCL.lombok" />
<ivy:compile destdir="build/lombok/Class50" source="1.5" target="1.6" ecj="true" nowarn="true">
<bootclasspath location="build/stubs" />
@@ -312,7 +304,6 @@ Your current version is:
<mkdir dir="build/lombok/META-INF/services" />
<echo file="build/lombok/META-INF/services/javax.annotation.processing.Processor">lombok.launch.AnnotationProcessorHider$AnnotationProcessor
lombok.launch.AnnotationProcessorHider$ClaimingProcessor</echo>
- <echo file="build/lombok/META-INF/services/org.mapstruct.ap.spi.AstModifyingAnnotationProcessor">lombok.launch.AnnotationProcessorHider$AstModificationNotifier</echo>
<mkdir dir="build/lombok/META-INF/gradle" />
<echo file="build/lombok/META-INF/gradle/incremental.annotation.processors">lombok.launch.AnnotationProcessorHider$AnnotationProcessor,isolating
lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
@@ -1072,4 +1063,28 @@ You can also create your own by writing a 'testenvironment.properties' file. The
<compilerarg value="org.projectlombok.testAp.TestAp,lombok.launch.AnnotationProcessorHider$AnnotationProcessor" />
</javac>
</target>
+
+ <target name="mapstructBinding" depends="dist">
+ <mkdir dir="build/mapstruct" />
+ <mkdir dir="build/mapstruct-module-path" />
+ <copy file="dist/lombok.jar" todir="build/mapstruct-module-path" />
+
+ <javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/mapstruct">
+ <src path="src/j9stubs" />
+ <!-- This includes org.mapstruct.ap.spi.AstModifyingAnnotationProcessor; putting this on the classpath doesn't work (needs to be internal or a module) so we just add it and then delete the class file for convenience. -->
+ </javac>
+ <jar destfile="build/mapstruct-module-path/mapstruct-processor.jar" basedir="build/mapstruct" includes="org/**">
+ <manifest>
+ <attribute name="Automatic-Module-Name" value="org.mapstruct.processor" />
+ </manifest>
+ </jar>
+
+ <mkdir dir="build/mapstruct-binding" />
+ <echo file="build/mapstruct-binding/META-INF/services/org.mapstruct.ap.spi.AstModifyingAnnotationProcessor">lombok.mapstruct.NotifierHider$AstModificationNotifier</echo>
+
+ <javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/mapstruct-binding" modulepath="build/mapstruct-module-path">
+ <src path="src/bindings/mapstruct" />
+ </javac>
+ <jar destfile="dist/lombok-mapstruct-binding-0.1.0" basedir="build/mapstruct-binding" includes="**" />
+ </target>
</project>
diff --git a/src/bindings/mapstruct/lombok/mapstruct/NotifierHider.java b/src/bindings/mapstruct/lombok/mapstruct/NotifierHider.java
new file mode 100644
index 00000000..a8e92b4b
--- /dev/null
+++ b/src/bindings/mapstruct/lombok/mapstruct/NotifierHider.java
@@ -0,0 +1,35 @@
+package lombok.mapstruct;
+
+import java.lang.reflect.Field;
+
+import javax.lang.model.type.TypeMirror;
+
+import org.mapstruct.ap.spi.AstModifyingAnnotationProcessor;
+
+class NotifierHider {
+
+ public static class AstModificationNotifier implements AstModifyingAnnotationProcessor {
+ private static Field lombokInvoked;
+
+ @Override public boolean isTypeComplete(TypeMirror type) {
+ if (System.getProperty("lombok.disable") != null) return true;
+ return isLombokInvoked();
+ }
+
+ private static boolean isLombokInvoked() {
+ if (lombokInvoked != null) {
+ try {
+ return lombokInvoked.getBoolean(null);
+ } catch (Exception e) {}
+ return true;
+ }
+
+ try {
+ Class<?> data = Class.forName("lombok.launch.AnnotationProcessorHider$AstModificationNotifierData");
+ lombokInvoked = data.getField("lombokInvoked");
+ return lombokInvoked.getBoolean(null);
+ } catch (Exception e) {}
+ return true;
+ }
+ }
+}
diff --git a/src/bindings/mapstruct/module-info.java b/src/bindings/mapstruct/module-info.java
new file mode 100644
index 00000000..bbfbd823
--- /dev/null
+++ b/src/bindings/mapstruct/module-info.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2020 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
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+module lombok.mapstruct {
+ requires lombok;
+ requires java.compiler;
+
+ requires static org.mapstruct.processor;
+
+ provides org.mapstruct.ap.spi.AstModifyingAnnotationProcessor with lombok.mapstruct.NotifierHider.AstModificationNotifier;
+}
diff --git a/src/core9/module-info.java b/src/core9/module-info.java
index 56e54270..293bc839 100644
--- a/src/core9/module-info.java
+++ b/src/core9/module-info.java
@@ -23,7 +23,6 @@ module lombok {
requires java.compiler;
requires java.instrument;
requires jdk.unsupported;
- requires static org.mapstruct.processor;
exports lombok;
exports lombok.experimental;
@@ -34,6 +33,7 @@ module lombok {
exports lombok.extern.slf4j;
exports lombok.extern.flogger;
+ exports lombok.launch to lombok.mapstruct;
+
provides javax.annotation.processing.Processor with lombok.launch.AnnotationProcessorHider.AnnotationProcessor;
- provides org.mapstruct.ap.spi.AstModifyingAnnotationProcessor with lombok.launch.AnnotationProcessorHider.AstModificationNotifier;
}
diff --git a/src/j9stubs/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.java b/src/j9stubs/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.java
index ffb99030..ffb99030 100644
--- a/src/j9stubs/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.java
+++ b/src/j9stubs/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.java
diff --git a/src/launch/lombok/launch/AnnotationProcessor.java b/src/launch/lombok/launch/AnnotationProcessor.java
index b03dec76..456a8cef 100644
--- a/src/launch/lombok/launch/AnnotationProcessor.java
+++ b/src/launch/lombok/launch/AnnotationProcessor.java
@@ -34,22 +34,13 @@ import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.TypeMirror;
-
-import org.mapstruct.ap.spi.AstModifyingAnnotationProcessor;
import sun.misc.Unsafe;
class AnnotationProcessorHider {
- public static class AstModificationNotifier implements AstModifyingAnnotationProcessor {
- @Override public boolean isTypeComplete(TypeMirror type) {
- if (System.getProperty("lombok.disable") != null) return true;
- return AstModificationNotifierData.lombokInvoked;
- }
- }
-
- static class AstModificationNotifierData {
- volatile static boolean lombokInvoked = false;
+
+ public static class AstModificationNotifierData {
+ public volatile static boolean lombokInvoked = false;
}
public static class AnnotationProcessor extends AbstractProcessor {