Java Code Examples for com.intellij.openapi.application.PathManager#getPluginsPath()

The following examples show how to use com.intellij.openapi.application.PathManager#getPluginsPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PantsClasspathRunConfigurationExtension.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Filter out all jars imported to the project with the exception of
 * jars on the JDK path, IntelliJ installation paths, and plugin installation path,
 * because Pants is already exporting all the runtime classpath in manifest.jar.
 *
 * Exception applies during unit test of this plugin because "JUnit" and "com.intellij"
 * plugin lives under somewhere under ivy, whereas during normal usage, they are covered
 * by `homePath`.
 *
 *
 * @param params JavaParameters
 * @return a set of paths that should be allowed to passed to the test runner.
 */
@NotNull
private Set<String> calculatePathsAllowed(JavaParameters params) {

  String homePath = PathManager.getHomePath();
  String pluginPath = PathManager.getPluginsPath();

  Set<String> pathsAllowed = Sets.newHashSet(homePath, pluginPath);

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    // /Users/yic/.ivy2/pants/com.intellij.sdk.community/idea_rt/jars/idea_rt-latest.jar ->
    // /Users/yic/.ivy2/pants/com.intellij.sdk.community/
    Optional.ofNullable(PluginManagerCore.getPlugin(PluginId.getId("com.intellij")))
      .map(s -> s.getPath().getParentFile().getParentFile().getParentFile().getAbsolutePath())
      .ifPresent(pathsAllowed::add);

    // At this point we know junit plugin is already enabled.
    // //Users/yic/.ivy2/pants/com.intellij.junit-plugin/junit-rt/jars/junit-rt-latest.jar ->
    // /Users/yic/.ivy2/pants/com.intellij.junit-plugin/
    Optional.ofNullable(PluginManagerCore.getPlugin(PluginId.getId("JUnit")))
      .map(s -> s.getPath().getParentFile().getParentFile().getParentFile().getAbsolutePath())
      .ifPresent(pathsAllowed::add);
  }
  return pathsAllowed;
}
 
Example 2
Source File: LoginFrame.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
private boolean classLoader() {
    synchronized (this) {
        String path = PathManager.getPluginsPath() + File.separator + "leetcode-editor" + File.separator + "natives" + File.separator;
        if (!new File(path, "icudtl.dat").exists()
                && !new File(path, "jcef_app.app").exists()) {
            return Boolean.FALSE;
        } else {
            JourneyLoader.getJourneyClassLoader(path);
            return Boolean.TRUE;
        }
    }
}
 
Example 3
Source File: PropertySetter.java    From tmc-intellij with MIT License 5 votes vote down vote up
public void setLog4jProperties() {
    File file =
            new File(
                    PathManager.getPluginsPath()
                            + "/tmc-plugin-intellij/lib/tmc-plugin-intellij.jar");

    if (file.exists()) {
        setPluginLog();
    } else {
        setDevLog();
    }
}
 
Example 4
Source File: PropertySetter.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void setPluginLog() {
    String jarPath =
            PathManager.getPluginsPath() + "/tmc-plugin-intellij/lib/tmc-plugin-intellij.jar";
    try {
        JarFile jar = new JarFile(jarPath);
        JarEntry entry = jar.getJarEntry("log4j.properties");
        InputStream is = jar.getInputStream(entry);
        PropertyConfigurator.configure(is);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: ServerExecutableState.java    From CppTools with Apache License 2.0 5 votes vote down vote up
private String getBasePath() {
  if (myBasePath == null) {
    String s = PathManager.getPluginsPath() + File.separatorChar + CPP_TOOLS;

    if (!new File(s).exists()) {
      s = PathManager.getPreinstalledPluginsPath() + File.separatorChar + CPP_TOOLS;

      if (!new File(s).exists()) {
        throw new RuntimeException("Plugin home is not found");
      }
    }
    myBasePath = s;
  }
  return myBasePath;
}