Handle tilde in java version options #2284

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-03-06 14:17:30 +11:00
parent e2b9351662
commit 4b62ab6006
2 changed files with 14 additions and 1 deletions

View File

@ -38,7 +38,7 @@ public class JavaVersion
private static final String UPDATE = "(?:(?<UNDERSCORE>_)(?<UPDATE>[0-9]+))?";
private static final String PRE = "(?:-(?<PRE>[a-zA-Z0-9]+))?";
private static final String BUILD = "(?:(?<PLUS>\\+)(?<BUILD>[0-9]+))?";
private static final String OPT = "(?:-(?<OPT>[-a-zA-Z0-9.]+))?";
private static final String OPT = "(?:-(?<OPT>[-a-zA-Z0-9.~]+))?";
private static final String VSTR_FORMAT = VNUM + UPDATE + PRE + BUILD + OPT;

View File

@ -148,4 +148,17 @@ public class JavaVersionTest
assertThat(version.getUpdate(),is(0));
assertThat(version.getSuffix(),is("Ubuntu-9b181-4"));
}
@Test
public void testUbuntu8()
{
JavaVersion version = JavaVersion.parse("1.8.0_151-8u151-b12-1~deb9u1-b12");
assertThat(version.getPlatform(),is(8));
assertThat(version.getMajor(),is(1));
assertThat(version.getMinor(),is(8));
assertThat(version.getMicro(),is(0));
assertThat(version.getUpdate(),is(151));
assertThat(version.getSuffix(),is("8u151-b12-1~deb9u1-b12"));
}
}