From 705b60dc1143b2e62326e67bbf25bdcee90843b2 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 15 Aug 2014 15:34:11 -0400 Subject: [PATCH] Use java Pattern directly in launcher instead of Scala API This keeps the launch jar smaller --- .../main/scala/xsbt/boot/ServerApplication.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/launch/src/main/scala/xsbt/boot/ServerApplication.scala b/launch/src/main/scala/xsbt/boot/ServerApplication.scala index 9194e1ff1..8ac87c4d7 100644 --- a/launch/src/main/scala/xsbt/boot/ServerApplication.scala +++ b/launch/src/main/scala/xsbt/boot/ServerApplication.scala @@ -222,12 +222,15 @@ object ServerLauncher { val stderr = new java.io.LineNumberReader(new java.io.InputStreamReader(process.getErrorStream)) // Looking for the first line which is `java version "1.7.0_60"` or similar val lineOption = try Option(stderr.readLine()) finally stderr.close() - val re = """java version "[0-9]+\.([0-9]+)\..*".*""".r - lineOption flatMap { - case re(v) => try Some(Integer.parseInt(v) > version) catch { case NonFatal(_) => None } - case other => - System.err.println(s"Failed to parse version from 'java -version' output '$other'") + val pattern = java.util.regex.Pattern.compile("""java version "[0-9]+\.([0-9]+)\..*".*""") + lineOption flatMap { line => + val matcher = pattern.matcher(line) + if (matcher.matches()) { + try Some(Integer.parseInt(matcher.group(1)) > version) catch { case NonFatal(_) => None } + } else { + System.err.println(s"Failed to parse version from 'java -version' output '$line'") None + } } } finally { process.destroy()