Bug 416701 - buildtimeComparatorUnanticipated.log.txt not capable of
handling signed inner JARs
Bug 407625 - Comparator log shows jdt.core twice
diff --git a/bundles/org.eclipse.releng.build.tools.comparator/META-INF/MANIFEST.MF b/bundles/org.eclipse.releng.build.tools.comparator/META-INF/MANIFEST.MF
index ebfdb36..13dbb47 100644
--- a/bundles/org.eclipse.releng.build.tools.comparator/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.releng.build.tools.comparator/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.eclipse.releng.build.tools.comparator;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.0.1.qualifier
 Bundle-Vendor: %Bundle-Vendor
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Require-Bundle: org.apache.ant,
diff --git a/bundles/org.eclipse.releng.build.tools.comparator/comparatorSummary.jar b/bundles/org.eclipse.releng.build.tools.comparator/comparatorSummary.jar
index 275a8eb..884e0d9 100644
--- a/bundles/org.eclipse.releng.build.tools.comparator/comparatorSummary.jar
+++ b/bundles/org.eclipse.releng.build.tools.comparator/comparatorSummary.jar
Binary files differ
diff --git a/bundles/org.eclipse.releng.build.tools.comparator/pom.xml b/bundles/org.eclipse.releng.build.tools.comparator/pom.xml
index 192fdcd..af88371 100644
--- a/bundles/org.eclipse.releng.build.tools.comparator/pom.xml
+++ b/bundles/org.eclipse.releng.build.tools.comparator/pom.xml
@@ -12,6 +12,6 @@
     </parent>
     <groupId>org.eclipse.platform</groupId>
     <artifactId>org.eclipse.releng.build.tools.comparator</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>eclipse-plugin</packaging>
 </project>
diff --git a/bundles/org.eclipse.releng.build.tools.comparator/src/org/eclipse/releng/build/tools/comparator/Extractor.java b/bundles/org.eclipse.releng.build.tools.comparator/src/org/eclipse/releng/build/tools/comparator/Extractor.java
index e82045d..deebc82 100644
--- a/bundles/org.eclipse.releng.build.tools.comparator/src/org/eclipse/releng/build/tools/comparator/Extractor.java
+++ b/bundles/org.eclipse.releng.build.tools.comparator/src/org/eclipse/releng/build/tools/comparator/Extractor.java
@@ -32,7 +32,7 @@
             extractor.setBuildDirectory(args[0]);
         }
         // set explicitly for local test
-        // extractor.setBuildDirectory("/home/davidw/temp/I20130417-1750zz");
+        extractor.setBuildDirectory("/home/davidw/temp/I20130910-0800");
         try {
             extractor.processBuildfile();
         }
@@ -44,8 +44,10 @@
     private final String  debugFilename                         = "mb060_run-maven-build_output.txt";
     private final String  outputFilenameFull                    = "buildtimeComparatorFull.log.txt";
     private final String  outputFilenameSign                    = "buildtimeComparatorSignatureOnly.log.txt";
+    private final String  outputFilenameSignPlusInnerJar        = "buildtimeComparatorSignatureOnlyWithInnerJar.log.txt";
     private final String  outputFilenameDoc                     = "buildtimeComparatorDocBundle.log.txt";
     private final String  outputFilenameOther                   = "buildtimeComparatorUnanticipated.log.txt";
+    private final String  outputFilenamejdtCore                 = "buildtimeComparatorJDTCore.log.txt";
     private final String  buildlogsDirectory                    = "buildlogs";
     private final String  comparatorLogsDirectory               = "comparatorlogs";
     private String        comparatorRepo                        = "comparatorRepo";
@@ -55,6 +57,8 @@
     private String        outputFilenameSignLog;
     private String        outputFilenameDocLog;
     private String        outputFilenameOtherLog;
+    private String        outputFilenameSignPlusInnerJarLog;
+    private String        outputFilenamejdtCoreLog;
     private final String  mainregexPattern                      = "^\\[WARNING\\].*eclipse.platform.releng.aggregator/(.*)/pom.xml: baseline and build artifacts have same version but different contents";
     private final Pattern mainPattern                           = Pattern.compile(mainregexPattern);
     private final String  noclassifierregexPattern              = "^.*no-classifier:.*$";
@@ -70,10 +74,15 @@
     private final Pattern sign2Pattern                          = Pattern.compile(sign2regexPattern);
     private final String  docNameregexPattern                   = "^.*eclipse\\.platform\\.common.*\\.doc\\..*$";
     private final Pattern docNamePattern                        = Pattern.compile(docNameregexPattern);
+    // jar pattern added for bug 416701
+    private final String  jarregexPattern                       = "^.*\\.jar.*$";
+    private final Pattern jarPattern                            = Pattern.compile(jarregexPattern);
     private int           count;
     private int           countSign;
     private int           countDoc;
     private int           countOther;
+    private int           countSignPlusInnerJar;
+    private int           countJDTCore;
 
     public Extractor() {
 
@@ -136,6 +145,22 @@
         return outputFilenameSignLog;
     }
 
