diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java index bfabaf09808d..bc082889fae7 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java @@ -480,7 +480,7 @@ public class DependencyResolverImpl implements DependencyResolver { Configuration deprecatedCompileConfiguration = compileDependenciesProvider.getDeprecatedCompileConfiguration(); Configuration compileConfiguration = compileDependenciesProvider.getCompileConfiguration(); - boolean checkCompileOnlyDeps = compileDependenciesProvider.getCompileClasspathConfiguration() != null && !compileConfiguration.getResolvedConfiguration().hasError(); + boolean checkCompileOnlyDeps = compileDependenciesProvider.getCompileClasspathConfiguration() != null; // since version 3.4 compileOnly no longer extends compile // so, we can use compileOnly configuration for the check if (isJavaLibraryPluginSupported) { diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResultsTransformer.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResultsTransformer.java index 09aa6132d901..414b2186d133 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResultsTransformer.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResultsTransformer.java @@ -26,16 +26,18 @@ import java.io.File; import java.lang.reflect.Method; import java.util.*; +import static org.jetbrains.plugins.gradle.tooling.util.resolve.DependencyResolverImpl.*; + public class DependencyResultsTransformer { private final Project myProject; private final SourceSetCachedFinder mySourceSetFinder; - private final Multimap myArtifactMap; - private final Map myAuxiliaryArtifactsMap; - private final Multimap myConfigurationProjectDependencies; - private final String myScope; + private final Multimap artifactMap; + private final Map componentResultsMap; + private final Multimap configurationProjectDependencies; + private final String scope; private final Set resolvedDepsFiles = new HashSet(); - private final Map> myResolvedDepsCache = - new HashMap>(); + + private final List handledDependencyResults = new ArrayList(); public DependencyResultsTransformer(@NotNull final Project project, @NotNull final SourceSetCachedFinder sourceSetFinder, @@ -46,10 +48,10 @@ public class DependencyResultsTransformer { myProject = project; mySourceSetFinder = sourceSetFinder; - myArtifactMap = artifactMap; - myAuxiliaryArtifactsMap = auxiliaryArtifactsMap; - myConfigurationProjectDependencies = configurationProjectDependencies; - myScope = scope; + this.artifactMap = artifactMap; + componentResultsMap = auxiliaryArtifactsMap; + this.configurationProjectDependencies = configurationProjectDependencies; + this.scope = scope; } public Set getResolvedDepsFiles() { @@ -57,292 +59,252 @@ public class DependencyResultsTransformer { } Set buildExternalDependencies(Collection gradleDependencies) { - Set handledDependencyResults = new HashSet(); - Set result = new LinkedHashSet(); - for (DependencyResult gradleDep : gradleDependencies) { + Set dependencies = new LinkedHashSet(); + for (DependencyResult dependencyResult : gradleDependencies) { + // dependency cycles check - if (handledDependencyResults.add(gradleDep)) { - if (gradleDep instanceof ResolvedDependencyResult) { - result.addAll(buildExternalDependencies((ResolvedDependencyResult)gradleDep)); - } + if (!handledDependencyResults.contains(dependencyResult)) { + handledDependencyResults.add(dependencyResult); - if (gradleDep instanceof UnresolvedDependencyResult) { - result.addAll(buildExternalDependencies((UnresolvedDependencyResult)gradleDep)); - } - } - } + if (dependencyResult instanceof ResolvedDependencyResult) { + ResolvedComponentResult componentResult = ((ResolvedDependencyResult)dependencyResult).getSelected(); + ComponentSelector componentSelector = dependencyResult.getRequested(); + ModuleComponentIdentifier componentIdentifier = toComponentIdentifier(componentResult.getModuleVersion()); - return result; - } + String name = componentResult.getModuleVersion().getName(); + String group = componentResult.getModuleVersion().getGroup(); + String version = componentResult.getModuleVersion().getVersion(); + String selectionReason = componentResult.getSelectionReason().getDescription(); - private Set buildExternalDependencies(UnresolvedDependencyResult unresolvedGradleDep) { - ComponentSelector attempted = unresolvedGradleDep.getAttempted(); - if (attempted instanceof ModuleComponentSelector) { - final ModuleComponentSelector attemptedMCSelector = (ModuleComponentSelector)attempted; - return Collections.singleton(createUnresolvedExternalDep(attemptedMCSelector, - unresolvedGradleDep.getFailure().getMessage())); - } - return Collections.emptySet(); - } + boolean resolveFromArtifacts = componentSelector instanceof ModuleComponentSelector; + + if (componentSelector instanceof ProjectComponentSelector) { + Collection projectDependencies = configurationProjectDependencies.get(componentIdentifier); + Collection dependencyConfigurations; + if (projectDependencies.isEmpty()) { + Project dependencyProject = myProject.findProject(((ProjectComponentSelector)componentSelector).getProjectPath()); + if (dependencyProject != null) { + Configuration dependencyProjectConfiguration = + dependencyProject.getConfigurations().getByName(Dependency.DEFAULT_CONFIGURATION); + dependencyConfigurations = Collections.singleton(dependencyProjectConfiguration); + } else { + dependencyConfigurations = Collections.emptySet(); + resolveFromArtifacts = true; + selectionReason = "composite build substitution"; + } + } else { + dependencyConfigurations = new ArrayList(); + for (ProjectDependency dependency : projectDependencies) { + dependencyConfigurations.add(getTargetConfiguration(dependency)); + } + } + + for (Configuration it : dependencyConfigurations) { + if (it.getName().equals(Dependency.DEFAULT_CONFIGURATION)) { + DefaultExternalProjectDependency dependency = new DefaultExternalProjectDependency(); + dependency.setName( name); + dependency.setGroup(group); + dependency.setVersion(version); + dependency.setScope(scope); + dependency.setSelectionReason(selectionReason); + dependency.setProjectPath(((ProjectComponentSelector)componentSelector).getProjectPath()); + dependency.setConfigurationName(it.getName()); + Set artifacts = it.getAllArtifacts().getFiles().getFiles(); + dependency.setProjectDependencyArtifacts(artifacts); + setProjectDependencyArtifactsSources(dependency, artifacts, mySourceSetFinder); + + resolvedDepsFiles.addAll(dependency.getProjectDependencyArtifacts()); + + if (it.getArtifacts().size() == 1) { + PublishArtifact publishArtifact = it.getAllArtifacts().iterator().next(); + dependency.setClassifier(publishArtifact.getClassifier()); + dependency.setPackaging(publishArtifact.getExtension() != null ? publishArtifact.getExtension() : "jar"); + } + + if (!componentResult.equals(dependencyResult.getFrom())) { + dependency.getDependencies().addAll( + buildExternalDependencies(componentResult.getDependencies()) + ); + } + dependencies.add(dependency); + } + else { + DefaultExternalProjectDependency dependency = new DefaultExternalProjectDependency(); + dependency.setName(name); + dependency.setGroup(group); + dependency.setVersion(version); + dependency.setScope(scope); + dependency.setSelectionReason(selectionReason); + dependency.setProjectPath(((ProjectComponentSelector)componentSelector).getProjectPath()); + dependency.setConfigurationName(it.getName()); + Set artifactsFiles = it.getAllArtifacts().getFiles().getFiles(); + dependency.setProjectDependencyArtifacts(artifactsFiles); + setProjectDependencyArtifactsSources(dependency, artifactsFiles, mySourceSetFinder); + + resolvedDepsFiles.addAll(dependency.getProjectDependencyArtifacts()); + + if (it.getArtifacts().size() == 1) { + PublishArtifact publishArtifact = it.getAllArtifacts().iterator().next(); + dependency.setClassifier(publishArtifact.getClassifier()); + dependency.setPackaging(publishArtifact.getExtension() != null ? publishArtifact.getExtension() : "jar"); + } + + if (!componentResult.equals(dependencyResult.getFrom())) { + + dependency.getDependencies().addAll( + buildExternalDependencies(componentResult.getDependencies()) + ); + } + + dependencies.add(dependency); + + List files = new ArrayList(); + PublishArtifactSet artifacts = it.getArtifacts(); + if (artifacts != null && !artifacts.isEmpty()) { + PublishArtifact artifact = artifacts.iterator().next(); + final MetaProperty taskProperty = DefaultGroovyMethods.hasProperty(artifact, "archiveTask"); + if (taskProperty != null && (taskProperty.getProperty(artifact) instanceof AbstractArchiveTask)) { + + AbstractArchiveTask archiveTask = (AbstractArchiveTask)taskProperty.getProperty(artifact); + resolvedDepsFiles.add(new File(archiveTask.getDestinationDir(), archiveTask.getArchiveName())); - private Set buildExternalDependencies(ResolvedDependencyResult resolvedGradleDep) { - Set result = new LinkedHashSet(); + try { + final Method mainSpecGetter = AbstractCopyTask.class.getDeclaredMethod("getMainSpec"); + mainSpecGetter.setAccessible(true); + Object mainSpec = mainSpecGetter.invoke(archiveTask); - ResolvedComponentResult componentResult = resolvedGradleDep.getSelected(); - ComponentSelector componentSelector = resolvedGradleDep.getRequested(); - ModuleVersionIdentifier moduleVersionId = componentResult.getModuleVersion(); - ModuleComponentIdentifier componentIdentifier = DependencyResolverImpl.toComponentIdentifier(moduleVersionId); - String selectionReason = componentResult.getSelectionReason().getDescription(); + final List sourcePathGetters = + DefaultGroovyMethods.respondsTo(mainSpec, "getSourcePaths", new Object[]{}); + if (!sourcePathGetters.isEmpty()) { + Set sourcePaths = (Set)sourcePathGetters.get(0).doMethodInvoke(mainSpec, new Object[]{}); + if (sourcePaths != null) { + for (Object path : sourcePaths) { + if (path instanceof String) { + File file = new File((String)path); + if (file.isAbsolute()) { + files.add(file); + } + } + else if (path instanceof SourceSetOutput) { + files.addAll(((SourceSetOutput)path).getFiles()); + } + } + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } - boolean resolveFromArtifacts = false; - - Set cached = myResolvedDepsCache.get(moduleVersionId); - if (cached != null) { - return cached; - } - - if (componentSelector instanceof ProjectComponentSelector) { - final ProjectComponentSelector selector = (ProjectComponentSelector)componentSelector; - - final Collection dependencyConfigurations = - getProjectDepsConfigurations(selector.getProjectPath(), - myConfigurationProjectDependencies.get(componentIdentifier)); - - if (dependencyConfigurations.isEmpty()) { - resolveFromArtifacts = true; - selectionReason = "composite build substitution"; - } - - for (Configuration it : dependencyConfigurations) { - DefaultExternalProjectDependency dependency = createExternalProjectDep(moduleVersionId, - selectionReason, - selector.getProjectPath(), - it.getName()); - processProjectDependencyConfiguration(resolvedGradleDep, result, componentResult, it, dependency); - } - } - - if (componentSelector instanceof ModuleComponentSelector || resolveFromArtifacts) { - Collection artifacts = myArtifactMap.get(moduleVersionId); - - final Set transitiveDeps = buildExternalDependencies(componentResult.getDependencies()); - if (artifacts != null && artifacts.isEmpty()) { - result.addAll(transitiveDeps); - } - - boolean first = true; - - if (artifacts != null) { - for (ResolvedArtifact artifact: artifacts) { - final ExternalDependency dependency = transformResolvedArtifact(moduleVersionId, componentIdentifier, selectionReason, artifact); - - if (first) { - dependency.getDependencies().addAll(transitiveDeps); - first = false; - } - result.add(dependency); - resolvedDepsFiles.add(artifact.getFile()); - } - } - } - - myResolvedDepsCache.put(moduleVersionId, result); - - return result; - } - - @NotNull - private Collection getProjectDepsConfigurations(@NotNull final String projectPath, - @NotNull final Collection projectDependencies) { - Collection dependencyConfigurations; - if (projectDependencies.isEmpty()) { - Project dependencyProject = myProject.findProject(projectPath); - if (dependencyProject != null) { - Configuration dependencyProjectConfiguration = - dependencyProject.getConfigurations().getByName(Dependency.DEFAULT_CONFIGURATION); - dependencyConfigurations = Collections.singleton(dependencyProjectConfiguration); - } else { - dependencyConfigurations = Collections.emptySet(); - } - } else { - dependencyConfigurations = new ArrayList(); - for (ProjectDependency dependency : projectDependencies) { - dependencyConfigurations.add(DependencyResolverImpl.getTargetConfiguration(dependency)); - } - } - return dependencyConfigurations; - } - - @NotNull - private ExternalDependency transformResolvedArtifact(@NotNull final ModuleVersionIdentifier moduleVersionId, - @NotNull final ModuleComponentIdentifier componentIdentifier, - @NotNull final String selectionReason, - @NotNull final ResolvedArtifact artifact) { - String packaging = artifact.getExtension() != null ? artifact.getExtension() : "jar"; - String classifier = artifact.getClassifier(); - final ExternalDependency dependency; - - if (DependencyResolverImpl.isProjectDependencyArtifact(artifact)) { - final String projectPath = ((ProjectComponentIdentifier)artifact.getId().getComponentIdentifier()).getProjectPath(); - dependency = createExternalProjectDep(moduleVersionId, - selectionReason, - projectPath, - Dependency.DEFAULT_CONFIGURATION); - - DefaultExternalProjectDependency projectDependency = (DefaultExternalProjectDependency)dependency; - - List files = new ArrayList(); - for (ResolvedArtifact resolvedArtifact : myArtifactMap.get(moduleVersionId)) { - files.add(resolvedArtifact.getFile()); - } - - projectDependency.setProjectDependencyArtifacts(files); - projectDependency.setProjectDependencyArtifactsSources(DependencyResolverImpl.findArtifactSources(files, mySourceSetFinder)); - resolvedDepsFiles.addAll(projectDependency.getProjectDependencyArtifacts()); - } - else { - dependency = createExternalLibraryDep(moduleVersionId, selectionReason); - DefaultExternalLibraryDependency libraryDependency = (DefaultExternalLibraryDependency)dependency; - - libraryDependency.setPackaging(packaging); - libraryDependency.setClassifier(classifier); - libraryDependency.setFile(artifact.getFile()); - - ComponentArtifactsResult artifactsResult = myAuxiliaryArtifactsMap.get(componentIdentifier); - if (artifactsResult != null) { - ResolvedArtifactResult sourcesResult = findMatchingArtifact(artifact, artifactsResult, SourcesArtifact.class); - if (sourcesResult != null) { - libraryDependency.setSource(sourcesResult.getFile()); - } - - ResolvedArtifactResult javadocResult = findMatchingArtifact(artifact, artifactsResult, JavadocArtifact.class); - if (javadocResult != null) { - libraryDependency.setJavadoc(javadocResult.getFile()); - } - } - } - return dependency; - } - - private void processProjectDependencyConfiguration(@NotNull final ResolvedDependencyResult resolvedGradleDep, - @NotNull final Set result, - @NotNull final ResolvedComponentResult resolvedComponent, - @NotNull final Configuration projectDepConfiguration, - @NotNull final DefaultExternalProjectDependency externalDependency) { - Set artifactsFiles = projectDepConfiguration.getAllArtifacts().getFiles().getFiles(); - externalDependency.setProjectDependencyArtifacts(artifactsFiles); - externalDependency.setProjectDependencyArtifactsSources(DependencyResolverImpl.findArtifactSources(artifactsFiles, mySourceSetFinder)); - resolvedDepsFiles.addAll(externalDependency.getProjectDependencyArtifacts()); - - if (projectDepConfiguration.getArtifacts().size() == 1) { - PublishArtifact publishArtifact = projectDepConfiguration.getAllArtifacts().iterator().next(); - externalDependency.setClassifier(publishArtifact.getClassifier()); - externalDependency.setPackaging(publishArtifact.getExtension() != null ? publishArtifact.getExtension() : "jar"); - } - - if (!resolvedComponent.equals(resolvedGradleDep.getFrom())) { - externalDependency.getDependencies().addAll(buildExternalDependencies(resolvedComponent.getDependencies())); - } - result.add(externalDependency); - - if (!projectDepConfiguration.getName().equals(Dependency.DEFAULT_CONFIGURATION)) { - List configurationSources = new ArrayList(); - PublishArtifactSet artifacts = projectDepConfiguration.getArtifacts(); - - if (artifacts != null && !artifacts.isEmpty()) { - configurationSources.addAll(collectSourcesOfPublishedArtifacts(artifacts)); - } - - if (!configurationSources.isEmpty()) { - final DefaultFileCollectionDependency fileCollectionDependency = new DefaultFileCollectionDependency(configurationSources); - fileCollectionDependency.setScope(myScope); - result.add(fileCollectionDependency); - resolvedDepsFiles.addAll(configurationSources); - } - } - } - - @NotNull - private List collectSourcesOfPublishedArtifacts(@NotNull final PublishArtifactSet artifacts) { - final List files = new ArrayList(); - - PublishArtifact artifact = artifacts.iterator().next(); - final MetaProperty taskProperty = DefaultGroovyMethods.hasProperty(artifact, "archiveTask"); - if (taskProperty != null && (taskProperty.getProperty(artifact) instanceof AbstractArchiveTask)) { - - AbstractArchiveTask archiveTask = (AbstractArchiveTask)taskProperty.getProperty(artifact); - resolvedDepsFiles.add(new File(archiveTask.getDestinationDir(), archiveTask.getArchiveName())); - - try { - final Method mainSpecGetter = AbstractCopyTask.class.getDeclaredMethod("getMainSpec"); - mainSpecGetter.setAccessible(true); - Object mainSpec = mainSpecGetter.invoke(archiveTask); - - final List sourcePathGetters = - DefaultGroovyMethods.respondsTo(mainSpec, "getSourcePaths", new Object[]{}); - if (!sourcePathGetters.isEmpty()) { - Set sourcePaths = (Set)sourcePathGetters.get(0).doMethodInvoke(mainSpec, new Object[]{}); - if (sourcePaths != null) { - for (Object path : sourcePaths) { - if (path instanceof String) { - File file = new File((String)path); - if (file.isAbsolute()) { - files.add(file); + if (!files.isEmpty()) { + final DefaultFileCollectionDependency fileCollectionDependency = new DefaultFileCollectionDependency(files); + fileCollectionDependency.setScope(scope); + dependencies.add(fileCollectionDependency); + resolvedDepsFiles.addAll(files); } } - else if (path instanceof SourceSetOutput) { - files.addAll(((SourceSetOutput)path).getFiles()); + } + } + + if (resolveFromArtifacts) { + Collection artifacts = artifactMap.get(componentResult.getModuleVersion()); + + if (artifacts != null && artifacts.isEmpty()) { + dependencies.addAll( + buildExternalDependencies(componentResult.getDependencies()) + ); + } + + boolean first = true; + + if (artifacts != null) { + for (ResolvedArtifact artifact: artifacts) { + String packaging = artifact.getExtension() != null ? artifact.getExtension() : "jar"; + String classifier = artifact.getClassifier(); + final ExternalDependency dependency; + if (isProjectDependencyArtifact(artifact)) { + ProjectComponentIdentifier artifactComponentIdentifier = + (ProjectComponentIdentifier)artifact.getId().getComponentIdentifier(); + + dependency = new DefaultExternalProjectDependency(); + DefaultExternalProjectDependency dDep = (DefaultExternalProjectDependency)dependency; + dDep.setName(name); + dDep.setGroup(group); + dDep.setVersion(version); + dDep.setScope(scope); + dDep.setSelectionReason(selectionReason); + dDep.setProjectPath(artifactComponentIdentifier.getProjectPath()); + dDep.setConfigurationName(Dependency.DEFAULT_CONFIGURATION); + + List files = new ArrayList(); + for (ResolvedArtifact resolvedArtifact : artifactMap.get(componentResult.getModuleVersion())) { + files.add(resolvedArtifact.getFile()); + } + dDep.setProjectDependencyArtifacts(files); + setProjectDependencyArtifactsSources(dDep, files, mySourceSetFinder); + resolvedDepsFiles.addAll(dDep.getProjectDependencyArtifacts()); + } + else { + dependency = new DefaultExternalLibraryDependency(); + DefaultExternalLibraryDependency dDep = (DefaultExternalLibraryDependency)dependency; + dDep.setName(name); + dDep.setGroup(group); + dDep.setPackaging(packaging); + dDep.setClassifier(classifier); + dDep.setVersion(version); + dDep.setScope(scope); + dDep.setSelectionReason(selectionReason); + dDep.setFile(artifact.getFile()); + + ComponentArtifactsResult artifactsResult = componentResultsMap.get(componentIdentifier); + if (artifactsResult != null) { + ResolvedArtifactResult sourcesResult = findMatchingArtifact(artifact, artifactsResult, SourcesArtifact.class); + if (sourcesResult != null) { + ((DefaultExternalLibraryDependency)dependency).setSource(sourcesResult.getFile()); + } + + ResolvedArtifactResult javadocResult = findMatchingArtifact(artifact, artifactsResult, JavadocArtifact.class); + if (javadocResult != null) { + ((DefaultExternalLibraryDependency)dependency).setJavadoc(javadocResult.getFile()); + } + } + } + + if (first) { + dependency.getDependencies().addAll( + buildExternalDependencies(componentResult.getDependencies()) + ); + first = false; + } + + dependencies.add(dependency); + resolvedDepsFiles.add(artifact.getFile()); } } } } - } catch (Exception e) { - throw new RuntimeException(e); + + if (dependencyResult instanceof UnresolvedDependencyResult) { + ComponentSelector attempted = ((UnresolvedDependencyResult)dependencyResult).getAttempted(); + if (attempted instanceof ModuleComponentSelector) { + final ModuleComponentSelector attemptedMCSelector = (ModuleComponentSelector)attempted; + final DefaultUnresolvedExternalDependency dependency = new DefaultUnresolvedExternalDependency(); + dependency.setName(attemptedMCSelector.getModule()); + dependency.setGroup(attemptedMCSelector.getGroup()); + dependency.setVersion(attemptedMCSelector.getVersion()); + dependency.setScope(scope); + dependency.setFailureMessage(((UnresolvedDependencyResult)dependencyResult).getFailure().getMessage()); + + dependencies.add(dependency); + } + } } } - return files; - } - - private ExternalLibraryDependency createExternalLibraryDep(@NotNull final ModuleVersionIdentifier moduleVersionId, - @NotNull final String selectionReason) { - DefaultExternalLibraryDependency dDep = new DefaultExternalLibraryDependency(); - dDep.setName(moduleVersionId.getName()); - dDep.setGroup(moduleVersionId.getGroup()); - dDep.setVersion(moduleVersionId.getVersion()); - dDep.setSelectionReason(selectionReason); - dDep.setScope(myScope); - return dDep; - } - - @NotNull - private DefaultExternalProjectDependency createExternalProjectDep(@NotNull final ModuleVersionIdentifier moduleVersionId, - @NotNull final String selectionReason, - @NotNull final String projectPath, - @NotNull final String configurationName) { - DefaultExternalProjectDependency dependency = new DefaultExternalProjectDependency(); - dependency.setName(moduleVersionId.getName()); - dependency.setGroup(moduleVersionId.getGroup()); - dependency.setVersion(moduleVersionId.getVersion()); - dependency.setScope(myScope); - dependency.setSelectionReason(selectionReason); - dependency.setProjectPath(projectPath); - dependency.setConfigurationName(configurationName); - return dependency; - } - - @NotNull - private DefaultUnresolvedExternalDependency createUnresolvedExternalDep(@NotNull final ModuleComponentSelector attemptedMCSelector, - @NotNull final String message) { - final DefaultUnresolvedExternalDependency dependency = new DefaultUnresolvedExternalDependency(); - dependency.setName(attemptedMCSelector.getModule()); - dependency.setGroup(attemptedMCSelector.getGroup()); - dependency.setVersion(attemptedMCSelector.getVersion()); - dependency.setScope(myScope); - dependency.setFailureMessage(message); - return dependency; + return dependencies; } @Nullable @@ -364,4 +326,17 @@ public class DependencyResultsTransformer { } return null; } + + private static void setProjectDependencyArtifactsSources(DefaultExternalProjectDependency projectDependency, + Collection artifactFiles, + SourceSetCachedFinder sourceSetFinder) { + List artifactSources = new ArrayList(); + for (File artifactFile : artifactFiles) { + Set sources = sourceSetFinder.findSourcesByArtifact(artifactFile.getPath()); + if (sources != null) { + artifactSources.addAll(sources); + } + } + projectDependency.setProjectDependencyArtifactsSources(artifactSources); + } }