aboutsummaryrefslogtreecommitdiff
path: root/src/bindings
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 /src/bindings
parenta8dd99d9f080be6839fe507ade104fccac115de4 (diff)
downloadlombok-0d7540db0cc0c9a2758799522925f09eddeb7420.tar.gz
lombok-0d7540db0cc0c9a2758799522925f09eddeb7420.tar.bz2
lombok-0d7540db0cc0c9a2758799522925f09eddeb7420.zip
(#2125) Extract mapstruct binding to separate module.
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/mapstruct/lombok/mapstruct/NotifierHider.java35
-rw-r--r--src/bindings/mapstruct/module-info.java29
2 files changed, 64 insertions, 0 deletions
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;
+}