Search in sources :

Example 1 with Version

use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.

the class CmdCheckoutClient method getSupportedFormats.

@Override
public List<WorkingCopyFormat> getSupportedFormats() throws VcsException {
    ArrayList<WorkingCopyFormat> result = new ArrayList<>();
    Version version = myFactory.createVersionClient().getVersion();
    result.add(WorkingCopyFormat.from(version));
    return result;
}
Also used : WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) Version(com.intellij.openapi.util.Version) ArrayList(java.util.ArrayList)

Example 2 with Version

use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.

the class JdkBundleListTest method testAddBundle.

@Test
public void testAddBundle() throws Exception {
    JdkBundle jb0 = new JdkBundle(new File("/jb0"), "java", Pair.create(new Version(1, 8, 0), new Integer(0)), true, false);
    JdkBundle jb1 = new JdkBundle(new File("/jb1"), "java", Pair.create(new Version(1, 8, 0), new Integer(1)), false, false);
    JdkBundle jb2 = new JdkBundle(new File("/jb2"), "java", Pair.create(new Version(1, 8, 0), new Integer(2)), false, false);
    JdkBundle jb3 = new JdkBundle(new File("/jb3"), "java", Pair.create(new Version(1, 8, 0), new Integer(3)), false, false);
    JdkBundle jb4 = new JdkBundle(new File("/jb4"), "java", Pair.create(new Version(1, 8, 0), new Integer(4)), false, false);
    JdkBundle ob0 = new JdkBundle(new File("/ob0"), "openjdk", Pair.create(new Version(1, 8, 0), new Integer(0)), false, true);
    JdkBundle ob1 = new JdkBundle(new File("/ob1"), "openjdk", Pair.create(new Version(1, 8, 0), new Integer(1)), false, false);
    JdkBundle ob2 = new JdkBundle(new File("/ob2"), "openjdk", Pair.create(new Version(1, 8, 0), new Integer(2)), false, false);
    JdkBundle ob3 = new JdkBundle(new File("/ob3"), "openjdk", Pair.create(new Version(1, 8, 0), new Integer(3)), false, false);
    JdkBundle ob4 = new JdkBundle(new File("/ob4"), "openjdk", Pair.create(new Version(1, 8, 0), new Integer(4)), false, false);
    JdkBundleList bundleList = new JdkBundleList();
    bundleList.addBundle(jb3, false);
    bundleList.addBundle(ob1, false);
    bundleList.addBundle(jb2, false);
    bundleList.addBundle(ob2, false);
    bundleList.addBundle(jb0, true);
    bundleList.addBundle(ob0, true);
    bundleList.addBundle(jb1, false);
    bundleList.addBundle(ob4, false);
    bundleList.addBundle(jb4, false);
    bundleList.addBundle(ob3, false);
    assertSameElements(bundleList.toArrayList(), Arrays.asList(jb4, ob4, jb0, ob0));
}
Also used : Version(com.intellij.openapi.util.Version) File(java.io.File) Test(org.junit.Test)

Example 3 with Version

use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.

the class JdkBundleTest method doTestCreateBundle.

public void doTestCreateBundle(File homeJDK) throws Exception {
    // 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 = macNonStandardJDK ? // the test is run under jdk with non-standard layout
    JdkBundle.createBundle(homeJDK, "", true, false, true) : JdkBundle.createBundle(bootJDK, true, false);
    assertNotNull(bundle);
    assertTrue(bundle.isBoot());
    assertFalse(bundle.isBundled());
    assertTrue(FileUtil.filesEqual(bundle.getLocation(), macNonStandardJDK ? homeJDK : bootJDK));
    Pair<Version, Integer> verUpdate = bundle.getVersionUpdate();
    assertNotNull(verUpdate);
    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)

Example 4 with Version

use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.

the class SystemHealthMonitor method checkJvm.

