use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class PathListBuilderTest method testAddFirstTwice.
@Test
public void testAddFirstTwice() {
PathsList builder = new PathsList();
builder.addFirst("b" + File.pathSeparatorChar + "b");
builder.addFirst("a");
assertThat(builder.getPathList()).containsExactly("a", "b");
}
use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class PathListBuilderTest method testDuplications.
@Test
public void testDuplications() {
PathsList builder = new PathsList();
builder.add("b");
builder.add("b");
builder.addFirst("a");
builder.addFirst("a");
builder.addTail("c");
builder.addTail("c");
assertThat(builder.getPathList()).containsExactly("a", "b", "c");
}
use of com.intellij.util.PathsList in project android by JetBrains.
the class AndroidJunitPatcher method patchJavaParameters.
@Override
public void patchJavaParameters(@Nullable Module module, @NotNull JavaParameters javaParameters) {
// Only patch if the project is a Gradle project.
if (module == null || !isBuildWithGradle(module.getProject())) {
return;
}
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel == null) {
return;
}
// Modify the class path only if we're dealing with the unit test artifact.
JavaArtifact testArtifact = androidModel.getUnitTestArtifactInSelectedVariant();
if (testArtifact == null) {
return;
}
PathsList classPath = javaParameters.getClassPath();
TestArtifactSearchScopes testScopes = TestArtifactSearchScopes.get(module);
if (testScopes == null) {
return;
}
// Filter the library / module dependencies that are in android test
FileRootSearchScope excludeScope = testScopes.getUnitTestExcludeScope();
// complexity. TODO change the {@code PathList} API.
for (String path : classPath.getPathList()) {
if (excludeScope.accept(new File(path))) {
classPath.remove(path);
}
}
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform == null) {
return;
}
String originalClassPath = classPath.getPathsString();
try {
handlePlatformJar(classPath, platform, testArtifact);
handleJavaResources(module, androidModel, classPath);
} catch (RuntimeException e) {
throw new RuntimeException(String.format("Error patching the JUnit class path. Original class path:%n%s", originalClassPath), e);
}
}
use of com.intellij.util.PathsList in project android by JetBrains.
the class AndroidJunitPatcher method patchJavaParameters.
@Override
public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) {
if (module == null) {
return;
}
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel == null) {
return;
}
// Modify the class path only if we're dealing with the unit test artifact.
PathsList classPath = javaParameters.getClassPath();
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk == null || !(sdk.getSdkType() instanceof AndroidSdkType)) {
return;
}
SdkAdditionalData data = sdk.getSdkAdditionalData();
if (!(data instanceof AndroidSdkAdditionalData)) {
return;
}
AndroidPlatform platform = ((AndroidSdkAdditionalData) data).getAndroidPlatform();
if (platform == null) {
return;
}
classPath.remove(platform.getTarget().getPath(IAndroidTarget.ANDROID_JAR));
// Move the mockable android jar to the end.
String mockableJarPath = null;
for (String path : classPath.getPathList()) {
if (new File(FileUtil.toSystemDependentName(path)).getName().startsWith("mockable-android")) {
// PathsList stores strings - use the one that's actually stored there.
mockableJarPath = path;
break;
}
}
if (mockableJarPath != null) {
classPath.remove(mockableJarPath);
classPath.addTail(mockableJarPath);
}
}
use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class GradleManager method enhanceRemoteProcessing.
@Override
public void enhanceRemoteProcessing(@NotNull SimpleJavaParameters parameters) throws ExecutionException {
final Set<String> additionalEntries = ContainerUtilRt.newHashSet();
for (GradleProjectResolverExtension extension : RESOLVER_EXTENSIONS.getValue()) {
ContainerUtilRt.addIfNotNull(additionalEntries, PathUtil.getJarPathForClass(extension.getClass()));
for (Class aClass : extension.getExtraProjectModelClasses()) {
ContainerUtilRt.addIfNotNull(additionalEntries, PathUtil.getJarPathForClass(aClass));
}
extension.enhanceRemoteProcessing(parameters);
}
final PathsList classPath = parameters.getClassPath();
for (String entry : additionalEntries) {
classPath.add(entry);
}
parameters.getVMParametersList().addProperty(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, GradleConstants.SYSTEM_ID.getId());
}
Aggregations