use of org.gradle.tooling.model.idea.IdeaSourceDirectory in project android by JetBrains.
the class JavaModuleContentRootTest method testCopyWithGradleContentRoot.
@Test
public void testCopyWithGradleContentRoot() {
IdeaContentRoot originalContentRoot = createMock(IdeaContentRoot.class);
File rootDirPath = new File("root");
expect(originalContentRoot.getRootDirectory()).andStubReturn(rootDirPath);
Pair<File, IdeaSourceDirectory> mock = createSourceDirectoryMock("src");
File sourceDirPath = mock.getFirst();
IdeaSourceDirectory sourceDir = mock.getSecond();
originalContentRoot.getSourceDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(sourceDir));
mock = createSourceDirectoryMock("gen-src");
File genSourceDirPath = mock.getFirst();
IdeaSourceDirectory genSourceDir = mock.getSecond();
originalContentRoot.getGeneratedSourceDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(genSourceDir));
mock = createSourceDirectoryMock("test");
File testDirPath = mock.getFirst();
IdeaSourceDirectory testDir = mock.getSecond();
originalContentRoot.getTestDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(testDir));
mock = createSourceDirectoryMock("gen-test");
File genTestDirPath = mock.getFirst();
IdeaSourceDirectory genTestDir = mock.getSecond();
originalContentRoot.getGeneratedTestDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(genTestDir));
File exclude = new File("exclude");
Set<File> allExclude = Sets.newSet(exclude, null);
expect(originalContentRoot.getExcludeDirectories()).andStubReturn(allExclude);
replay(originalContentRoot, sourceDir, genSourceDir, testDir, genTestDir);
JavaModuleContentRoot contentRoot = JavaModuleContentRoot.copy(originalContentRoot);
assertNotNull(contentRoot);
assertSame(contentRoot.getRootDirPath(), rootDirPath);
assertThat(contentRoot.getSourceDirPaths()).containsExactly(sourceDirPath);
assertThat(contentRoot.getGenSourceDirPaths()).containsExactly(genSourceDirPath);
assertThat(contentRoot.getTestDirPaths()).containsExactly(testDirPath);
assertThat(contentRoot.getGenTestDirPaths()).containsExactly(genTestDirPath);
assertThat(contentRoot.getResourceDirPaths()).isEmpty();
assertThat(contentRoot.getTestResourceDirPaths()).isEmpty();
verify(originalContentRoot, sourceDir, genSourceDir, testDir, genTestDir);
}
use of org.gradle.tooling.model.idea.IdeaSourceDirectory in project android by JetBrains.
the class JavaModuleContentRootTest method createSourceDirectoryMock.
@NotNull
private static Pair<File, IdeaSourceDirectory> createSourceDirectoryMock(@NotNull String fileName) {
File path = new File(fileName);
IdeaSourceDirectory dir = createMock(IdeaSourceDirectory.class);
expect(dir.getDirectory()).andStubReturn(path);
return Pair.create(path, dir);
}
use of org.gradle.tooling.model.idea.IdeaSourceDirectory in project intellij-community by JetBrains.
the class ModuleExtendedModelBuilderImplTest method getAllPaths.
private Collection<? extends String> getAllPaths(DomainObjectSet<? extends IdeaSourceDirectory> directories, final String moduleName) {
List<String> list = ContainerUtil.map2List(directories, new Function<IdeaSourceDirectory, String>() {
@Override
public String fun(IdeaSourceDirectory sourceDirectory) {
String path = FileUtil.toCanonicalPath(FileUtil.getRelativePath(new File(testDir, moduleName), sourceDirectory.getDirectory()));
Assert.assertNotNull(path);
return path.substring(path.indexOf("/") + 1);
}
});
Collections.sort(list);
return list;
}
use of org.gradle.tooling.model.idea.IdeaSourceDirectory in project android by JetBrains.
the class JavaModuleContentRootTest method testCopyWithIdeaContentRoot.
@Test
public void testCopyWithIdeaContentRoot() {
ExtIdeaContentRoot originalContentRoot = createMock(ExtIdeaContentRoot.class);
File rootDirPath = new File("root");
expect(originalContentRoot.getRootDirectory()).andStubReturn(rootDirPath);
Pair<File, IdeaSourceDirectory> mock = createSourceDirectoryMock("src");
File sourceDirPath = mock.getFirst();
IdeaSourceDirectory sourceDir = mock.getSecond();
originalContentRoot.getSourceDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(sourceDir));
mock = createSourceDirectoryMock("gen-src");
File genSourceDirPath = mock.getFirst();
IdeaSourceDirectory genSourceDir = mock.getSecond();
originalContentRoot.getGeneratedSourceDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(genSourceDir));
mock = createSourceDirectoryMock("test");
File testDirPath = mock.getFirst();
IdeaSourceDirectory testDir = mock.getSecond();
originalContentRoot.getTestDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(testDir));
mock = createSourceDirectoryMock("gen-test");
File genTestDirPath = mock.getFirst();
IdeaSourceDirectory genTestDir = mock.getSecond();
originalContentRoot.getGeneratedTestDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(genTestDir));
mock = createSourceDirectoryMock("resource");
File resourceDirPath = mock.getFirst();
IdeaSourceDirectory resourceDir = mock.getSecond();
originalContentRoot.getResourceDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(resourceDir));
mock = createSourceDirectoryMock("test-resource");
File testResourceDirPath = mock.getFirst();
IdeaSourceDirectory testResourceDir = mock.getSecond();
originalContentRoot.getTestResourceDirectories();
expectLastCall().andStubReturn(DomainObjectHashSet.newSet(testResourceDir));
File exclude = new File("exclude");
Set<File> allExclude = Sets.newSet(exclude, null);
expect(originalContentRoot.getExcludeDirectories()).andStubReturn(allExclude);
replay(originalContentRoot, sourceDir, genSourceDir, testDir, genTestDir, resourceDir, testResourceDir);
JavaModuleContentRoot contentRoot = JavaModuleContentRoot.copy(originalContentRoot);
assertNotNull(contentRoot);
assertSame(contentRoot.getRootDirPath(), rootDirPath);
assertThat(contentRoot.getSourceDirPaths()).containsExactly(sourceDirPath);
assertThat(contentRoot.getGenSourceDirPaths()).containsExactly(genSourceDirPath);
assertThat(contentRoot.getTestDirPaths()).containsExactly(testDirPath);
assertThat(contentRoot.getGenTestDirPaths()).containsExactly(genTestDirPath);
assertThat(contentRoot.getResourceDirPaths()).containsExactly(resourceDirPath);
assertThat(contentRoot.getTestResourceDirPaths()).containsExactly(testResourceDirPath);
verify(originalContentRoot, sourceDir, genSourceDir, testDir, genTestDir, resourceDir, testResourceDir);
}
use of org.gradle.tooling.model.idea.IdeaSourceDirectory in project meghanada-server by mopemope.
the class GradleProject method searchProjectSources.
private Map<String, Set<File>> searchProjectSources(final IdeaModule ideaModule) throws IOException {
final Map<String, Set<File>> result = new HashMap<>(8);
result.put("sources", new HashSet<>(2));
result.put("resources", new HashSet<>(2));
result.put("testSources", new HashSet<>(2));
result.put("testResources", new HashSet<>(2));
for (final IdeaContentRoot ideaContentRoot : ideaModule.getContentRoots().getAll()) {
for (final IdeaSourceDirectory sourceDirectory : ideaContentRoot.getSourceDirectories().getAll()) {
final File file = normalizeFile(sourceDirectory.getDirectory());
final String path = file.getCanonicalPath();
if (path.contains("resources")) {
result.get("resources").add(file);
} else {
result.get("sources").add(file);
}
}
for (final IdeaSourceDirectory sourceDirectory : ideaContentRoot.getTestDirectories().getAll()) {
final File file = normalizeFile(sourceDirectory.getDirectory());
final String path = file.getCanonicalPath();
if (path.contains("resources")) {
result.get("testResources").add(file);
} else {
result.get("testSources").add(file);
}
}
}
return result;
}
Aggregations