IDEA-169388 Resources not copied to output folder if Gradle project name is 'test'

This commit is contained in:
Vladislav.Soroka
2017-04-20 18:59:32 +03:00
parent 38b09b1c61
commit 71b911eba3
2 changed files with 29 additions and 3 deletions
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.model.DefaultExternalProject;
import org.jetbrains.plugins.gradle.model.ExternalProject;
import org.jetbrains.plugins.gradle.model.ExternalSourceSet;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import java.io.File;
import java.util.Collections;
@@ -101,13 +102,15 @@ public class ExternalProjectDataCache {
@NotNull
public Map<String, ExternalSourceSet> findExternalProject(@NotNull ExternalProject parentProject, @NotNull Module module) {
String externalProjectId = ExternalSystemApiUtil.getExternalProjectId(module);
return externalProjectId != null ? findExternalProject(parentProject, externalProjectId)
boolean isSourceSet = GradleConstants.GRADLE_SOURCE_SET_MODULE_TYPE_KEY.equals(ExternalSystemApiUtil.getExternalModuleType(module));
return externalProjectId != null ? findExternalProject(parentProject, externalProjectId, isSourceSet)
: Collections.emptyMap();
}
@NotNull
private static Map<String, ExternalSourceSet> findExternalProject(@NotNull ExternalProject parentProject,
@NotNull String externalProjectId) {
@NotNull String externalProjectId,
boolean isSourceSet) {
Queue<ExternalProject> queue = ContainerUtil.newLinkedList();
queue.add(parentProject);
@@ -119,7 +122,7 @@ public class ExternalProjectDataCache {
for (Map.Entry<String, ExternalSourceSet> sourceSetEntry : externalProject.getSourceSets().entrySet()) {
final String sourceSetName = sourceSetEntry.getKey();
final String sourceSetId = projectId + ":" + sourceSetName;
if (isRelatedProject || externalProjectId.equals(sourceSetId)) {
if (isRelatedProject || (isSourceSet && externalProjectId.equals(sourceSetId))) {
result.put(sourceSetName, sourceSetEntry.getValue());
}
}
@@ -302,6 +302,29 @@ public class GradleResourceProcessingTest extends GradleCompilingTestCase {
assertCopiedResources();
}
@Test
public void testModuleWithNameTestResourceCopying() throws Exception {
createProjectSubFile("bar/foo/src/main/resources/dir/file.properties");
createProjectSubFile("bar/foo/src/test/resources/dir/file-test.properties");
createProjectSubFile("bar/test/src/main/resources/dir/file.properties");
createProjectSubFile("bar/test/src/test/resources/dir/file-test.properties");
createSettingsFile("include ':bar:foo'\n" +
"include ':bar:test'");
importProjectUsingSingeModulePerGradleProject(
"subprojects {\n" +
" apply plugin: 'java'\n" +
"}\n"
);
assertModules("project", "bar", "foo", "test");
compileModules("project", "bar", "foo", "test");
assertCopied("bar/foo/build/resources/main/dir/file.properties");
assertCopied("bar/foo/build/resources/test/dir/file-test.properties");
assertCopied("bar/test/build/resources/main/dir/file.properties");
assertCopied("bar/test/build/resources/test/dir/file-test.properties");
}
private void createFilesForIncludesAndExcludesTest() throws IOException {
createProjectSubFile("src/main/resources/dir/file.xxx");
createProjectSubFile("src/main/resources/dir/file.yyy");