Object (@NotNull final String modelName, @NotNull final Project project, @NotNull ModelBuilderContext context) { BuildScriptClasspathModelImpl buildScriptClasspath = cache.get(project.getPath()); if (buildScriptClasspath != null) return buildScriptClasspath; buildScriptClasspath = new BuildScriptClasspathModelImpl(); final File gradleHomeDir = project.getGradle().getGradleHomeDir(); buildScriptClasspath.setGradleHomeDir(gradleHomeDir); buildScriptClasspath.setGradleVersion(GradleVersion.current().getVersion()); final boolean downloadJavadoc = GradleDependencyArtifactPolicyUtil.shouldDownloadJavadoc(project); final boolean downloadSources = GradleDependencyArtifactPolicyUtil.shouldDownloadSources(project); GradleDependencyArtifactPolicyUtil.setPolicy(project, downloadSources, downloadJavadoc); Project parent = project.getParent(); if (parent != null) { BuildScriptClasspathModelImpl parentBuildScriptClasspath = (BuildScriptClasspathModelImpl)buildAll(modelName, parent, context); 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(context, project, downloadJavadoc, downloadSources) .resolveDependencies(classpathConfiguration); for (ExternalDependency dependency : new DependencyTraverser(dependencies)) { if (dependency instanceof ExternalProjectDependency) { ExternalProjectDependency projectDependency = (ExternalProjectDependency)dependency; Collection<File> projectDependencyArtifacts = projectDependency.getProjectDependencyArtifacts(); Collection<File> projectDependencyArtifactsSources = projectDependency.getProjectDependencyArtifactsSources(); buildScriptClasspath.add(new ClasspathEntryModelImpl( projectDependencyArtifacts, projectDependencyArtifactsSources, Collections.emptySet() )); } else if (dependency instanceof ExternalLibraryDependency) { final ExternalLibraryDependency libraryDep = (ExternalLibraryDependency)dependency; buildScriptClasspath.add(new ClasspathEntryModelImpl( singletonListOrEmpty(libraryDep.getFile()), singletonListOrEmpty(libraryDep.getSource()), singletonListOrEmpty(libraryDep.getJavadoc()) )); } else if (dependency instanceof ExternalMultiLibraryDependency) { ExternalMultiLibraryDependency multiLibraryDependency = (ExternalMultiLibraryDependency)dependency; buildScriptClasspath.add(new ClasspathEntryModelImpl( multiLibraryDependency.getFiles(), multiLibraryDependency.getSources(), multiLibraryDependency.getJavadoc() )); } else if (dependency instanceof FileCollectionDependency) { FileCollectionDependency fileCollectionDependency = (FileCollectionDependency)dependency; buildScriptClasspath.add(new ClasspathEntryModelImpl( fileCollectionDependency.getFiles(), Collections.emptySet(), Collections.emptySet() )); } } cache.put(project.getPath(), buildScriptClasspath); return buildScriptClasspath; }