Skip to content

Commit

Permalink
[xa-prep-tasks] Support single-digit versions (dotnet#939)
Browse files Browse the repository at this point in the history
JDK 9 reports a single-digit version value:

	$ javac -version
	javac 9

Unfortunately, this means that the `<Which/>` task won't properly
recognize JDK 9's `javac` as passing the
`%(RequiredProgram.MinimumVersion)` value of 1.8, because `<Which/>`
requires *at least* two digits, not one. (Because `System.Version`
required at least two digits; one would throw `ArgumentException`.)

Update the `<Which/>` task so that it supports single-digit version
values, treating them as if they had a "minor" value of `0`.
  • Loading branch information
jonpryor authored and Redth committed Oct 30, 2017
1 parent 2dfcf89 commit c5f7aed
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool NeedInstall ()
return curVersion > maxVersion;
}

static readonly Regex VersionMatch = new Regex (@"(?<version>\d+\.\d+(\.\d+(\.\d+)?)?)");
static readonly Regex VersionMatch = new Regex (@"(?<version>\d+(\.\d+(\.\d+(\.\d+)?)?)?)");

Version GetCurrentVersion ()
{
Expand Down Expand Up @@ -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 ();
Expand Down

0 comments on commit c5f7aed

Please sign in to comment.