use of org.gradle.tooling.model.idea.IdeaContentRoot 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.IdeaContentRoot 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