Search in sources :

Example 11 with Version

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));
}
Also used : Version(com.intellij.openapi.util.Version) File(java.io.File) Test(org.junit.Test)

Example 12 with Version

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);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Version(com.intellij.openapi.util.Version) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with Version

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;
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) Version(com.intellij.openapi.util.Version) Matcher(java.util.regex.Matcher) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with Version

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;
}
Also used : Version(com.intellij.openapi.util.Version) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with Version

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");
        }
    }
}
Also used : RequestFailedException(com.intellij.tasks.impl.RequestFailedException) Version(com.intellij.openapi.util.Version)

Aggregations

Version (com.intellij.openapi.util.Version)15 File (java.io.File)8 Nullable (org.jetbrains.annotations.Nullable)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Matcher (java.util.regex.Matcher)2 NotNull (org.jetbrains.annotations.NotNull)2 Test (org.junit.Test)2 GroupDescriptor (com.intellij.internal.statistic.beans.GroupDescriptor)1 UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)1 Notification (com.intellij.notification.Notification)1 SystemInfo (com.intellij.openapi.util.SystemInfo)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 RequestFailedException (com.intellij.tasks.impl.RequestFailedException)1 JdkBundle (com.intellij.util.JdkBundle)1 Plist (com.jetbrains.cidr.xcode.plist.Plist)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1