use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.
the class JdkBundleTest method testCreateBoot.
@Test
public void testCreateBoot() throws Exception {
File homeJDK = new File(System.getProperty("java.home")).getParentFile();
// Skip pure jre
if (!new File(homeJDK, "lib/tools.jar").exists())
return;
File bootJDK = SystemInfo.isMac ? homeJDK.getParentFile().getParentFile() : homeJDK;
String verStr = System.getProperty("java.version");
boolean macNonStandardJDK = SystemInfo.isMac && !new File(bootJDK, "Contents/Home").exists();
JdkBundle bundle = // the test is run under jdk with non-standard layout
macNonStandardJDK ? // the test is run under jdk with non-standard layout
JdkBundle.createBoot(false) : JdkBundle.createBoot();
assertNotNull(bundle);
assertTrue(bundle.isBoot());
assertFalse(bundle.isBundled());
assertTrue(FileUtil.filesEqual(bundle.getLocation(), macNonStandardJDK ? homeJDK : bootJDK));
Pair<Version, Integer> verUpdate = bundle.getVersionUpdate();
assertNotNull(verUpdate);
assertNotNull(bundle.getUpdateNumber());
final String evalVerStr = verUpdate.first.toString() + "_" + verUpdate.second.toString();
assertTrue(evalVerStr + " is not the same with " + verStr, verStr.contains(evalVerStr));
}
use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.
the class VersionUtil method parseVersionAndUpdate.
@Nullable
public static Pair<Version, Integer> parseVersionAndUpdate(@NotNull String version, @NotNull Pattern... patterns) {
String[] versions = null;
String updateStr = null;
for (Pattern pattern : patterns) {
Matcher matcher = pattern.matcher(version);
if (matcher.find()) {
String versionGroup = matcher.group(1);
if (versionGroup != null) {
updateStr = matcher.groupCount() > 1 ? matcher.group(2) : null;
versions = versionGroup.split("\\.");
break;
}
}
}
if (versions == null || versions.length < 2) {
return null;
}
Integer update = null;
if (updateStr != null) {
try {
update = Integer.parseInt(updateStr);
} catch (NumberFormatException e) {
// ignore
}
}
// Treating no update info as update 0
if (update == null)
update = new Integer(0);
return Pair.create(new Version(Integer.parseInt(versions[0]), Integer.parseInt(versions[1]), (versions.length > 2) ? Integer.parseInt(versions[2]) : 0), update);
}
use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.
the class CmdVersionClient method parseVersion.
@NotNull
public static Version parseVersion(@NotNull String versionText) throws SvnBindException {
Version result = null;
Exception cause = null;
Matcher matcher = VERSION.matcher(versionText);
boolean found = matcher.find();
if (found) {
try {
result = new Version(getInt(matcher.group(1)), getInt(matcher.group(2)), getInt(matcher.group(3)));
} catch (NumberFormatException e) {
cause = e;
}
}
if (!found || cause != null) {
throw new SvnBindException(String.format("Could not parse svn version: %s", versionText), cause);
}
return result;
}
use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.
the class SvnExecutableChecker method validate.
@Override
@Nullable
protected Notification validate(@NotNull String executable) {
Notification result = createDefaultNotification();
// Necessary executable path will be taken from settings while command execution
final Version version = getConfiguredClientVersion();
if (version != null) {
try {
result = validateVersion(version);
if (result == null) {
result = validateLocale();
}
} catch (Throwable e) {
LOG.info(e);
}
}
return result;
}
use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.
the class BugzillaRepository method ensureVersionDiscovered.
private void ensureVersionDiscovered() throws Exception {
if (myVersion == null) {
Hashtable<String, Object> result = new BugzillaXmlRpcRequest("Bugzilla.version").execute();
if (result == null) {
throw new RequestFailedException(TaskBundle.message("bugzilla.failure.no.version"));
}
String version = (String) result.get("version");
String[] parts = version.split("\\.", 3);
myVersion = new Version(Integer.parseInt(parts[0]), parts.length > 1 ? Integer.parseInt(parts[1]) : 0, parts.length > 2 ? Integer.parseInt(parts[2]) : 0);
if (myVersion.lessThan(3, 4)) {
throw new RequestFailedException("Bugzilla before 3.4 is not supported");
}
}
}
Aggregations