[releng] Force --release and use BREE to run tests

Make the EGit-Github build work if code is compiled with a Java > 1.8.
This prepares for moving the BREE to Java 11: when we do that, we
will need to be able to build nightly with and against Java 11, but
the stable branch against Java 1.8.

This requires a ~/.m2/toolchains.xml file defining at least a
JavaSE-1.8 toolchain. The CI build pods do have such toolchain
definitions.

Change-Id: I82e9cb4c2518bc13906d44cc1ead2724f7130ffe
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
index 9d2a692..b3f7a11 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
@@ -25,6 +25,7 @@
 @SuiteClasses({ ApplicationTest.class, //
 		AuthorizationTest.class, //
 		BlobTest.class, //
+		BreeSmokeTest.class, //
 		CollaboratorServiceTest.class, //
 		CommentTest.class, //
 		CommitCommentPayloadTest.class, //
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/BreeSmokeTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/BreeSmokeTest.java
new file mode 100644
index 0000000..ebf3357
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/BreeSmokeTest.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (C) 2021 Thomas Wolf <thomas.wolf@paranor.ch>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+
+import org.junit.Test;
+
+/**
+ * Simple test to guard against build setup errors such as --release not being
+ * effective.
+ */
+public class BreeSmokeTest {
+
+	@Test
+	public void testByteBuffer() {
+		// This test will fail if compiled against a Java 11 library without
+		// --release 8 and then run on a Java 8 JVM with Java 8 libraries
+		ByteBuffer buffer = ByteBuffer.allocate(10);
+		Buffer flipped = buffer.flip();
+		assertNotNull(flipped);
+	}
+}
diff --git a/pom.xml b/pom.xml
index a44bf51..2bfaf11 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,6 +67,24 @@
 
   <profiles>
     <profile>
+      <id>compile-jdk-newer-than-8</id>
+      <!-- The release argument is allowed only if the Java version used to run maven is > 1.8 -->
+      <activation>
+        <jdk>[9,]</jdk>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.eclipse.tycho</groupId>
+            <artifactId>tycho-compiler-plugin</artifactId>
+            <configuration>
+              <release>8</release>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
       <id>platform-oxygen</id>
       <activation>
         <property>
@@ -437,6 +455,7 @@
           <version>${tycho-version}</version>
           <configuration>
             <trimStackTrace>false</trimStackTrace>
+            <useJDK>BREE</useJDK>
           </configuration>
         </plugin>
         <plugin>