mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-158769 Gradle dependency on test output overrides dependency
This commit is contained in:
+5
-6
@@ -438,13 +438,12 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
}
|
||||
else {
|
||||
final Set<String> testSet = ContainerUtil.newHashSet();
|
||||
Map<ExternalSystemSourceType, String> gradleTestOutputs = pair.first.getUserData(GRADLE_OUTPUTS);
|
||||
if(gradleTestOutputs != null) {
|
||||
ContainerUtil.addAllNotNull(compileSet,
|
||||
gradleTestOutputs.get(ExternalSystemSourceType.TEST),
|
||||
gradleTestOutputs.get(ExternalSystemSourceType.TEST_RESOURCE));
|
||||
if(gradleOutputs != null) {
|
||||
ContainerUtil.addAllNotNull(testSet,
|
||||
gradleOutputs.get(ExternalSystemSourceType.TEST),
|
||||
gradleOutputs.get(ExternalSystemSourceType.TEST_RESOURCE));
|
||||
}
|
||||
if (compileSet.isEmpty() && ContainerUtil.intersects(libraryPaths, testSet)) {
|
||||
if (!testSet.isEmpty() && ContainerUtil.intersects(libraryPaths, testSet)) {
|
||||
targetModuleOutputPaths = testSet;
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -849,4 +849,50 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase {
|
||||
}
|
||||
assertModuleModuleDepScope("projectC", "projectB", DependencyScope.PROVIDED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectConfigurationDependencyWithDependencyOnTestOutput() throws Exception {
|
||||
createSettingsFile("include 'project1'\n" +
|
||||
"include 'project2'\n");
|
||||
|
||||
importProject(
|
||||
"project(':project1') {\n" +
|
||||
" apply plugin: 'java'\n" +
|
||||
" configurations {\n" +
|
||||
" testOutput\n" +
|
||||
" testOutput.extendsFrom (testCompile)\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" dependencies {\n" +
|
||||
" testOutput sourceSets.test.output\n" +
|
||||
" testCompile group: 'junit', name: 'junit', version: '4.11'\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"project(':project2') {\n" +
|
||||
" apply plugin: 'java'\n" +
|
||||
" dependencies {\n" +
|
||||
" compile project(path: ':project1')\n" +
|
||||
"\n" +
|
||||
" testCompile group: 'junit', name: 'junit', version: '4.11'\n" +
|
||||
" testCompile project(path: ':project1', configuration: 'testOutput')\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
"}\n"
|
||||
);
|
||||
|
||||
assertModules("project", "project1", "project1_main", "project1_test", "project2", "project2_main", "project2_test");
|
||||
|
||||
assertModuleModuleDepScope("project1_test", "project1_main", DependencyScope.COMPILE);
|
||||
assertModuleLibDepScope("project1_test", "Gradle: junit:junit:4.11", DependencyScope.COMPILE);
|
||||
assertModuleLibDepScope("project1_test", "Gradle: org.hamcrest:hamcrest-core:1.3", DependencyScope.COMPILE);
|
||||
|
||||
assertModuleModuleDepScope("project2_main", "project1_main", DependencyScope.COMPILE);
|
||||
|
||||
assertModuleModuleDepScope("project2_test", "project2_main", DependencyScope.COMPILE);
|
||||
assertModuleModuleDepScope("project2_test", "project1_test", DependencyScope.COMPILE);
|
||||
assertModuleModuleDepScope("project2_test", "project1_main", DependencyScope.COMPILE);
|
||||
assertModuleLibDepScope("project2_test", "Gradle: junit:junit:4.11", DependencyScope.COMPILE);
|
||||
assertModuleLibDepScope("project2_test", "Gradle: org.hamcrest:hamcrest-core:1.3", DependencyScope.COMPILE);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -63,6 +63,10 @@ public class DefaultExternalProjectDependency extends AbstractExternalDependency
|
||||
|
||||
public void setConfigurationName(String configurationName) {
|
||||
myConfigurationName = configurationName;
|
||||
// have to differentiate(using different DefaultExternalDependencyId) project dependencies on different configurations
|
||||
if(!Dependency.DEFAULT_CONFIGURATION.equals(configurationName)){
|
||||
setClassifier(configurationName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-1
@@ -155,10 +155,19 @@ class DependencyResolverImpl implements DependencyResolver {
|
||||
|
||||
ResolutionResult resolutionResult = configuration.incoming.resolutionResult
|
||||
if(!configuration.resolvedConfiguration.hasError()) {
|
||||
def fileDeps = new LinkedHashSet<File>(configuration.incoming.files.files);
|
||||
Collection<File> fileDeps = new LinkedHashSet<File>(configuration.incoming.files.files);
|
||||
artifactMap.values().each {
|
||||
fileDeps.remove(it.file)
|
||||
}
|
||||
configurationProjectDependencies.values().each {
|
||||
def intersect = fileDeps.intersect(it.resolve())
|
||||
if(!intersect.isEmpty()) {
|
||||
def fileCollectionDependency = new DefaultFileCollectionDependency(intersect)
|
||||
fileCollectionDependency.scope = scope
|
||||
result.add(fileCollectionDependency)
|
||||
fileDeps.removeAll(intersect)
|
||||
}
|
||||
}
|
||||
fileDeps.each {
|
||||
def fileCollectionDependency = new DefaultFileCollectionDependency([it])
|
||||
fileCollectionDependency.scope = scope
|
||||
|
||||
Reference in New Issue
Block a user