From 0e7bd25b0c21903d0461cd1b76a58981deb24272 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Mon, 16 Oct 2017 22:22:13 -0400 Subject: [PATCH] [xa-prep-tasks] Support single-digit versions JDK 9 reports a single-digit version value: $ javac -version javac 9 Unfortunately, this means that the `` task won't properly recognize JDK 9's `javac` as passing the `%(RequiredProgram.MinimumVersion)` value of 1.8, because `` requires *at least* two digits, not one. (Because `System.Version` required at least two digits; one would throw `ArgumentException`.) Update the `` task so that it supports single-digit version values, treating them as if they had a "minor" value of `0`. --- .../Xamarin.Android.BuildTools.PrepTasks/Which.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Which.cs b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Which.cs index 75611ab251a..f06a5d74cc9 100644 --- a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Which.cs +++ b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Which.cs @@ -138,7 +138,7 @@ bool NeedInstall () return curVersion > maxVersion; } - static readonly Regex VersionMatch = new Regex (@"(?\d+\.\d+(\.\d+(\.\d+)?)?)"); + static readonly Regex VersionMatch = new Regex (@"(?\d+(\.\d+(\.\d+(\.\d+)?)?)?)"); Version GetCurrentVersion () { @@ -167,6 +167,9 @@ internal static Version GetProgramVersion (string hostOS, string command) if (!m.Success) return; curVersion = m.Groups ["version"].Value; + if (!curVersion.Contains (".")) { + curVersion += ".0"; + } }; p.Start (); p.BeginOutputReadLine ();