private static void updateExistingPluginInfo(
      IdeaPluginDescriptor descr, IdeaPluginDescriptor existing) {
    int state = StringUtil.compareVersionNumbers(descr.getVersion(), existing.getVersion());
    final PluginId pluginId = existing.getPluginId();
    final String idString = pluginId.getIdString();
    final JDOMExternalizableStringList installedPlugins =
        PluginManagerUISettings.getInstance().getInstalledPlugins();
    if (!installedPlugins.contains(idString)
        && !((IdeaPluginDescriptorImpl) existing).isDeleted()) {
      installedPlugins.add(idString);
    }
    final PluginManagerUISettings updateSettings = PluginManagerUISettings.getInstance();
    if (state > 0
        && !PluginManager.isIncompatible(descr)
        && !updatedPlugins.contains(descr.getPluginId())) {
      NewVersions2Plugins.put(pluginId, 1);
      if (!updateSettings.myOutdatedPlugins.contains(idString)) {
        updateSettings.myOutdatedPlugins.add(idString);
      }

      final IdeaPluginDescriptorImpl plugin = (IdeaPluginDescriptorImpl) existing;
      plugin.setDownloadsCount(descr.getDownloads());
      plugin.setVendor(descr.getVendor());
      plugin.setVendorEmail(descr.getVendorEmail());
      plugin.setVendorUrl(descr.getVendorUrl());
      plugin.setUrl(descr.getUrl());

    } else {
      updateSettings.myOutdatedPlugins.remove(idString);
      if (NewVersions2Plugins.remove(pluginId) != null) {
        updatedPlugins.add(pluginId);
      }
    }
  }
 public static void loadDescriptors(
     String pluginsPath,
     List<IdeaPluginDescriptorImpl> result,
     @Nullable StartupProgress progress,
     int pluginsCount) {
   final File pluginsHome = new File(pluginsPath);
   final File[] files = pluginsHome.listFiles();
   if (files != null) {
     int i = result.size();
     for (File file : files) {
       final IdeaPluginDescriptorImpl descriptor = loadDescriptor(file, PLUGIN_XML);
       if (descriptor == null) continue;
       if (progress != null) {
         progress.showProgress(
             descriptor.getName(), PLUGINS_PROGRESS_MAX_VALUE * ((float) ++i / pluginsCount));
       }
       int oldIndex = result.indexOf(descriptor);
       if (oldIndex >= 0) {
         final IdeaPluginDescriptorImpl oldDescriptor = result.get(oldIndex);
         if (StringUtil.compareVersionNumbers(oldDescriptor.getVersion(), descriptor.getVersion())
             < 0) {
           result.set(oldIndex, descriptor);
         }
       } else {
         result.add(descriptor);
       }
     }
   }
 }
 private static SimpleTextAttributes getTextAttributes(
     final boolean valid, final boolean selected) {
   if (!valid) {
     return SimpleTextAttributes.ERROR_ATTRIBUTES;
   } else if (selected
       && !((SystemInfo.isWindows
               && StringUtil.compareVersionNumbers(SystemInfo.OS_VERSION, "6.0") >= 0)
           && UIManager.getLookAndFeel().getName().contains("Windows"))) {
     return SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES;
   } else {
     return SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES;
   }
 }
  @Nullable
  private static Library actualizePackagesLibrary(
      @NotNull final Project project, @Nullable final DartSdk sdk) {
    if (sdk == null || StringUtil.compareVersionNumbers(sdk.getVersion(), "1.12") < 0) return null;

    final DartLibInfo libInfo = collectPackagesLibraryRoots(project, sdk);

    if (libInfo.getLibRootUrls().isEmpty()) {
      return null;
    } else {
      return updatePackagesLibraryRoots(project, libInfo);
    }
  }
  @Nullable
  private static String getAirVersionIfCustomDescriptor(final JpsFlexBuildConfiguration bc) {
    if (bc.getTargetPlatform() == TargetPlatform.Desktop) {
      final JpsAirDesktopPackagingOptions packagingOptions = bc.getAirDesktopPackagingOptions();
      if (!packagingOptions.isUseGeneratedDescriptor()) {
        return FlexCommonUtils.parseAirVersionFromDescriptorFile(
            packagingOptions.getCustomDescriptorPath());
      }
    } else if (bc.getTargetPlatform() == TargetPlatform.Mobile) {
      final JpsAndroidPackagingOptions androidOptions = bc.getAndroidPackagingOptions();
      final JpsIosPackagingOptions iosPackagingOptions = bc.getIosPackagingOptions();

      // if at least one of descriptors is generated - return null
      if (androidOptions.isEnabled() && androidOptions.isUseGeneratedDescriptor()
          || iosPackagingOptions.isEnabled() && iosPackagingOptions.isUseGeneratedDescriptor()) {
        return null;
      }

      String androidAirVersion = null;
      String iosAirVersion = null;

      if (androidOptions.isEnabled() && !androidOptions.isUseGeneratedDescriptor()) {
        androidAirVersion =
            FlexCommonUtils.parseAirVersionFromDescriptorFile(
                androidOptions.getCustomDescriptorPath());
      }

      if (iosPackagingOptions.isEnabled() && !iosPackagingOptions.isUseGeneratedDescriptor()) {
        iosAirVersion =
            FlexCommonUtils.parseAirVersionFromDescriptorFile(
                iosPackagingOptions.getCustomDescriptorPath());
      }

      if (androidAirVersion == null) return iosAirVersion;
      if (iosAirVersion == null) return androidAirVersion;

      // return minimal
      return StringUtil.compareVersionNumbers(androidAirVersion, iosAirVersion) > 0
          ? iosAirVersion
          : androidAirVersion;
    }
    return null;
  }
