import org.gradle.api.Project; //导入方法依赖的package包/类
/**
* Gets IDE project dependencies.
*
* @param configuration Configuration
* @param project Project
* @return IDE project dependencies
*/
public List getIdeProjectDependencies(Configuration configuration, Project project) {
ResolutionResult result = getIncomingResolutionResult(configuration);
final Set projectComponents = CollectionUtils.filter(result.getAllComponents(), new Spec() {
@Override
public boolean isSatisfiedBy(ResolvedComponentResult element) {
return element.getId() instanceof ProjectComponentIdentifier;
}
});
List ideProjectDependencies = new ArrayList();
ProjectComponentIdentifier thisProjectId = DefaultProjectComponentIdentifier.newProjectId(project);
for (ResolvedComponentResult projectComponent : projectComponents) {
ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) projectComponent.getId();
if (thisProjectId.equals(projectId)) {
continue;
}
if (!projectId.getBuild().isCurrentBuild()) {
// Don't have access to the ProjectInstance: we can't use it to determine the name.
ideProjectDependencies.add(new IdeProjectDependency(projectId));
} else {
Project resolvedProject = project.project(projectId.getProjectPath());
ideProjectDependencies.add(new IdeProjectDependency(projectId, resolvedProject.getName()));
}
}
return ideProjectDependencies;
}