rmannibucau commented on a change in pull request #90:
URL: https://github.com/apache/openjpa/pull/90#discussion_r759147173



##########
File path: 
openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
##########
@@ -311,10 +314,26 @@ private void annotate(SourceCode source, String 
originalClass) {
         SourceCode.Class cls = source.getTopLevelClass();
         cls.addAnnotation(StaticMetamodel.class.getName())
             .addArgument("value", originalClass + ".class", false);
-        if (generatedSourceVersion >= 6) {
-            cls.addAnnotation(Generated.class.getName())
-            .addArgument("value", this.getClass().getName())
-            .addArgument("date", new Date().toString());
+        if ("false".equals(this.addGeneratedOption)) {
+            return;
+        }
+
+        if ("force".equals(this.addGeneratedOption)) {
+            cls.addAnnotation(javax.annotation.Generated.class.getName())
+                    .addArgument("value", this.getClass().getName())
+                    .addArgument("date", new Date().toString());

Review comment:
       know it was "before" but can be worth storing the date in init if needed 
(once the forName moved there it will be easy to know)

##########
File path: 
openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
##########
@@ -311,10 +314,26 @@ private void annotate(SourceCode source, String 
originalClass) {
         SourceCode.Class cls = source.getTopLevelClass();
         cls.addAnnotation(StaticMetamodel.class.getName())
             .addArgument("value", originalClass + ".class", false);
-        if (generatedSourceVersion >= 6) {
-            cls.addAnnotation(Generated.class.getName())
-            .addArgument("value", this.getClass().getName())
-            .addArgument("date", new Date().toString());
+        if ("false".equals(this.addGeneratedOption)) {
+            return;
+        }
+
+        if ("force".equals(this.addGeneratedOption)) {
+            cls.addAnnotation(javax.annotation.Generated.class.getName())
+                    .addArgument("value", this.getClass().getName())
+                    .addArgument("date", new Date().toString());
+        }
+
+        try {
+            // only add the annotation if it is on the classpath for Java 6+.
+            Class<?> generatedAnnotation = 
Class.forName("javax.annotation.Generated", false, null);

Review comment:
       guess we want to do it in init and not each time

##########
File path: openjpa-persistence/pom.xml
##########
@@ -60,5 +60,10 @@
             <version>4.2.0</version>
             <scope>provided</scope>
         </dependency>
+        <!-- annotation javax.annotation.Generated -->
+        <dependency>
+            <groupId>javax.annotation</groupId>

Review comment:
       provided?

##########
File path: 
openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
##########
@@ -379,6 +398,19 @@ private void setHeader() {
         }
     }
 
+    private void setAddGeneratedAnnotation() {
+        String addGeneratedOption = 
getOptionValue("openjpa.addGeneratedAnnotation");

Review comment:
       `this.addGeneratedOption = 
getOptionValue("openjpa.addGeneratedAnnotation")` ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@openjpa.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to