示例#6
0
  @Nullable
  private static File fromMacSystemJavaTools() {
    final File symlinkDir = new File("/usr/share/maven");
    if (isValidMavenHome(symlinkDir)) {
      return symlinkDir;
    }

    // well, try to search
    final File dir = new File("/usr/share/java");
    final String[] list = dir.list();
    if (list == null || list.length == 0) {
      return null;
    }

    String home = null;
    final String prefix = "maven-";
    final int versionIndex = prefix.length();
    for (String path : list) {
      if (path.startsWith(prefix)
          && (home == null
              || StringUtil.compareVersionNumbers(
                      path.substring(versionIndex), home.substring(versionIndex))
                  > 0)) {
        home = path;
      }
    }

    if (home != null) {
      File file = new File(dir, home);
      if (isValidMavenHome(file)) {
        return file;
      }
    }

    return null;
  }
  private void addMandatoryOptions(final Element rootElement) {
    if (!FlexCommonUtils.isRLMTemporaryBC(myBC)
        && !FlexCommonUtils.isRuntimeStyleSheetBC(myBC)
        && FlexCommonUtils.canHaveRLMsAndRuntimeStylesheets(myBC)
        && myBC.getRLMs().size() > 0) {
      addOption(rootElement, CompilerOptionInfo.LINK_REPORT_INFO, getLinkReportFilePath(myBC));
    }

    if (FlexCommonUtils.isRLMTemporaryBC(myBC) && !myBC.getOptimizeFor().isEmpty()) {
      final String customLinkReportPath = getCustomLinkReportPath(myBC);
      final String linkReportPath =
          StringUtil.notNullize(customLinkReportPath, getLinkReportFilePath(myBC));
      addOption(rootElement, CompilerOptionInfo.LOAD_EXTERNS_INFO, linkReportPath);
    }

    addOption(rootElement, CompilerOptionInfo.WARN_NO_CONSTRUCTOR_INFO, "false");
    if (myFlexmojos) return;

    final BuildConfigurationNature nature = myBC.getNature();
    final String targetPlayer =
        nature.isWebPlatform()
            ? myBC.getDependencies().getTargetPlayer()
            : FlexCommonUtils.getMaximumTargetPlayer(mySdk.getHomePath());
    addOption(rootElement, CompilerOptionInfo.TARGET_PLAYER_INFO, targetPlayer);

    if (FlexCommonUtils.isAirSdkWithoutFlex(mySdk)
        || StringUtil.compareVersionNumbers(mySdk.getVersionString(), "4.5") >= 0) {
      final String swfVersion;
      if (nature.isWebPlatform()) {
        swfVersion = FlexCommonUtils.getSwfVersionForTargetPlayer(targetPlayer);
      } else {
        String airVersion = getAirVersionIfCustomDescriptor(myBC);
        if (airVersion == null) {
          airVersion = FlexCommonUtils.getAirVersion(mySdk.getHomePath(), mySdk.getVersionString());
        }
        swfVersion =
            airVersion != null
                ? FlexCommonUtils.getSwfVersionForAirVersion(airVersion)
                : FlexCommonUtils.getSwfVersionForSdk_THE_WORST_WAY(mySdk.getVersionString());
      }

      addOption(rootElement, CompilerOptionInfo.SWF_VERSION_INFO, swfVersion);
    }

    if (nature.isMobilePlatform()) {
      addOption(rootElement, CompilerOptionInfo.MOBILE_INFO, "true");
      addOption(rootElement, CompilerOptionInfo.PRELOADER_INFO, "spark.preloaders.SplashScreen");
    }

    if (!FlexCommonUtils.isAirSdkWithoutFlex(mySdk)) {
      final String accessible =
          nature.isMobilePlatform()
              ? "false"
              : StringUtil.compareVersionNumbers(mySdk.getVersionString(), "4") >= 0
                  ? "true"
                  : "false";
      addOption(rootElement, CompilerOptionInfo.ACCESSIBLE_INFO, accessible);

      final String fontManagers =
          StringUtil.compareVersionNumbers(mySdk.getVersionString(), "4") >= 0
              ? "flash.fonts.JREFontManager"
                  + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR
                  + "flash.fonts.BatikFontManager"
                  + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR
                  + "flash.fonts.AFEFontManager"
                  + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR
                  + "flash.fonts.CFFFontManager"
              : "flash.fonts.JREFontManager"
                  + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR
                  + "flash.fonts.AFEFontManager"
                  + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR
                  + "flash.fonts.BatikFontManager";
      addOption(rootElement, CompilerOptionInfo.FONT_MANAGERS_INFO, fontManagers);

      addOption(rootElement, CompilerOptionInfo.STATIC_RSLS_INFO, "false");
    }
  }
  @NotNull
  private GroovycOutputParser runGroovycOrContinuation(
      CompileContext context,
      ModuleChunk chunk,
      JpsGroovySettings settings,
      Map<ModuleBuildTarget, String> finalOutputs,
      String compilerOutput,
      List<File> toCompile,
      boolean hasStubExcludes)
      throws Exception {
    GroovycContinuation continuation = takeContinuation(context, chunk);
    if (continuation != null) {
      if (Utils.IS_TEST_MODE || LOG.isDebugEnabled()) {
        LOG.info("using continuation for " + chunk);
      }
      return continuation.continueCompilation();
    }

    final Set<String> toCompilePaths = getPathsToCompile(toCompile);

    JpsSdk<JpsDummyElement> jdk = getJdk(chunk);
    String version = jdk == null ? SystemInfo.JAVA_RUNTIME_VERSION : jdk.getVersionString();
    boolean inProcess = "true".equals(System.getProperty("groovyc.in.process", "true"));
    boolean mayDependOnUtilJar =
        version != null && StringUtil.compareVersionNumbers(version, "1.6") >= 0;
    boolean optimizeClassLoading =
        !inProcess
            && mayDependOnUtilJar
            && ourOptimizeThreshold != 0
            && toCompilePaths.size() >= ourOptimizeThreshold;

    Map<String, String> class2Src =
        buildClassToSourceMap(chunk, context, toCompilePaths, finalOutputs);

    final String encoding =
        context
            .getProjectDescriptor()
            .getEncodingConfiguration()
            .getPreferredModuleChunkEncoding(chunk);
    List<String> patchers = new ArrayList<String>();

    for (GroovyBuilderExtension extension :
        JpsServiceManager.getInstance().getExtensions(GroovyBuilderExtension.class)) {
      patchers.addAll(extension.getCompilationUnitPatchers(context, chunk));
    }

    Collection<String> classpath = generateClasspath(context, chunk);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Optimized class loading: " + optimizeClassLoading);
      LOG.debug("Groovyc classpath: " + classpath);
    }

    final File tempFile =
        GroovycOutputParser.fillFileWithGroovycParameters(
            compilerOutput,
            toCompilePaths,
            finalOutputs.values(),
            class2Src,
            encoding,
            patchers,
            optimizeClassLoading ? StringUtil.join(classpath, File.pathSeparator) : "");
    GroovycFlavor groovyc =
        inProcess
            ? new InProcessGroovyc(finalOutputs.values(), hasStubExcludes)
            : new ForkedGroovyc(optimizeClassLoading, chunk);

    GroovycOutputParser parser = new GroovycOutputParser(chunk, context);

    continuation = groovyc.runGroovyc(classpath, myForStubs, settings, tempFile, parser);
    setContinuation(context, chunk, continuation);
    return parser;
  }
 public static boolean isOsVersionAtLeast(@NotNull String version) {
   return StringUtil.compareVersionNumbers(OS_VERSION, version) >= 0;
 }
示例#10
0
 public static boolean isJavaVersionAtLeast(String v) {
   return StringUtil.compareVersionNumbers(JAVA_RUNTIME_VERSION, v) >= 0;
 }
示例#11
0
 private static boolean hasDocTagsSupport() {
   String testngJarPath = PathUtil.getJarPathForClass(Test.class);
   String version =
       JarUtil.getJarAttribute(new File(testngJarPath), Attributes.Name.IMPLEMENTATION_VERSION);
   return version != null && StringUtil.compareVersionNumbers(version, "5.12") <= 0;
 }