This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-pipelines.git


The following commit(s) were added to refs/heads/master by this push:
     new 0254391  Switch to using tool and withEnv
0254391 is described below

commit 0254391c5186b9bf9c39ae2364a7bf83d8df5bd6
Author: Matt Sicker <[email protected]>
AuthorDate: Sat May 8 13:13:20 2021 -0500

    Switch to using tool and withEnv
    
    The withMaven step doesn't seem to work too well.
---
 vars/mvn.groovy | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/vars/mvn.groovy b/vars/mvn.groovy
index d3ad1ba..fda5bf1 100644
--- a/vars/mvn.groovy
+++ b/vars/mvn.groovy
@@ -16,18 +16,22 @@
  */
 
 def call(String args) {
+    String mavenHome = tool 'maven_3_latest'
     String javaVersion = '1.8'
     if (env.JOB_NAME == 'log4j' && env.BRANCH_NAME == 'master') {
         javaVersion = '11'
     }
-    withMaven(jdk: "jdk_${javaVersion}_latest", maven: 'maven_3_latest') {
-        if (isUnix()) {
+    String javaHome = tool "jdk_${javaVersion}_latest"
+    if (isUnix()) {
+        withEnv(["JAVA_HOME=$javaHome", 
"PATH+MAVEN=${mavenHome}/bin:${javaHome}/bin"]) {
             configFileProvider([configFile(fileId: 'ubuntu', variable: 
'TOOLCHAINS')]) {
                 // note that the jenkins system property is set here to 
activate certain pom properties in
                 // some log4j modules that compile against system jars (e.g., 
log4j-jmx-gui)
                 sh "mvn --toolchains \"\$TOOLCHAINS\" -Djenkins ${args}"
             }
-        } else {
+        }
+    } else {
+        withEnv(["JAVA_HOME=$javaHome", 
"PATH+MAVEN=${mavenHome}\\bin;${javaHome}\\bin"]) {
             configFileProvider([configFile(fileId: 'windows', variable: 
'TOOLCHAINS')]) {
                 bat "mvn --toolchains \"%TOOLCHAINS%\" ${args}"
             }

Reply via email to