diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/data/ExternalProjectDataCache.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/data/ExternalProjectDataCache.java index 576ae24ecee5..562e0bb9b31a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/data/ExternalProjectDataCache.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/data/ExternalProjectDataCache.java @@ -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 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 findExternalProject(@NotNull ExternalProject parentProject, - @NotNull String externalProjectId) { + @NotNull String externalProjectId, + boolean isSourceSet) { Queue queue = ContainerUtil.newLinkedList(); queue.add(parentProject); @@ -119,7 +122,7 @@ public class ExternalProjectDataCache { for (Map.Entry 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()); } } diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/compiler/GradleResourceProcessingTest.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/compiler/GradleResourceProcessingTest.java index 34ad6589e86f..0cd1b08cdb79 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/compiler/GradleResourceProcessingTest.java +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/compiler/GradleResourceProcessingTest.java @@ -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");