diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index 27fe78e0..b19dccfc 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -87,7 +87,7 @@ public class ConfigurationKeys { * * If {@code true}, lombok generates {@code @lombok.Generated} on all fields, methods, and types that are generated. */ - public static final ConfigurationKey ADD_LOMBOK_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addLombokGeneratedAnnotation", "Generate @lombok.Generated on all generated code (default: false).") {}; + public static final ConfigurationKey ADD_LOMBOK_GENERATED_ANNOTATIONS = new ConfigurationKey("lombok.addLombokGeneratedAnnotation", "Generate @lombok.Generated on all generated code (default: true).") {}; /** * lombok configuration: {@code lombok.extern.findbugs.addSuppressFBWarnings} = {@code true} | {@code false}. diff --git a/src/core/lombok/Generated.java b/src/core/lombok/Generated.java index 216ab143..09608e4b 100644 --- a/src/core/lombok/Generated.java +++ b/src/core/lombok/Generated.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2016 The Project Lombok Authors. + * Copyright (C) 2015-2024 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 @@ -27,14 +27,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Lombok will eventually automatically add this annotation to all generated constructors, methods, fields, and types. + * Lombok automatically adds this annotation to all generated constructors, methods, fields, and types. * * You can mark the presence of this annotation as 'ignore it' for all code style and bug finding tools. *

- * NB: As of v1.16.2 which introduces this annotation, lombok doesn't actually add this annotation; we're setting - * it up so that lombok jars in widespread use start having this, which will make it easier to actually apply it - * later on. By adding {@code lombok.addLombokGeneratedAnnotation = true} to {@code lombok.config} you can already - * get this behavior. + * NB: As of v1.18.34, lombok adds this annotation by default; before then you had to add a lombok config key. + *

+ * If you want to opt out (not recommended), you can add {@code lombok.addLombokGeneratedAnnotation = false} to + * {@code lombok.config}. */ @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.CLASS) diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index ef7a7c3a..af1aa0fd 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -2098,7 +2098,7 @@ public class EclipseHandlerUtil { 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))) { + if (!Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) { result = addAnnotation(source, result, LOMBOK_GENERATED); } return result; diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 660ebcc8..38658bb6 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1542,7 +1542,7 @@ public class JavacHandlerUtil { 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))) { + if (!Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) { addAnnotation(mods, node, source, "lombok.Generated", null); } } diff --git a/test/transform/resource/before/GeneratedJavaxOnLombokOn.java b/test/transform/resource/before/GeneratedJavaxOnLombokOn.java index cee391ad..b6cc1fe4 100644 --- a/test/transform/resource/before/GeneratedJavaxOnLombokOn.java +++ b/test/transform/resource/before/GeneratedJavaxOnLombokOn.java @@ -1,5 +1,4 @@ //CONF: lombok.addJavaxGeneratedAnnotation = true -//CONF: lombok.addLombokGeneratedAnnotation = true class GeneratedJavaxOnLombokOn { @lombok.Getter int x; diff --git a/test/transform/resource/before/GeneratedOffLombokOn.java b/test/transform/resource/before/GeneratedOffLombokOn.java index 9d122306..ae6094e4 100644 --- a/test/transform/resource/before/GeneratedOffLombokOn.java +++ b/test/transform/resource/before/GeneratedOffLombokOn.java @@ -1,5 +1,4 @@ //CONF: lombok.addGeneratedAnnotation = false -//CONF: lombok.addLombokGeneratedAnnotation = true class GeneratedOffLombokOn { @lombok.Getter int x;