diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java
index 93bcb85f59..e94dc65f9f 100644
--- a/src/core/lombok/ConfigurationKeys.java
+++ b/src/core/lombok/ConfigurationKeys.java
@@ -59,6 +59,7 @@ private ConfigurationKeys() {}
* BREAKING CHANGE: Starting with lombok v1.16.20, defaults to {@code false} instead of {@code true}, as this annotation is broken in JDK9.
*
* @see ConfigurationKeys#ADD_JAVAX_GENERATED_ANNOTATIONS
+ * @see ConfigurationKeys#ADD_JAKARTA_GENERATED_ANNOTATIONS
* @see ConfigurationKeys#ADD_LOMBOK_GENERATED_ANNOTATIONS
* @deprecated Since version 1.16.14, use {@link #ADD_JAVAX_GENERATED_ANNOTATIONS} instead.
*/
@@ -74,6 +75,13 @@ private ConfigurationKeys() {}
*/
public static final ConfigurationKey ADD_JAVAX_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addJavaxGeneratedAnnotation", "Generate @javax.annotation.Generated on all generated code (default: follow lombok.addGeneratedAnnotation).") {};
+ /**
+ * lombok configuration: {@code lombok.addJakartaGeneratedAnnotation} = {@code true} | {@code false}.
+ *
+ * If {@code true}, lombok generates {@code @jakarta.annotation.Generated("lombok")} on all fields, methods, and types that are generated.
+ */
+ public static final ConfigurationKey ADD_JAKARTA_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addJakartaGeneratedAnnotation", "Generate @jakarta.annotation.Generated on all generated code (default: false).") {};
+
/**
* lombok configuration: {@code lombok.addLombokGeneratedAnnotation} = {@code true} | {@code false}.
*
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 752ed0e64b..2732925bb7 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -2088,6 +2088,7 @@ public static EclipseNode injectType(final EclipseNode typeNode, final TypeDecla
private static final char[] GENERATED_CODE = "generated code".toCharArray();
private static final char[] LOMBOK = "lombok".toCharArray();
private static final char[][] JAVAX_ANNOTATION_GENERATED = Eclipse.fromQualifiedName("javax.annotation.Generated");
+ private static final char[][] JAKARTA_ANNOTATION_GENERATED = Eclipse.fromQualifiedName("jakarta.annotation.Generated");
private static final char[][] LOMBOK_GENERATED = Eclipse.fromQualifiedName("lombok.Generated");
private static final char[][] EDU_UMD_CS_FINDBUGS_ANNOTATIONS_SUPPRESSFBWARNINGS = Eclipse.fromQualifiedName("edu.umd.cs.findbugs.annotations.SuppressFBWarnings");
@@ -2111,6 +2112,9 @@ public static Annotation[] addGenerated(EclipseNode node, ASTNode source, Annota
if (HandlerUtil.shouldAddGenerated(node)) {
result = addAnnotation(source, result, JAVAX_ANNOTATION_GENERATED, new StringLiteral(LOMBOK, 0, 0, 0));
}
+ if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_JAKARTA_GENERATED_ANNOTATIONS))) {
+ result = addAnnotation(source, result, JAKARTA_ANNOTATION_GENERATED, new StringLiteral(LOMBOK, 0, 0, 0));
+ }
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) {
result = addAnnotation(source, result, LOMBOK_GENERATED);
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 6993a6baa5..84f106bef8 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1521,6 +1521,9 @@ public static void addGenerated(JCModifiers mods, JavacNode node, JavacNode sour
if (HandlerUtil.shouldAddGenerated(node)) {
addAnnotation(mods, node, source, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok"));
}
+ if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_JAKARTA_GENERATED_ANNOTATIONS))) {
+ addAnnotation(mods, node, source, "jakarta.annotation.Generated", node.getTreeMaker().Literal("lombok"));
+ }
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) {
addAnnotation(mods, node, source, "lombok.Generated", null);
}
diff --git a/test/stubs/jakarta/annotation/Generated.java b/test/stubs/jakarta/annotation/Generated.java
new file mode 100644
index 0000000000..a7dda92906
--- /dev/null
+++ b/test/stubs/jakarta/annotation/Generated.java
@@ -0,0 +1,15 @@
+package jakarta.annotation;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(SOURCE)
+@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, PARAMETER})
+public @interface Generated {
+ String[] value();
+}
diff --git a/test/stubs/javax/annotation/Generated.java b/test/stubs/javax/annotation/Generated.java
new file mode 100644
index 0000000000..435f61f223
--- /dev/null
+++ b/test/stubs/javax/annotation/Generated.java
@@ -0,0 +1,15 @@
+package javax.annotation;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(SOURCE)
+@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, PARAMETER})
+public @interface Generated {
+ String[] value();
+}
diff --git a/test/transform/resource/after-delombok/GeneratedJavaxJakarta.java b/test/transform/resource/after-delombok/GeneratedJavaxJakarta.java
new file mode 100644
index 0000000000..42f7c2b6de
--- /dev/null
+++ b/test/transform/resource/after-delombok/GeneratedJavaxJakarta.java
@@ -0,0 +1,10 @@
+class GeneratedJavaxJakarta {
+ int x;
+
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ @jakarta.annotation.Generated("lombok")
+ public int getX() {
+ return this.x;
+ }
+}
diff --git a/test/transform/resource/after-delombok/GeneratedJavaxOnLombokOn.java b/test/transform/resource/after-delombok/GeneratedJavaxOnLombokOn.java
index 2ca96e7c7d..90fe0e3abb 100644
--- a/test/transform/resource/after-delombok/GeneratedJavaxOnLombokOn.java
+++ b/test/transform/resource/after-delombok/GeneratedJavaxOnLombokOn.java
@@ -1,4 +1,3 @@
-//version :8
class GeneratedJavaxOnLombokOn {
int x;
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/GeneratedOffJavaxOn.java b/test/transform/resource/after-delombok/GeneratedOffJavaxOn.java
index 4b10c70881..05c2be090e 100644
--- a/test/transform/resource/after-delombok/GeneratedOffJavaxOn.java
+++ b/test/transform/resource/after-delombok/GeneratedOffJavaxOn.java
@@ -1,4 +1,3 @@
-//version :8
class GeneratedOffJavaxOn {
int x;
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/GeneratedOn.java b/test/transform/resource/after-delombok/GeneratedOn.java
new file mode 100644
index 0000000000..f4976c7aab
--- /dev/null
+++ b/test/transform/resource/after-delombok/GeneratedOn.java
@@ -0,0 +1,9 @@
+class GeneratedOn {
+ int x;
+
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public int getX() {
+ return this.x;
+ }
+}
diff --git a/test/transform/resource/after-ecj/GeneratedJavaxJakarta.java b/test/transform/resource/after-ecj/GeneratedJavaxJakarta.java
new file mode 100644
index 0000000000..184df939bc
--- /dev/null
+++ b/test/transform/resource/after-ecj/GeneratedJavaxJakarta.java
@@ -0,0 +1,9 @@
+class GeneratedJavaxJakarta {
+ @lombok.Getter int x;
+ GeneratedJavaxJakarta() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") @jakarta.annotation.Generated("lombok") int getX() {
+ return this.x;
+ }
+}
diff --git a/test/transform/resource/after-ecj/GeneratedOn.java b/test/transform/resource/after-ecj/GeneratedOn.java
new file mode 100644
index 0000000000..9d72333407
--- /dev/null
+++ b/test/transform/resource/after-ecj/GeneratedOn.java
@@ -0,0 +1,9 @@
+class GeneratedOn {
+ @lombok.Getter int x;
+ GeneratedOn() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int getX() {
+ return this.x;
+ }
+}
diff --git a/test/transform/resource/before/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/before/EqualsAndHashCodeWithSomeExistingMethods.java
index ec5ef7ad67..debe75b9dc 100644
--- a/test/transform/resource/before/EqualsAndHashCodeWithSomeExistingMethods.java
+++ b/test/transform/resource/before/EqualsAndHashCodeWithSomeExistingMethods.java
@@ -1,4 +1,3 @@
-//CONF: lombok.addGeneratedAnnotation = false
import lombok.*;
import static lombok.AccessLevel.NONE;
diff --git a/test/transform/resource/before/GeneratedJavaxJakarta.java b/test/transform/resource/before/GeneratedJavaxJakarta.java
new file mode 100644
index 0000000000..82c87c4a29
--- /dev/null
+++ b/test/transform/resource/before/GeneratedJavaxJakarta.java
@@ -0,0 +1,6 @@
+//CONF: lombok.addJavaxGeneratedAnnotation = true
+//CONF: lombok.addJakartaGeneratedAnnotation = true
+class GeneratedJavaxJakarta {
+ @lombok.Getter
+ int x;
+}
diff --git a/test/transform/resource/before/GeneratedJavaxOnLombokOn.java b/test/transform/resource/before/GeneratedJavaxOnLombokOn.java
index 4eb86de188..cee391adb1 100644
--- a/test/transform/resource/before/GeneratedJavaxOnLombokOn.java
+++ b/test/transform/resource/before/GeneratedJavaxOnLombokOn.java
@@ -1,6 +1,5 @@
//CONF: lombok.addJavaxGeneratedAnnotation = true
//CONF: lombok.addLombokGeneratedAnnotation = true
-//version :8
class GeneratedJavaxOnLombokOn {
@lombok.Getter
int x;
diff --git a/test/transform/resource/before/GeneratedOffJavaxOn.java b/test/transform/resource/before/GeneratedOffJavaxOn.java
index 83c03eac3b..a354791305 100644
--- a/test/transform/resource/before/GeneratedOffJavaxOn.java
+++ b/test/transform/resource/before/GeneratedOffJavaxOn.java
@@ -1,6 +1,5 @@
//CONF: lombok.addGeneratedAnnotation = false
//CONF: lombok.addJavaxGeneratedAnnotation = true
-//version :8
class GeneratedOffJavaxOn {
@lombok.Getter
int x;
diff --git a/test/transform/resource/before/GeneratedOn.java b/test/transform/resource/before/GeneratedOn.java
new file mode 100644
index 0000000000..92d178dfda
--- /dev/null
+++ b/test/transform/resource/before/GeneratedOn.java
@@ -0,0 +1,5 @@
+//CONF: lombok.addGeneratedAnnotation = true
+class GeneratedOn {
+ @lombok.Getter
+ int x;
+}
diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages
index d8c064a0ac..d3119bd60b 100644
--- a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages
+++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages
@@ -1 +1 @@
-5 Not generating equals: One of equals or hashCode exists. You should either write both of these or none of these (in the latter case, lombok generates them).
+4 Not generating equals: One of equals or hashCode exists. You should either write both of these or none of these (in the latter case, lombok generates them).
diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages
index d8c064a0ac..d3119bd60b 100644
--- a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages
+++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages
@@ -1 +1 @@
-5 Not generating equals: One of equals or hashCode exists. You should either write both of these or none of these (in the latter case, lombok generates them).
+4 Not generating equals: One of equals or hashCode exists. You should either write both of these or none of these (in the latter case, lombok generates them).