From a8ecc4fa4a017e4fbf742b082e96f3d0febfc98d Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Thu, 13 Apr 2023 23:08:40 +0200 Subject: [PATCH 1/8] Build with Tycho 3.0.4 and set up Maven toolchains General guide for Maven toolchains: https://maven.apache.org/guides/mini/guide-using-toolchains.html Using the Maven-Toolchain-Plugin and its 'toolchain' goal the maven-compiler-plugin is configured to use a JDK from the toolchain that matches the specified release version. Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that matches the Bundle-RequiredExecutionEnvironment: https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK Configure the Maven-Surefire-Plugin to use a specific JDK version from the toolchain to launch a test runtime: https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain Configure the Tycho-Surefire-Plugin to use a specific JDK version from the toolchain to launch a test runtime: https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK About the toolchains.xml generated by the setup-java Github action and the exported JAVA_HOME_ environment variables: - https://github.com/actions/setup-java/#install-multiple-jdks - https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains Fixes https://github.com/eclipse/xtext/issues/2216 --- Jenkinsfile | 52 +++++++++++++-------------- jenkins/nightly-deploy/Jenkinsfile | 6 +++- pom.xml | 58 ++++++++++++++++++++++++++++++ releng/toolchains.xml | 25 +++++++++++++ 4 files changed, 114 insertions(+), 27 deletions(-) create mode 100644 releng/toolchains.xml diff --git a/Jenkinsfile b/Jenkinsfile index b314d470efd..e0c1b8f0e62 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,16 +7,13 @@ pipeline { parameters { choice(name: 'TARGET_PLATFORM', choices: ['r202203', 'r202206', 'r202209', 'r202212', 'r202303', 'latest'], description: 'Which Target Platform should be used?') - // see https://wiki.eclipse.org/Jenkins#JDK - choice(name: 'JDK_VERSION', description: 'Which JDK should be used?', choices: [ - 'temurin-jdk11-latest', 'temurin-jdk17-latest' - ]) + choice(name: 'JDK_VERSION', choices: [ '11', '17' ], description: 'Which JDK version should be used?') } triggers { parameterizedCron(env.BRANCH_NAME == 'main' ? ''' - H H(0-1) * * * %TARGET_PLATFORM=r202203;JDK_VERSION=temurin-jdk17-latest - H H(3-4) * * * %TARGET_PLATFORM=latest;JDK_VERSION=temurin-jdk17-latest + H H(0-1) * * * %TARGET_PLATFORM=r202203;JDK_VERSION=17 + H H(3-4) * * * %TARGET_PLATFORM=latest;JDK_VERSION=17 ''' : '') } @@ -28,7 +25,8 @@ pipeline { tools { maven "apache-maven-3.8.6" - jdk "${params.JDK_VERSION}" + // see https://wiki.eclipse.org/Jenkins#JDK + jdk "temurin-jdk17-latest" } stages { @@ -59,10 +57,29 @@ pipeline { stage('Maven/Tycho Build & Test') { environment { MAVEN_OPTS = "-Xmx1500m" + JAVA_HOME_11_X64 = tool(type:'jdk', name:'temurin-jdk11-latest') + JAVA_HOME_17_X64 = tool(type:'jdk', name:'temurin-jdk17-latest') } steps { xvnc(useXauthority: true) { - sh "./full-build.sh --tp=${selectedTargetPlatform()} ${javaVersionBasedProperties()}" + //TODO: remove the following test print out + sh ''' + echo 'JAVA_HOME_11_X64=${JAVA_HOME_11_X64}' + echo 'JAVA_HOME_17_X64=${JAVA_HOME_17_X64}' + echo 'Predefined Jenkins Toolchain content' + cat ~/.m2e/toolchains.xml + ''' + script { + def mavenSurfireJDKToolchain = params.JDK_VERSION + def tychoSurefireJDK = params.JDK_VERSION == '17' ? 'SYSTEM' : 'BREE' + sh """ + ./full-build.sh --tp=${selectedTargetPlatform()} \ + -Pstrict-jdk + --toolchains releng/toolchains.xml + -Dmaven.surefire.runtimeJDK=${mavenSurfireJDKToolchain} \ + -Dtycho.surefire.runtimeJDK=${tychoSurefireJDK} + """ + } } }// END steps } // END stage @@ -116,7 +133,7 @@ pipeline { /** return the Java version as Integer (8, 11, ...) */ def javaVersion() { - return Integer.parseInt(params.JDK_VERSION.replaceAll(".*-jdk(\\d+).*", "\$1")) + return Integer.parseInt(params.JDK_VERSION) } /** returns true when this build was triggered by an upstream build */ @@ -161,20 +178,3 @@ def selectedTargetPlatform() { return tp } } - -/** - * Tycho 3 requires Java 17. - * If the build uses Java version 11, we return the proper tycho-version override. - * Otherwise, we return an empty string. - */ -def javaVersionBasedProperties() { - def javaVersion = javaVersion() - - if (javaVersion<17) { - println("Switching to Tycho 2.7.5 with Java ${javaVersion}") - return '-Dtycho-version=2.7.5' - } else { - return '' - } -} - diff --git a/jenkins/nightly-deploy/Jenkinsfile b/jenkins/nightly-deploy/Jenkinsfile index 1f1f2a308c3..33486b1ebbf 100644 --- a/jenkins/nightly-deploy/Jenkinsfile +++ b/jenkins/nightly-deploy/Jenkinsfile @@ -34,13 +34,17 @@ pipeline { } } stage('Maven Tycho Build, Sign, Deploy') { + environment { + JAVA_HOME_11_X64 = tool(type:'jdk', name:'temurin-jdk11-latest') + JAVA_HOME_17_X64 = tool(type:'jdk', name:'temurin-jdk17-latest') + } steps { withCredentials([file(credentialsId: 'secret-subkeys.asc', variable: 'KEYRING')]) { sh 'gpg --batch --import "${KEYRING}"' sh 'for fpr in $(gpg --list-keys --with-colons | awk -F: \'/fpr:/ {print $10}\' | sort -u); do echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key ${fpr} trust; done' } sshagent(['projects-storage.eclipse.org-bot-ssh']) { - sh './full-deploy.sh -Peclipse-sign,sonatype-oss-release,release-snapshot' + sh ' ./full-deploy.sh -Peclipse-sign,sonatype-oss-release,release-snapshot,strict-jdk --toolchains releng/toolchains.xml' } } } diff --git a/pom.xml b/pom.xml index d7cd5a86ec2..d3fad9d6942 100644 --- a/pom.xml +++ b/pom.xml @@ -186,6 +186,11 @@ ${releases-zip-directory}/${current-release-zip-subdirectory} TMF Xtext Update Site + + + ${java.specification.version} + SYSTEM + @@ -400,6 +405,59 @@ + + strict-jdk + + + + org.apache.maven.plugins + maven-toolchains-plugin + 3.1.0 + + + + toolchain + + + + + + + ${maven.compiler.release} + + + + + + + + + org.eclipse.tycho + tycho-compiler-plugin + + BREE + + + + org.eclipse.tycho + tycho-surefire-plugin + + ${tycho.surefire.runtimeJDK} + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${maven.surefire.runtimeJDK} + + + + + + + diff --git a/releng/toolchains.xml b/releng/toolchains.xml new file mode 100644 index 00000000000..b12a3999dc8 --- /dev/null +++ b/releng/toolchains.xml @@ -0,0 +1,25 @@ + + + + jdk + + JavaSE-11 + 11 + + + ${env.JAVA_HOME_11_X64} + + + + jdk + + JavaSE-17 + 17 + + + ${env.JAVA_HOME_17_X64} + + + From 416cb580528b99ab633e1392c1a25d2059673801 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 19 Apr 2023 09:02:42 +0200 Subject: [PATCH 2/8] fixed .m2/toolchains.xml --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e0c1b8f0e62..6b76dfbcf4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ pipeline { echo 'JAVA_HOME_11_X64=${JAVA_HOME_11_X64}' echo 'JAVA_HOME_17_X64=${JAVA_HOME_17_X64}' echo 'Predefined Jenkins Toolchain content' - cat ~/.m2e/toolchains.xml + cat ~/.m2/toolchains.xml ''' script { def mavenSurfireJDKToolchain = params.JDK_VERSION From cedbe4617eb3754b32a6781c381781d77a2dd44d Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 19 Apr 2023 09:24:06 +0200 Subject: [PATCH 3/8] configured surefire and compiler for toolchain --- pom.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d3fad9d6942..de8254805ee 100644 --- a/pom.xml +++ b/pom.xml @@ -442,7 +442,16 @@ org.eclipse.tycho tycho-surefire-plugin - ${tycho.surefire.runtimeJDK} + BREE + + + + org.apache.maven.plugins + maven-compiler-plugin + + + ${maven.compiler.release} + @@ -450,7 +459,7 @@ maven-surefire-plugin - ${maven.surefire.runtimeJDK} + ${maven.compiler.release} From bbce2f855ab70baa429b0f158046c1309a64893d Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 19 Apr 2023 09:24:26 +0200 Subject: [PATCH 4/8] Jenkinsfile enable toolchain only on JDK 11 --- Jenkinsfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b76dfbcf4d..2720e47e729 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,14 +70,9 @@ pipeline { cat ~/.m2/toolchains.xml ''' script { - def mavenSurfireJDKToolchain = params.JDK_VERSION - def tychoSurefireJDK = params.JDK_VERSION == '17' ? 'SYSTEM' : 'BREE' + def toolChainArgs = params.JDK_VERSION == '17' ? '' : '-Pstrict-jdk --toolchains releng/toolchains.xml' sh """ - ./full-build.sh --tp=${selectedTargetPlatform()} \ - -Pstrict-jdk - --toolchains releng/toolchains.xml - -Dmaven.surefire.runtimeJDK=${mavenSurfireJDKToolchain} \ - -Dtycho.surefire.runtimeJDK=${tychoSurefireJDK} + ./full-build.sh --tp=${selectedTargetPlatform()} ${toolChainArgs} """ } } From ed921f8dae51bd2e1901497c5c4644433a1c2cc4 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 19 Apr 2023 09:42:42 +0200 Subject: [PATCH 5/8] SYSTEM for tycho --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index de8254805ee..6868023a034 100644 --- a/pom.xml +++ b/pom.xml @@ -435,14 +435,14 @@ org.eclipse.tycho tycho-compiler-plugin - BREE + SYSTEM org.eclipse.tycho tycho-surefire-plugin - BREE + SYSTEM From 91cc5e9180465705bfc7abb0d311b09366f415d6 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 19 Apr 2023 11:32:44 +0200 Subject: [PATCH 6/8] maven-compiler-plugin configured in parent POM --- org.eclipse.xtend.maven.parent/pom.xml | 4 ---- org.eclipse.xtext.maven.parent/pom.xml | 4 ---- pom.xml | 5 +++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/org.eclipse.xtend.maven.parent/pom.xml b/org.eclipse.xtend.maven.parent/pom.xml index c1d1584bb0b..7fc0e485075 100644 --- a/org.eclipse.xtend.maven.parent/pom.xml +++ b/org.eclipse.xtend.maven.parent/pom.xml @@ -122,10 +122,6 @@ maven-archetype-plugin 3.0.1 - - maven-compiler-plugin - 3.10.1 - maven-deploy-plugin 2.8.2 diff --git a/org.eclipse.xtext.maven.parent/pom.xml b/org.eclipse.xtext.maven.parent/pom.xml index d2319c53de3..78e003f15f8 100644 --- a/org.eclipse.xtext.maven.parent/pom.xml +++ b/org.eclipse.xtext.maven.parent/pom.xml @@ -99,10 +99,6 @@ maven-antrun-plugin 3.1.0 - - maven-compiler-plugin - 3.10.1 - maven-deploy-plugin 2.8.2 diff --git a/pom.xml b/pom.xml index 6868023a034..c52df003503 100644 --- a/pom.xml +++ b/pom.xml @@ -472,6 +472,11 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + org.codehaus.mojo exec-maven-plugin From 8e378fb696126978b95f2730d3c14e9a1f854761 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 19 Apr 2023 12:12:07 +0200 Subject: [PATCH 7/8] don't configure maven-compiler in our maven plugins Or the toolchain mechanism will make the compilation fail. Moreover, I don't think we need to use tycho-compiler-jdt for compiling our maven plugins --- org.eclipse.xtend.maven.parent/pom.xml | 14 -------------- org.eclipse.xtext.maven.parent/pom.xml | 14 -------------- 2 files changed, 28 deletions(-) diff --git a/org.eclipse.xtend.maven.parent/pom.xml b/org.eclipse.xtend.maven.parent/pom.xml index 7fc0e485075..0ccced5cee1 100644 --- a/org.eclipse.xtend.maven.parent/pom.xml +++ b/org.eclipse.xtend.maven.parent/pom.xml @@ -71,20 +71,6 @@ - - maven-compiler-plugin - - jdt - true - - - - org.eclipse.tycho - tycho-compiler-jdt - ${tycho-version} - - - maven-source-plugin diff --git a/org.eclipse.xtext.maven.parent/pom.xml b/org.eclipse.xtext.maven.parent/pom.xml index 78e003f15f8..b95bfef44b3 100644 --- a/org.eclipse.xtext.maven.parent/pom.xml +++ b/org.eclipse.xtext.maven.parent/pom.xml @@ -52,20 +52,6 @@ - - maven-compiler-plugin - - jdt - true - - - - org.eclipse.tycho - tycho-compiler-jdt - ${tycho-version} - - - maven-source-plugin From d1c75209c60f293a30916b7043b0e1b77a4c43d2 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Thu, 20 Apr 2023 07:14:50 +0200 Subject: [PATCH 8/8] Clean up toolchain usage and reduce changes to required minimum --- Jenkinsfile | 29 ++++++++------------ jenkins/nightly-deploy/Jenkinsfile | 6 +--- pom.xml | 44 ++---------------------------- 3 files changed, 14 insertions(+), 65 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2720e47e729..6147541ff4e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,13 +7,16 @@ pipeline { parameters { choice(name: 'TARGET_PLATFORM', choices: ['r202203', 'r202206', 'r202209', 'r202212', 'r202303', 'latest'], description: 'Which Target Platform should be used?') - choice(name: 'JDK_VERSION', choices: [ '11', '17' ], description: 'Which JDK version should be used?') + // see https://wiki.eclipse.org/Jenkins#JDK + choice(name: 'JDK_VERSION', description: 'Which JDK should be used?', choices: [ + 'temurin-jdk11-latest', 'temurin-jdk17-latest' + ]) } triggers { parameterizedCron(env.BRANCH_NAME == 'main' ? ''' - H H(0-1) * * * %TARGET_PLATFORM=r202203;JDK_VERSION=17 - H H(3-4) * * * %TARGET_PLATFORM=latest;JDK_VERSION=17 + H H(0-1) * * * %TARGET_PLATFORM=r202203;JDK_VERSION=temurin-jdk17-latest + H H(3-4) * * * %TARGET_PLATFORM=latest;JDK_VERSION=temurin-jdk17-latest ''' : '') } @@ -25,7 +28,6 @@ pipeline { tools { maven "apache-maven-3.8.6" - // see https://wiki.eclipse.org/Jenkins#JDK jdk "temurin-jdk17-latest" } @@ -62,19 +64,10 @@ pipeline { } steps { xvnc(useXauthority: true) { - //TODO: remove the following test print out - sh ''' - echo 'JAVA_HOME_11_X64=${JAVA_HOME_11_X64}' - echo 'JAVA_HOME_17_X64=${JAVA_HOME_17_X64}' - echo 'Predefined Jenkins Toolchain content' - cat ~/.m2/toolchains.xml - ''' - script { - def toolChainArgs = params.JDK_VERSION == '17' ? '' : '-Pstrict-jdk --toolchains releng/toolchains.xml' - sh """ - ./full-build.sh --tp=${selectedTargetPlatform()} ${toolChainArgs} - """ - } + sh """ + ./full-build.sh --tp=${selectedTargetPlatform()} \ + ${javaVersion() == 17 ? '' : '--toolchains releng/toolchains.xml -Pstrict-release-jdk'} + """ } }// END steps } // END stage @@ -128,7 +121,7 @@ pipeline { /** return the Java version as Integer (8, 11, ...) */ def javaVersion() { - return Integer.parseInt(params.JDK_VERSION) + return Integer.parseInt(params.JDK_VERSION.replaceAll(".*-jdk(\\d+).*", "\$1")) } /** returns true when this build was triggered by an upstream build */ diff --git a/jenkins/nightly-deploy/Jenkinsfile b/jenkins/nightly-deploy/Jenkinsfile index 33486b1ebbf..1f1f2a308c3 100644 --- a/jenkins/nightly-deploy/Jenkinsfile +++ b/jenkins/nightly-deploy/Jenkinsfile @@ -34,17 +34,13 @@ pipeline { } } stage('Maven Tycho Build, Sign, Deploy') { - environment { - JAVA_HOME_11_X64 = tool(type:'jdk', name:'temurin-jdk11-latest') - JAVA_HOME_17_X64 = tool(type:'jdk', name:'temurin-jdk17-latest') - } steps { withCredentials([file(credentialsId: 'secret-subkeys.asc', variable: 'KEYRING')]) { sh 'gpg --batch --import "${KEYRING}"' sh 'for fpr in $(gpg --list-keys --with-colons | awk -F: \'/fpr:/ {print $10}\' | sort -u); do echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key ${fpr} trust; done' } sshagent(['projects-storage.eclipse.org-bot-ssh']) { - sh ' ./full-deploy.sh -Peclipse-sign,sonatype-oss-release,release-snapshot,strict-jdk --toolchains releng/toolchains.xml' + sh './full-deploy.sh -Peclipse-sign,sonatype-oss-release,release-snapshot' } } } diff --git a/pom.xml b/pom.xml index c52df003503..5c9c7b688c0 100644 --- a/pom.xml +++ b/pom.xml @@ -186,11 +186,6 @@ ${releases-zip-directory}/${current-release-zip-subdirectory} TMF Xtext Update Site - - - ${java.specification.version} - SYSTEM - @@ -406,7 +401,7 @@ - strict-jdk + strict-release-jdk @@ -423,48 +418,13 @@ + ${maven.compiler.release} - - - - org.eclipse.tycho - tycho-compiler-plugin - - SYSTEM - - - - org.eclipse.tycho - tycho-surefire-plugin - - SYSTEM - - - - org.apache.maven.plugins - maven-compiler-plugin - - - ${maven.compiler.release} - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${maven.compiler.release} - - - - -