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 <[email protected]> Authored: Tue Apr 12 15:32:32 2016 +0200 Committer: Christofer Dutz <[email protected]> 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);