private void checkJvm() {
    if (StringUtil.endsWithIgnoreCase(System.getProperty("java.version", ""), "-ea")) {
        showNotification(new KeyHyperlinkAdapter("unsupported.jvm.ea.message"));
    }
    JdkBundle bundle = JdkBundle.createBoot();
    if (bundle != null && !bundle.isBundled()) {
        Version version = bundle.getVersion();
        Integer updateNumber = bundle.getUpdateNumber();
        if (version != null && updateNumber != null && updateNumber < 112) {
            final String bundleVersion = version.toCompactString() + "u" + updateNumber;
            boolean showSwitchOption = false;
            final File bundledJDKAbsoluteLocation = JdkBundle.getBundledJDKAbsoluteLocation();
            if (bundledJDKAbsoluteLocation.exists() && bundle.getBitness() == Bitness.x64) {
                if (SystemInfo.isMacIntel64) {
                    showSwitchOption = true;
                } else if (SystemInfo.isWindows || SystemInfo.isLinux) {
                    JdkBundle bundledJdk = JdkBundle.createBundle(bundledJDKAbsoluteLocation, false, false);
                    if (bundledJdk != null && bundledJdk.getVersion() != null) {
                        // Version of bundled jdk is available, so the jdk is compatible with underlying OS
                        showSwitchOption = true;
                    }
                }
            }
            if (showSwitchOption) {
                showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message1") {

                    @Override
                    protected void hyperlinkActivated(HyperlinkEvent e) {
                        String url = e.getDescription();
                        if ("ack".equals(url)) {
                            myProperties.setValue(getIgnoreKey(), "true");
                        } else if ("switch".equals(url)) {
                            ActionManager.getInstance().getAction(SWITCH_JDK_ACTION).actionPerformed(null);
                        } else {
                            BrowserUtil.browse(url);
                        }
                    }
                }, bundleVersion, LATEST_JDK_RELEASE);
            } else {
                showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message2"), bundleVersion, LATEST_JDK_RELEASE);
            }
        }
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Version(com.intellij.openapi.util.Version) File(java.io.File) JdkBundle(com.intellij.util.JdkBundle)

Example 5 with Version

use of com.intellij.openapi.util.Version in project intellij-community by JetBrains.

the class OsVersionUsageCollector method getUsages.

@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
    UsageDescriptor descriptor;
    if (SystemInfo.isLinux) {
        String releaseId = null, releaseVersion = null;
        try {
            Map<String, String> values = Files.lines(Paths.get("/etc/os-release")).map(line -> StringUtil.split(line, "=")).filter(parts -> parts.size() == 2).collect(Collectors.toMap(parts -> parts.get(0), parts -> StringUtil.unquoteString(parts.get(1))));
            releaseId = values.get("ID");
            releaseVersion = values.get("VERSION_ID");
        } catch (IOException ignored) {
        }
        if (releaseId == null)
            releaseId = "unknown";
        if (releaseVersion == null) {
            releaseVersion = SystemInfo.OS_VERSION;
            Version version = Version.parseVersion(releaseVersion);
            if (version != null) {
                releaseVersion = version.toCompactString();
            }
        }
        descriptor = new UsageDescriptor("Linux/" + releaseId + " " + releaseVersion, 1);
    } else {
        descriptor = new UsageDescriptor(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, 1);
    }
    return Collections.singleton(descriptor);
}
Also used : GroupDescriptor(com.intellij.internal.statistic.beans.GroupDescriptor) Files(java.nio.file.Files) StringUtil(com.intellij.openapi.util.text.StringUtil) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) SystemInfo(com.intellij.openapi.util.SystemInfo) Version(com.intellij.openapi.util.Version) Paths(java.nio.file.Paths) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Version(com.intellij.openapi.util.Version) IOException(java.io.IOException) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Version (com.intellij.openapi.util.Version)19 File (java.io.File)10 NotNull (org.jetbrains.annotations.NotNull)4 Matcher (java.util.regex.Matcher)3 Nullable (org.jetbrains.annotations.Nullable)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)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 Module (com.intellij.openapi.module.Module)1 SystemInfo (com.intellij.openapi.util.SystemInfo)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 PsiFile (com.intellij.psi.PsiFile)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