You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/04/12 15:33:32 UTC

[1/2] git commit: [flex-falcon] [refs/heads/feature/maven-migration] - - Make the annotate mojo skip annotating if the class is already annotated.

Repository: flex-falcon
Updated Branches:
  refs/heads/feature/maven-migration 4b6817d0d -> ad9435711


- Make the annotate mojo skip annotating if the class is already annotated.


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/b8c7c15a
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/b8c7c15a
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/b8c7c15a

Branch: refs/heads/feature/maven-migration
Commit: b8c7c15a9e4b7c1ab67717c3a14f8a7a9fabd340
Parents: 4b6817d
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Tue Apr 12 15:32:32 2016 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Tue Apr 12 15:32:32 2016 +0200

----------------------------------------------------------------------
 .../compiler/tools/annotate/AnnotateClassesMojo.java     | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b8c7c15a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/annotate/AnnotateClassesMojo.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/annotate/AnnotateClassesMojo.java b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/annotate/AnnotateClassesMojo.java
index f808e7b..0f60762 100644
--- a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/annotate/AnnotateClassesMojo.java
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/annotate/AnnotateClassesMojo.java
@@ -72,7 +72,6 @@ public class AnnotateClassesMojo
             System.out.println("Missing file: " + file.getPath());
             return;
         }
-        System.out.println("Adding " + annotation + " to class: " + file.getPath());
         try
         {
             // Prepare to read the file.
@@ -87,10 +86,18 @@ public class AnnotateClassesMojo
             {
                 // Read it line-by-line.
                 String line;
+                boolean alreadyAnnotated = false;
                 while ((line = bufferedReader.readLine()) != null)
                 {
+                    // If the class is already annotated, prevent us from doing it again.
+                    if (line.contains(annotation)) {
+                        alreadyAnnotated = true;
+                        System.out.println("Annotation " + annotation + " already added to class: " + file.getPath());
+                    }
                     // If the line starts with "public class", output the annotation on the previous line.
-                    if (line.startsWith("public class") || line.startsWith("public interface")) {
+                    if (!alreadyAnnotated &&
+                            (line.startsWith("public class") || line.startsWith("public interface"))) {
+                        System.out.println("Adding " + annotation + " to class: " + file.getPath());
                         outputStream.println(annotation);
                     }
                     outputStream.println(line);


[2/2] git commit: [flex-falcon] [refs/heads/feature/maven-migration] - - Made the BaseProblemGeneratorMojo delete previously generated enums

Posted by cd...@apache.org.
- Made the BaseProblemGeneratorMojo delete previously generated enums


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/ad943571
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/ad943571
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/ad943571

Branch: refs/heads/feature/maven-migration
Commit: ad943571149c51c1063165a5bfe5ae4ae33bfce4
Parents: b8c7c15
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Tue Apr 12 15:33:24 2016 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Tue Apr 12 15:33:24 2016 +0200

----------------------------------------------------------------------
 .../compiler/tools/problems/BaseProblemGeneratorMojo.java     | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ad943571/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
index 903ca55..04929a5 100644
--- a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/problems/BaseProblemGeneratorMojo.java
@@ -61,6 +61,13 @@ public abstract class BaseProblemGeneratorMojo extends AbstractMojo
             }
         }
 
+        // If the file already exists, delete it before generating output.
+        if(generatedFile.exists()) {
+            if(!generatedFile.delete()) {
+                throw new MojoExecutionException("Could not clear previously created file: " + generatedFile.getPath());
+            }
+        }
+
         try {
             PrintWriter writer = new PrintWriter(new FileWriter(generatedFile, true));
             try {