Search in sources :

Example 1 with ExtIdeaContentRoot

use of org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot in project intellij-community by JetBrains.

the class ModuleExtendedModelBuilderImplTest method fillDirectories.

private void fillDirectories(final ModuleExtendedModel model, List<String> sourceDirectories, List<String> resourceDirectories, List<String> testDirectories, List<String> resourceTestDirectories, List<String> excludeDirectories) {
    for (ExtIdeaContentRoot contentRoot : model.getContentRoots()) {
        sourceDirectories.addAll(getAllPaths(contentRoot.getSourceDirectories(), model.getName()));
        resourceDirectories.addAll(getAllPaths(contentRoot.getResourceDirectories(), model.getName()));
        testDirectories.addAll(getAllPaths(contentRoot.getTestDirectories(), model.getName()));
        resourceTestDirectories.addAll(getAllPaths(contentRoot.getTestResourceDirectories(), model.getName()));
        excludeDirectories.addAll(getAllPaths(contentRoot.getExcludeDirectories(), model.getName()));
    }
}
Also used : ExtIdeaContentRoot(org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot)

Example 2 with ExtIdeaContentRoot

use of org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot in project android by JetBrains.

the class JavaModuleContentRoot method copy.

@NotNull
public static JavaModuleContentRoot copy(@NotNull IdeaContentRoot original) {
    File rootDirPath = original.getRootDirectory();
    Collection<File> sourceDirPaths = copy(original.getSourceDirectories());
    Collection<File> genSourceDirPaths = copy(original.getGeneratedSourceDirectories());
    Collection<File> testDirPaths = copy(original.getTestDirectories());
    Collection<File> genTestDirPaths = copy(original.getGeneratedTestDirectories());
    Collection<File> resourceDirPaths = Collections.emptySet();
    Collection<File> testResourceDirPaths = Collections.emptySet();
    if (original instanceof ExtIdeaContentRoot) {
        ExtIdeaContentRoot extContentRoot = (ExtIdeaContentRoot) original;
        resourceDirPaths = copy(extContentRoot.getResourceDirectories());
        testResourceDirPaths = copy(extContentRoot.getTestResourceDirectories());
    }
    Collection<File> excludeDirPaths = Collections.emptySet();
    Set<File> exclude = original.getExcludeDirectories();
    if (exclude != null) {
        excludeDirPaths = Sets.newHashSet();
        for (File path : exclude) {
            if (path != null) {
                excludeDirPaths.add(path);
            }
        }
    }
    return new JavaModuleContentRoot(rootDirPath, sourceDirPaths, genSourceDirPaths, resourceDirPaths, testDirPaths, genTestDirPaths, testResourceDirPaths, excludeDirPaths);
}
Also used : ExtIdeaContentRoot(org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ExtIdeaContentRoot

use of org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot 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);
}
Also used : ExtIdeaContentRoot(org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot) File(java.io.File) IdeaSourceDirectory(org.gradle.tooling.model.idea.IdeaSourceDirectory) Test(org.junit.Test)

Aggregations

ExtIdeaContentRoot (org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot)3 File (java.io.File)2 IdeaSourceDirectory (org.gradle.tooling.model.idea.IdeaSourceDirectory)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.junit.Test)1