com.intellij.util.PathsList Java Examples

The following examples show how to use com.intellij.util.PathsList. 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: IntellijWithPluginClasspathHelper.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void addIntellijLibraries(JavaParameters params, Sdk ideaJdk) {
  String libPath = ideaJdk.getHomePath() + File.separator + "lib";
  PathsList list = params.getClassPath();
  for (String lib : IJ_LIBRARIES) {
    list.addFirst(libPath + File.separator + lib);
  }
  list.addFirst(((JavaSdkType) ideaJdk.getSdkType()).getToolsPath(ideaJdk));
}
 
Example #2
Source File: PantsClasspathRunConfigurationExtension.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * The goal of this function is to find classpath for IntelliJ JUnit/Scala runner.
 * <p/>
 * This function will fail if the projects' Pants doesn't support `--export-classpath-manifest-jar-only`.
 * It also assumes that Pants has created a manifest jar that contains all the classpath links for the
 * particular test that's being run.
 */
@Override
public <T extends RunConfigurationBase> void updateJavaParameters(
  T configuration,
  @NotNull JavaParameters params,
  RunnerSettings runnerSettings
) throws ExecutionException {
  List<BeforeRunTask<?>> tasks = ((RunManagerImpl) RunManager.getInstance(configuration.getProject())).getBeforeRunTasks(configuration);
  boolean builtByPants = tasks.stream().anyMatch(s -> s.getProviderId().equals(PantsMakeBeforeRun.ID));
  // Not built by Pants means it was built by IntelliJ, in which case we don't need to change the classpath.
  if (!builtByPants) {
    return;
  }

  final Module module = findPantsModule(configuration);
  if (module == null) {
    return;
  }

  Set<String> pathsAllowed = calculatePathsAllowed(params);

  final PathsList classpath = params.getClassPath();
  List<String> classpathToKeep = classpath.getPathList().stream()
    .filter(cp -> pathsAllowed.stream().anyMatch(cp::contains)).collect(Collectors.toList());
  classpath.clear();
  classpath.addAll(classpathToKeep);

  VirtualFile manifestJar = PantsUtil.findProjectManifestJar(configuration.getProject())
    .orElseThrow(() -> new ExecutionException("manifest.jar is not found. It should be generated by `./pants export-classpath ...`"));
  classpath.add(manifestJar.getPath());

  PantsExternalMetricsListenerManager.getInstance().logTestRunner(configuration);
}
 
Example #3
Source File: OrderRootsEnumeratorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public PathsList getPathsList() {
  final PathsList list = new PathsList();
  collectPaths(list);
  return list;
}
 
Example #4
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Configures given classpath to reference target i18n bundle file(s).
 *
 * @param classPath    process classpath
 * @param bundlePath   path to the target bundle file
 * @param contextClass class from the same content root as the target bundle file
 */
public static void addBundle(@Nonnull PathsList classPath, @Nonnull String bundlePath, @Nonnull Class<?> contextClass) {
  String pathToUse = bundlePath.replace('.', '/');
  if (!pathToUse.endsWith(".properties")) {
    pathToUse += ".properties";
  }
  if (!pathToUse.startsWith("/")) {
    pathToUse = '/' + pathToUse;
  }
  String root = PathManager.getResourceRoot(contextClass, pathToUse);
  if (root != null) {
    classPath.add(root);
  }
}
 
Example #5
Source File: OrderRootsEnumeratorImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void collectPaths(@Nonnull PathsList list) {
  list.addVirtualFiles(getRoots());
}
 
Example #6
Source File: ModuleChunk.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String convertToStringPath(final OrderedSet<VirtualFile> cpFiles) {
  PathsList classpath = new PathsList();
  classpath.addVirtualFiles(cpFiles);
  return classpath.getPathsString();
}
 
Example #7
Source File: OrderEnumerator.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @return list containing classes roots for all entries processed by this enumerator
 */
public PathsList getPathsList() {
  return classes().getPathsList();
}
 
Example #8
Source File: OrderEnumerator.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @return list containing source roots for all entries processed by this enumerator
 */
public PathsList getSourcePathsList() {
  return sources().getPathsList();
}
 
Example #9
Source File: SimpleJavaParameters.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PathsList getClassPath() {
  return myClassPath;
}
 
Example #10
Source File: OrderRootsEnumerator.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * @return list of path to all roots processed by this enumerator
 */
@Nonnull
PathsList getPathsList();
 
Example #11
Source File: OrderRootsEnumerator.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Add all source roots processed by this enumerator to <code>list</code>
 * @param list list
 */
void collectPaths(@Nonnull PathsList list);