use of org.jetbrains.plugins.gradle.tooling.internal.BuildScriptClasspathModelImpl in project intellij-community by JetBrains.
the class ModelBuildScriptClasspathBuilderImpl method buildAll.
@Nullable
@Override
public Object buildAll(final String modelName, final Project project) {
BuildScriptClasspathModelImpl buildScriptClasspath = cache.get(project.getPath());
if (buildScriptClasspath != null)
return buildScriptClasspath;
if (mySourceSetFinder == null)
mySourceSetFinder = new SourceSetCachedFinder(project);
buildScriptClasspath = new BuildScriptClasspathModelImpl();
final File gradleHomeDir = project.getGradle().getGradleHomeDir();
buildScriptClasspath.setGradleHomeDir(gradleHomeDir);
buildScriptClasspath.setGradleVersion(GradleVersion.current().getVersion());
boolean downloadJavadoc = false;
boolean downloadSources = true;
final IdeaPlugin ideaPlugin = project.getPlugins().findPlugin(IdeaPlugin.class);
if (ideaPlugin != null) {
final IdeaModule ideaModule = ideaPlugin.getModel().getModule();
downloadJavadoc = ideaModule.isDownloadJavadoc();
downloadSources = ideaModule.isDownloadSources();
}
Project parent = project.getParent();
if (parent != null) {
BuildScriptClasspathModelImpl parentBuildScriptClasspath = (BuildScriptClasspathModelImpl) buildAll(modelName, parent);
if (parentBuildScriptClasspath != null) {
for (ClasspathEntryModel classpathEntryModel : parentBuildScriptClasspath.getClasspath()) {
buildScriptClasspath.add(classpathEntryModel);
}
}
}
Configuration classpathConfiguration = project.getBuildscript().getConfigurations().findByName(CLASSPATH_CONFIGURATION_NAME);
if (classpathConfiguration == null)
return null;
Collection<ExternalDependency> dependencies = new DependencyResolverImpl(project, false, downloadJavadoc, downloadSources, mySourceSetFinder).resolveDependencies(classpathConfiguration);
for (ExternalDependency dependency : new DependencyTraverser(dependencies)) {
if (dependency instanceof ExternalLibraryDependency) {
final ExternalLibraryDependency libraryDep = (ExternalLibraryDependency) dependency;
buildScriptClasspath.add(new ClasspathEntryModelImpl(pathSet(libraryDep.getFile()), pathSet(libraryDep.getSource()), pathSet(libraryDep.getJavadoc())));
}
if (dependency instanceof ExternalMultiLibraryDependency) {
ExternalMultiLibraryDependency multiLibraryDependency = (ExternalMultiLibraryDependency) dependency;
buildScriptClasspath.add(new ClasspathEntryModelImpl(pathSet(multiLibraryDependency.getFiles()), pathSet(multiLibraryDependency.getSources()), pathSet(multiLibraryDependency.getJavadoc())));
}
if (dependency instanceof FileCollectionDependency) {
FileCollectionDependency fileCollectionDependency = (FileCollectionDependency) dependency;
buildScriptClasspath.add(new ClasspathEntryModelImpl(pathSet(fileCollectionDependency.getFiles()), new HashSet<String>(), new HashSet<String>()));
}
}
cache.put(project.getPath(), buildScriptClasspath);
return buildScriptClasspath;
}
Aggregations