Force a Java 1.8 JDK

EGit needs to be built with Java 1.8 for backwards compatibility
reasons. It shall be possible to use EGit with older Eclipse versions
before 2020-09, which didn't require Java 11.

Set the toolchain explicitly to 'adoptopenjdk-hotspot-jdk8-latest' by
default. This default can be overridden via config option config.jdk.

Bug: 570591
Change-Id: I3f8fd95782bd8d4994c7ff7295e1a7ed6b9069e2
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
diff --git a/.settings/org.eclipse.jdt.groovy.core.prefs b/.settings/org.eclipse.jdt.groovy.core.prefs
index 74af1ba..71b5e37 100644
--- a/.settings/org.eclipse.jdt.groovy.core.prefs
+++ b/.settings/org.eclipse.jdt.groovy.core.prefs
@@ -1,2 +1,3 @@
 eclipse.preferences.version=1
-groovy.compiler.level=25
+groovy.compiler.level=-1
+groovy.script.filters=**/*.dsld,y,**/*.gradle,n
diff --git a/vars/egitGithubProductBuild.groovy b/vars/egitGithubProductBuild.groovy
index f911e00..96b4bf2 100644
--- a/vars/egitGithubProductBuild.groovy
+++ b/vars/egitGithubProductBuild.groovy
@@ -34,7 +34,8 @@
 		upstreamVersion: params.EGIT_VERSION,
 		p2project : 'org.eclipse.mylyn.github-site',
 		p2zip : 'github-updatesite-*.zip',
-		publishRoot : 'egit/github'
+		publishRoot : 'egit/github',
+		jdk : 'adoptopenjdk-hotspot-jdk8-latest'
 	]
 	productBuild(lib, tooling, config << cfg)
 }
\ No newline at end of file
diff --git a/vars/egitGithubVerifyBuild.groovy b/vars/egitGithubVerifyBuild.groovy
index 408e6c7..c03c671 100644
--- a/vars/egitGithubVerifyBuild.groovy
+++ b/vars/egitGithubVerifyBuild.groovy
@@ -32,6 +32,7 @@
 		upstreamRepo : 'egit',
 		upstreamVersion: params.EGIT_VERSION,
 		p2project : 'org.eclipse.mylyn.github-site',
+		jdk : 'adoptopenjdk-hotspot-jdk8-latest'
 	]
 	verifyBuild(lib, tooling, config << cfg)
 }
\ No newline at end of file
diff --git a/vars/egitProductBuild.groovy b/vars/egitProductBuild.groovy
index c253040..d9acbf5 100644
--- a/vars/egitProductBuild.groovy
+++ b/vars/egitProductBuild.groovy
@@ -34,6 +34,7 @@
 		p2project : 'org.eclipse.egit.repository',
 		p2zip : 'org.eclipse.egit.repository-*.zip',
 		publishRoot : 'egit',
+		jdk : 'adoptopenjdk-hotspot-jdk8-latest'
 		// downstreamJob from cfg
 	]
 	productBuild(lib, tooling, config << cfg)
diff --git a/vars/egitVerifyBuild.groovy b/vars/egitVerifyBuild.groovy
index 4b05e51..30b2ef4 100644
--- a/vars/egitVerifyBuild.groovy
+++ b/vars/egitVerifyBuild.groovy
@@ -32,6 +32,7 @@
 		upstreamRepo : 'jgit',
 		// upstreamVersion from cfg or auto-determined
 		p2project : 'org.eclipse.egit.repository',
+		jdk : 'adoptopenjdk-hotspot-jdk8-latest'
 	]
 	verifyBuild(lib, tooling, config << cfg)
 }
\ No newline at end of file
diff --git a/vars/productBuild.groovy b/vars/productBuild.groovy
index 64e8947..f2346ac 100644
--- a/vars/productBuild.groovy
+++ b/vars/productBuild.groovy
@@ -39,11 +39,16 @@
 		// downstreamJob is optional: job to trigger after deployment
 	])
 	uiNode(config.timeOut) {
-		if (!env.GERRIT_BRANCH) {
-			env.GERRIT_BRANCH = config.defaultBranch
-		}
 		try {
+			if (!env.GERRIT_BRANCH) {
+				env.GERRIT_BRANCH = config.defaultBranch
+			}
+			if (config.jdk) {
+				def jdk = tool name: "${config.jdk}", type: 'jdk'
+				env.JAVA_HOME = "${jdk}"
+			}
 			stage('Checkout') {
+				sh '$JAVA_HOME/bin/java -version'
 				tooling.cloneAndCheckout(config.repoPath, env.GERRIT_BRANCH, '+refs/heads/*:refs/remotes/origin/*');
 			}
 			def ownVersion = lib.getOwnVersion('pom.xml')
diff --git a/vars/verifyBuild.groovy b/vars/verifyBuild.groovy
index e0ea924..c8f6b33 100644
--- a/vars/verifyBuild.groovy
+++ b/vars/verifyBuild.groovy
@@ -39,7 +39,12 @@
 			if (!env.GERRIT_BRANCH) {
 				env.GERRIT_BRANCH = config.defaultBranch
 			}
+			if (config.jdk) {
+				def jdk = tool name: "${config.jdk}", type: 'jdk'
+				env.JAVA_HOME = "${jdk}"
+			}
 			stage('Checkout') {
+				sh '$JAVA_HOME/bin/java -version'
 				tooling.cloneAndCheckout(config.repoPath, env.GERRIT_BRANCH, '$GERRIT_REFSPEC', [
 					extensions: [
 						[$class: 'BuildChooserSetting',