+    private String getOutputFilenameSignWithInnerJar() {
+        if (outputFilenameSignPlusInnerJarLog == null) {
+            outputFilenameSignPlusInnerJarLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory
+                    + "/" + outputFilenameSignPlusInnerJar;
+        }
+        return outputFilenameSignPlusInnerJarLog;
+    }
+
+    private String getOutputFilenameJDTCore() {
+        if (outputFilenamejdtCoreLog == null) {
+            outputFilenamejdtCoreLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory + "/"
+                    + outputFilenamejdtCore;
+        }
+        return outputFilenamejdtCoreLog;
+    }
+
     public void processBuildfile() throws IOException {
 
         // Make sure directory exists
@@ -156,6 +181,14 @@
         final Writer outsign = new FileWriter(outfileSign);
         final BufferedWriter outputSign = new BufferedWriter(outsign);
 
+        final File outfileSignWithInnerJar = new File(getOutputFilenameSignWithInnerJar());
+        final Writer outsignWithJar = new FileWriter(outfileSignWithInnerJar);
+        final BufferedWriter outputSignWithJar = new BufferedWriter(outsignWithJar);
+
+        final File outfileJDTCore = new File(getOutputFilenameJDTCore());
+        final Writer outJDTCore = new FileWriter(outfileJDTCore);
+        final BufferedWriter outputJDTCore = new BufferedWriter(outJDTCore);
+
         final File outfileDoc = new File(getOutputFilenameDoc());
         final Writer outdoc = new FileWriter(outfileDoc);
         final BufferedWriter outputDoc = new BufferedWriter(outdoc);
@@ -166,12 +199,16 @@
 
         writeHeader(output);
         writeHeader(outputSign);
+        writeHeader(outputSignWithJar);
         writeHeader(outputDoc);
         writeHeader(outputOther);
+        writeHeader(outputJDTCore);
         count = 0;
         countSign = 0;
+        countSignPlusInnerJar = 0;
         countDoc = 0;
         countOther = 0;
+        countJDTCore = 0;
         try {
             String inputLine = "";
 
@@ -208,10 +245,14 @@
                         while ((inputLine != null) && (inputLine.length() > 0));
                         // Write full log, for sanity check, if nothing else
                         writeEntry(++count, output, newEntry);
-                        if (docItem(newEntry)) {
+                        if (jdtCore(newEntry)) {
+                            writeEntry(++countJDTCore, outputJDTCore, newEntry);
+                        } else if (docItem(newEntry)) {
                             writeEntry(++countDoc, outputDoc, newEntry);
                         } else if (pureSignature(newEntry)) {
                             writeEntry(++countSign, outputSign, newEntry);
+                        } else if (pureSignaturePlusInnerJar(newEntry)) {
+                            writeEntry(++countSignPlusInnerJar, outputSignWithJar, newEntry);
                         } else {
                             writeEntry(++countOther, outputOther, newEntry);
                         }
@@ -235,6 +276,12 @@
             if (outputOther != null) {
                 outputOther.close();
             }
+            if (outputSignWithJar != null) {
+                outputSignWithJar.close();
+            }
+            if (outputJDTCore != null) {
+                outputJDTCore.close();
+            }
         }
     }
 
@@ -247,6 +294,15 @@
         }
     }
 
+    private boolean jdtCore(final LogEntry newEntry) {
+        boolean result = false;
+        final String name = newEntry.getName();
+        if (name.equals("eclipse.jdt.core/org.eclipse.jdt.core")) {
+            result = true;
+        }
+        return result;
+    }
+
     private boolean pureSignature(final LogEntry newEntry) {
         // if all lines match one of these critical patterns,
         // then assume "signature only" difference. If even
@@ -271,6 +327,33 @@
         return result;
     }
 
+    private boolean pureSignaturePlusInnerJar(final LogEntry newEntry) {
+        // if all lines match one of these critical patterns,
+        // then assume "signature only plus inner jar" difference. If even
+        // one of them does not match, assume not.
+        // TODO: refactor so less copy/paste of pureSignature method.
+        boolean result = true;
+        final List<String> reasons = newEntry.getReasons();
+        for (final String reason : reasons) {
+            final Matcher matcher1 = noclassifierPattern.matcher(reason);
+            final Matcher matcher2 = classifier_sourcesPattern.matcher(reason);
+            final Matcher matcher3 = classifier_sourcesfeaturePattern.matcher(reason);
+            final Matcher matcher4 = sign1Pattern.matcher(reason);
+            final Matcher matcher5 = sign2Pattern.matcher(reason);
+            final Matcher matcher6 = jarPattern.matcher(reason);
+
+            if (matcher1.matches() || matcher2.matches() || matcher3.matches() || matcher4.matches() || matcher5.matches()
+                    || matcher6.matches()) {
+                continue;
+            } else {
+                result = false;
+                break;
+            }
+        }
+
+        return result;
+    }
+
     public void setBuildDirectory(final String buildDirectory) {
         this.buildDirectory = buildDirectory;
     }
@@ -293,7 +376,6 @@
         return comparatorRepo;
     }
 
-    
     public void setComparatorRepo(String comparatorRepo) {
         this.comparatorRepo = comparatorRepo;
     }