mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 04:16:19 +00:00
Merge pull request #3502 from Rawi01/jakarta-generated-annotations
Add support for jakarta generated annotation
This commit is contained in:
18 files changed
+95
-7
No files matched your search
@@ -59,6 +59,7 @@ public class ConfigurationKeys {
|
||||
* <em>BREAKING CHANGE</em>: 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 @@ public class ConfigurationKeys {
|
||||
*/
|
||||
public static final ConfigurationKey<Boolean> ADD_JAVAX_GENERATED_ANNOTATIONS = new ConfigurationKey<Boolean>("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<Boolean> ADD_JAKARTA_GENERATED_ANNOTATIONS = new ConfigurationKey<Boolean>("lombok.addJakartaGeneratedAnnotation", "Generate @jakarta.annotation.Generated on all generated code (default: false).") {};
|
||||
|
||||
/**
|
||||
* lombok configuration: {@code lombok.addLombokGeneratedAnnotation} = {@code true} | {@code false}.
|
||||
*
|
||||
|
||||
@@ -2088,6 +2088,7 @@ public class EclipseHandlerUtil {
|
||||
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 class EclipseHandlerUtil {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1521,6 +1521,9 @@ public class JavacHandlerUtil {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
//version :8
|
||||
class GeneratedJavaxOnLombokOn {
|
||||
int x;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//version :8
|
||||
class GeneratedOffJavaxOn {
|
||||
int x;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class GeneratedOn {
|
||||
int x;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@javax.annotation.Generated("lombok")
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
//CONF: lombok.addGeneratedAnnotation = false
|
||||
import lombok.*;
|
||||
import static lombok.AccessLevel.NONE;
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
//CONF: lombok.addJavaxGeneratedAnnotation = true
|
||||
//CONF: lombok.addJakartaGeneratedAnnotation = true
|
||||
class GeneratedJavaxJakarta {
|
||||
@lombok.Getter
|
||||
int x;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
//CONF: lombok.addJavaxGeneratedAnnotation = true
|
||||
//CONF: lombok.addLombokGeneratedAnnotation = true
|
||||
//version :8
|
||||
class GeneratedJavaxOnLombokOn {
|
||||
@lombok.Getter
|
||||
int x;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//CONF: lombok.addGeneratedAnnotation = false
|
||||
//CONF: lombok.addJavaxGeneratedAnnotation = true
|
||||
//version :8
|
||||
class GeneratedOffJavaxOn {
|
||||
@lombok.Getter
|
||||
int x;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//CONF: lombok.addGeneratedAnnotation = true
|
||||
class GeneratedOn {
|
||||
@lombok.Getter
|
||||
int x;
|
||||
}
|
||||
+1
-1
@@ -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).
|
||||
+1
-1
@@ -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).
|
||||
Reference in new issue
Block a user