From 15d1ffe257d1e21d50ab31c2676c83d258911ef6 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 31 Oct 2011 18:37:20 -0700 Subject: [PATCH] normalizing the options handling --- .../main/java/hudson/tools/JDKInstaller.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/tools/JDKInstaller.java b/core/src/main/java/hudson/tools/JDKInstaller.java index 9a05cd9434..f5af29f126 100644 --- a/core/src/main/java/hudson/tools/JDKInstaller.java +++ b/core/src/main/java/hudson/tools/JDKInstaller.java @@ -225,11 +225,14 @@ public class JDKInstaller extends ToolInstaller { ArgumentListBuilder args = new ArgumentListBuilder(); args.add(jdkBundle); - args.add("/s"); + if (isJava15() || isJava14()) { + args.add("/s","/v/qn REBOOT=ReallySuppress INSTALLDIR=\\\""+ expectedLocation +"\\\" /L \\\""+logFile+"\\\""); + } else { + // modern version supports arguments in more sane format. + args.add("/s","/v","/qn","/L","\\\""+logFile+"\\\"","REBOOT=ReallySuppress","INSTALLDIR=\\\""+ expectedLocation+"\\\""); + } // according to http://community.acresso.com/showthread.php?t=83301, \" is the trick to quote values with whitespaces. // Oh Windows, oh windows, why do you have to be so difficult? - args.add("/v/qn REBOOT=ReallySuppress INSTALLDIR=\\\""+ expectedLocation +"\\\" /L \\\""+logFile+"\\\""); - int r = launcher.launch().cmds(args).stdout(out) .pwd(new FilePath(launcher.getChannel(), expectedLocation)).join(); if (r != 0) { @@ -250,6 +253,14 @@ public class JDKInstaller extends ToolInstaller { } } + private boolean isJava15() { + return id.contains("-1.5"); + } + + private boolean isJava14() { + return id.contains("-1.4"); + } + /** * Abstraction of the file system to perform JDK installation. * Consider {@link FilePathFileSystem} as the canonical documentation of the contract. -- GitLab