[528979] Migrate build to Maven/Tycho

https://bugs.eclipse.org/bugs/show_bug.cgi?id=528979
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/pom.xml b/plugins/org.eclipse.emf.cdo.tests.db/pom.xml
index dadee8c..3f96893 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.tests.db/pom.xml
@@ -44,6 +44,9 @@
             <configuration>
               <test>${CDO_TESTS}*</test>
               <testFailureIgnore>true</testFailureIgnore>
+              <systemProperties>
+                <disable.main.suite.finished>true</disable.main.suite.finished>
+              </systemProperties>
             </configuration>
           </plugin>
         </plugins>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
index fe5a9f1..0aaf606 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
@@ -91,10 +91,10 @@
     // defaultDataSource = null;
     // }
 
-    // if (reusableFolder != null)
-    // {
-    // IOUtil.delete(reusableFolder);
-    // reusableFolder = null;
-    // }
+    if (reusableFolder != null)
+    {
+      IOUtil.delete(reusableFolder);
+      reusableFolder = null;
+    }
   }
 }
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
index f3d25e4..dae2a55 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
@@ -17,6 +17,7 @@
 
 import org.eclipse.net4j.util.io.IOUtil;
 import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
 
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Method;
@@ -37,6 +38,8 @@
  */
 public abstract class ConfigTestSuite implements IConstants
 {
+  private static final boolean DISABLE_MAIN_SUITE_FINISHED = OMPlatform.INSTANCE.isProperty("disable.main.suite.finished");
+
   private final List<IScenario> scenarios = new ArrayList<IScenario>();
 
   public ConfigTestSuite()
@@ -129,15 +132,18 @@
 
   protected void mainSuiteFinished()
   {
-    for (IScenario scenario : scenarios)
+    if (!DISABLE_MAIN_SUITE_FINISHED)
     {
-      try
+      for (IScenario scenario : scenarios)
       {
-        scenario.mainSuiteFinished();
-      }
-      catch (Exception ex)
-      {
-        IOUtil.print(ex);
+        try
+        {
+          scenario.mainSuiteFinished();
+        }
+        catch (Exception ex)
+        {
+          IOUtil.print(ex);
+        }
       }
     }
   }
diff --git a/releng/org.eclipse.emf.cdo.releng/hudson/generate.ant b/releng/org.eclipse.emf.cdo.releng/hudson/generate.ant
index ec35806..e70d34e 100644
--- a/releng/org.eclipse.emf.cdo.releng/hudson/generate.ant
+++ b/releng/org.eclipse.emf.cdo.releng/hudson/generate.ant
@@ -9,7 +9,7 @@
 	Contributors:
 	  Eike Stepper - initial API and implementation
 -->
-<project name="CDO" default="generate">
+<project name="generate" default="generate">
 
   <!-- ==== -->
   <!-- Init -->
@@ -19,14 +19,9 @@
     <property environment="env" />
     <property name="build.root" value="${env.WORKSPACE}" />
     <property name="git.clone" location="${build.root}/git" />
-    <property name="features.dir" location="${git.clone}/features" />
-    <property name="plugins.dir" location="${git.clone}/plugins" />
     <property name="releng.dir" location="${git.clone}/releng" />
     <property name="releng" location="${releng.dir}/org.eclipse.emf.cdo.releng" />
-    <property name="releng.help" location="${releng.dir}/org.eclipse.emf.cdo.releng.help" />
     <property name="releng.site" location="${releng.dir}/org.eclipse.emf.cdo.releng.site" />
-    <property name="test.report" location="${build.root}/test-report.xml" />
-    <property name="zips" location="${build.root}/zips" />
 
     <property file="ant.properties" />
     <property file="${build.root}/build-info.properties" />
@@ -43,6 +38,7 @@
         <include name="plugins/**" />
         <include name="binary/**" />
         <include name="zips/**" />
+        <include name="tests/**" />
         <include name="help/**" />
         <include name="*.jar" />
         <include name="*.css" />
@@ -58,11 +54,13 @@
       </fileset>
     </delete>
     
+  	<!--
     <echoxml file="${test.report}">
       <testsuite name="CDO AllTests" tests="1" errors="0" failures="0" ignored="0">
         <testcase name="noTestHasBeenExecuted" classname="org.eclipse.emf.cdo.tests.NoTest" time="0.00"/>
       </testsuite>
     </echoxml>
+    -->
   </target>
 
   <!-- ============= -->
@@ -102,6 +100,7 @@
   <!-- ============= -->
 
   <target name="generate-help" depends="clean">
+    <property name="releng.help" location="${releng.dir}/org.eclipse.emf.cdo.releng.help" />
     <mkdir dir="${build.root}/help" />
     <copy todir="${build.root}/help">
       <fileset dir="${releng.help}/html">
@@ -153,6 +152,7 @@
   <!-- ================ -->
 
   <target name="generate-dropins" depends="clean">
+    <property name="zips" location="${build.root}/zips" />
     <mkdir dir="${zips}" />
     <zip destfile="${zips}/emf-cdo-${build.qualifier}-Dropins.zip">
       <fileset dir="${releng.site}/target/repository">
@@ -165,9 +165,9 @@
           file="${zips}/emf-cdo-${build.qualifier}-Dropins.properties" />
   </target>
 
-  <!-- ============ -->
-  <!-- Generate API -->
-  <!-- ============ -->
+  <!-- ==================== -->
+  <!-- Generate API Reports -->
+  <!-- ==================== -->
 
   <target name="generate-apireports" depends="clean">
   	<copy file="${releng}/api/api.xml" todir="${build.root}" overwrite="true" />
@@ -182,10 +182,45 @@
     </java>
   </target>
 
+  <!-- ==================== -->
+  <!-- Generate Test Reports -->
+  <!-- ==================== -->
+
+  <target name="generate-testreports" depends="clean">
+    <property name="tests" location="${build.root}/tests" />
+    <mkdir dir="${tests}" />
+    <copy todir="${tests}/tmp" flatten="true">
+      <fileset dir="${build.root}">
+        <include name="**/target/surefire-reports/TEST-*.xml" />
+      </fileset>
+    </copy>
+    <java classname="org.eclipse.emf.cdo.releng.FixTestReportNesting">
+      <classpath>
+        <pathelement location="${releng}/target/classes/" />
+      </classpath>
+      <arg value="${tests}/tmp" />
+    </java>
+    <junitreport todir="${tests}">
+      <fileset dir="${tests}/tmp/singles">
+        <include name="TEST-*.xml" />
+      </fileset>
+      <report format="frames" todir="${tests}">
+        <param name="TITLE" expression="CDO ${build.qualifier} Test Results" />
+      </report>
+    </junitreport>
+    <delete includeemptydirs="true">
+      <fileset dir="${tests}">
+        <include name="tmp/**" />
+      </fileset>
+    </delete>
+    <replace dir="${tests}" includes="**/package-summary.html" token="&lt;h3&gt;Package " value="&lt;h3&gt;Scenario " />
+    <replace dir="${tests}" includes="overview-*.html" token="&lt;h2&gt;Packages&lt;/h2&gt;" value="&lt;h2&gt;Scenarios&lt;/h2&gt;" />
+  </target>
+
   <!-- ======== -->
   <!-- Generate -->
   <!-- ======== -->
 
-  <target name="generate" depends="generate-site,generate-help,generate-bookmarks,generate-dropins,generate-apireports" />
+  <target name="generate" depends="generate-site,generate-help,generate-bookmarks,generate-dropins,generate-apireports,generate-testreports" />
 
 </project>
diff --git a/releng/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/FixTestReportNesting.java b/releng/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/FixTestReportNesting.java
new file mode 100644
index 0000000..86f426d
--- /dev/null
+++ b/releng/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/FixTestReportNesting.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2017 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Eike Stepper
+ */
+public class FixTestReportNesting
+{
+  private static final String NL = System.getProperty("line.separator");
+
+  private static final Pattern TESTCASE = Pattern.compile("<testcase name=\"([^\"]*)\" classname=\"([^\"]*)\" time=\"([^\"]*)\"(/?>)");
+
+  private static StringBuilder builder;
+
+  private static String lastClassname;
+
+  private static String scenario;
+
+  private static String artificialClassname;
+
+  private static File folder;
+
+  private static int tests;
+
+  private static int errors;
+
+  private static int failures;
+
+  private static float times;
+
+  public static void main(String[] args) throws Exception
+  {
+    folder = new File(args[0]);
+
+    for (File file : folder.listFiles())
+    {
+      String name = file.getName();
+      if (name.startsWith("TEST-") && name.endsWith(".xml"))
+      {
+        fix(file);
+      }
+    }
+  }
+
+  private static void fix(File file) throws IOException
+  {
+    String path = file.getAbsolutePath();
+    scenario = path.substring(0, path.length() - ".xml".length());
+    scenario = scenario.substring(scenario.lastIndexOf('.') + 1);
+
+    BufferedReader reader = null;
+
+    try
+    {
+      reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+
+      String line;
+      while ((line = reader.readLine()) != null)
+      {
+        String trimmed = line.trim();
+        if (trimmed.startsWith("<testcase name="))
+        {
+          Matcher matcher = TESTCASE.matcher(trimmed);
+          if (matcher.matches())
+          {
+            String name = matcher.group(1);
+            String classname = matcher.group(2);
+            String time = matcher.group(3);
+            String ending = matcher.group(4);
+
+            times += Float.parseFloat(time);
+            ++tests;
+
+            if (!classname.equals(lastClassname))
+            {
+              if (lastClassname != null)
+              {
+                finishTestSuite();
+              }
+            }
+
+            lastClassname = classname;
+            artificialClassname = scenario + "." + lastClassname.substring(lastClassname.lastIndexOf('.') + 1);
+
+            if (builder == null)
+            {
+              builder = new StringBuilder();
+            }
+
+            writeln("  <testcase name=\"" + name + "\" classname=\"" + classname + "\" time=\"" + time + "\"" + ending);
+            continue;
+          }
+        }
+        else if (trimmed.startsWith("<error message="))
+        {
+          ++errors;
+        }
+        else if (trimmed.startsWith("<failure message="))
+        {
+          ++failures;
+        }
+        else if (trimmed.startsWith("</testsuite>"))
+        {
+          continue;
+        }
+
+        writeln(line);
+      }
+
+      if (lastClassname != null)
+      {
+        finishTestSuite();
+      }
+    }
+    finally
+    {
+      if (reader != null)
+      {
+        reader.close();
+      }
+    }
+  }
+
+  private static void finishTestSuite() throws IOException
+  {
+    if (builder != null)
+    {
+      String text = builder.toString();
+      builder = null;
+
+      File tmp = new File(folder, "singles");
+      tmp.mkdirs();
+
+      BufferedWriter writer = null;
+
+      try
+      {
+        writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(tmp, "TEST-" + artificialClassname + ".xml"))));
+        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+        writer.write(NL);
+        writer.write("<testsuite name=\"" + artificialClassname + "\" tests=\"" + tests + "\" errors=\"" + errors + "\" failures=\"" + failures + "\" time=\""
+            + times + "\">");
+        writer.write(NL);
+        writer.write(text);
+        writer.write("</testsuite>");
+        writer.write(NL);
+      }
+      finally
+      {
+        if (writer != null)
+        {
+          writer.close();
+        }
+      }
+
+      lastClassname = null;
+      tests = 0;
+      errors = 0;
+      failures = 0;
+      times = 0.0f;
+    }
+  }
+
+  private static void writeln(String line) throws IOException
+  {
+    if (builder != null)
+    {
+      builder.append(line);
+      builder.append(NL);
+    }
+  }
+}
diff --git a/releng/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Main.java b/releng/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Main.java
deleted file mode 100644
index 2da5b95..0000000
--- a/releng/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Main.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2017 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.releng;
-
-/**
- * @author Eike Stepper
- */
-public class Main
-{
-  public static void main(String[] args)
-  {
-    for (String arg : args)
-    {
-      System.out.println(arg);
-    }
-  }
-}