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

The following examples show how to use com.intellij.openapi.application.PathManager#getHomePath() . 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: PantsTestUtils.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static File findTestPath(String folderName) {
  final File f = new File(folderName);
  if (f.exists()) {
    return f.getAbsoluteFile();
  }
  return new File(PathManager.getHomePath() + "/plugins/pants/" + folderName);
}
 
Example 3
Source File: HaxeTestUtils.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private static String findTestDataPath() {
  File f = new File("testData");
  if (f.exists()) {
    return f.getAbsolutePath();
  }
  return PathManager.getHomePath() + "/plugins/haxe/testData";
}
 
Example 4
Source File: ThriftTestUtils.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
private static String findTestDataPath() {
  File f = new File("src/test/resources");
  if (f.exists()) {
    return f.getAbsolutePath();
  }
  return PathManager.getHomePath() + "/plugins/thrift/testData";
}
 
Example 5
Source File: BaseFunctionalTestCase.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
protected String getTestDataPath() {
    return PathManager.getHomePath();
}