use of org.gradle.plugins.ide.idea.IdeaPlugin 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;
}
use of org.gradle.plugins.ide.idea.IdeaPlugin in project intellij-community by JetBrains.
the class ModuleExtendedModelBuilderImpl method enrichDataFromIdeaPlugin.
private static void enrichDataFromIdeaPlugin(Project project, Set<File> excludeDirectories, Set<String> javaDirectories, Set<String> testDirectories, Set<String> ideaGeneratedDirectories) {
IdeaPlugin ideaPlugin = project.getPlugins().findPlugin(IdeaPlugin.class);
if (ideaPlugin == null)
return;
IdeaModel ideaModel = ideaPlugin.getModel();
if (ideaModel == null || ideaModel.getModule() == null)
return;
for (File excludeDir : ideaModel.getModule().getExcludeDirs()) {
excludeDirectories.add(excludeDir);
}
for (File file : ideaModel.getModule().getSourceDirs()) {
javaDirectories.add(file.getPath());
}
for (File file : ideaModel.getModule().getTestSourceDirs()) {
testDirectories.add(file.getPath());
}
if (GradleVersion.current().compareTo(GradleVersion.version("2.2")) >= 0) {
for (File file : ideaModel.getModule().getGeneratedSourceDirs()) {
ideaGeneratedDirectories.add(file.getPath());
}
}
}
Aggregations