use of org.gradle.api.Project 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.api.Project in project gradle by gradle.
the class ProjectConverter method addSubProjects.
/**
* Adds all sub projects of the specified GradleProject.
*
* @param parentProject the source parent project. Where we get the sub projects from.
* @param parentProjectView the destination of the sub projects from parentProject.
*/
private void addSubProjects(Project parentProject, ProjectView parentProjectView) {
Collection<Project> subProjects = parentProject.getChildProjects().values();
for (Project subProject : subProjects) {
ProjectView projectView = new ProjectView(parentProjectView, subProject.getName(), subProject.getBuildFile(), subProject.getDescription());
addTasks(subProject, projectView);
projectView.sortSubProjectsAndTasks();
addSubProjects(subProject, projectView);
}
}
use of org.gradle.api.Project in project gradle by gradle.
the class IdeaPlugin method setupScopes.
private void setupScopes(GenerateIdeaModule ideaModule) {
Map<String, Map<String, Collection<Configuration>>> scopes = Maps.newLinkedHashMap();
for (GeneratedIdeaScope scope : GeneratedIdeaScope.values()) {
Map<String, Collection<Configuration>> plusMinus = Maps.newLinkedHashMap();
plusMinus.put(IdeaDependenciesProvider.SCOPE_PLUS, Lists.<Configuration>newArrayList());
plusMinus.put(IdeaDependenciesProvider.SCOPE_MINUS, Lists.<Configuration>newArrayList());
scopes.put(scope.name(), plusMinus);
}
Project project = ideaModule.getProject();
ConfigurationContainer configurations = project.getConfigurations();
Collection<Configuration> provided = scopes.get(GeneratedIdeaScope.PROVIDED.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
provided.add(configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME));
Collection<Configuration> runtime = scopes.get(GeneratedIdeaScope.RUNTIME.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
runtime.add(configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
Collection<Configuration> test = scopes.get(GeneratedIdeaScope.TEST.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
test.add(configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME));
test.add(configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME));
ideaModule.getModule().setScopes(scopes);
}
use of org.gradle.api.Project in project gradle by gradle.
the class IdeaPlugin method registerImlArtifacts.
private void registerImlArtifacts() {
Set<Project> projectsWithIml = Sets.filter(project.getRootProject().getAllprojects(), new Predicate<Project>() {
@Override
public boolean apply(Project project) {
return project.getPlugins().hasPlugin(IdeaPlugin.class);
}
});
for (Project project : projectsWithIml) {
ProjectLocalComponentProvider projectComponentProvider = ((ProjectInternal) project).getServices().get(ProjectLocalComponentProvider.class);
ProjectComponentIdentifier projectId = newProjectId(project);
projectComponentProvider.registerAdditionalArtifact(projectId, createImlArtifact(projectId, project));
}
}
use of org.gradle.api.Project in project gradle by gradle.
the class FilterTest method setUp.
protected void setUp() throws Exception {
JUnit4Mockery context = new JUnit4Mockery();
Task subsubCompileTask = TestUtility.createTask(context, "compile", "compile description");
Task subsubLibTask = TestUtility.createTask(context, "lib", "lib description");
Task subsubDocTask = TestUtility.createTask(context, "doc", "doc description");
Project subsubProject = TestUtility.createMockProject(context, "mysubsubproject", "filepath3", 2, null, new Task[] { subsubCompileTask, subsubLibTask, subsubDocTask }, null);
Task subCompileTask1 = TestUtility.createTask(context, "compile", "compile description");
Task subLibTask1 = TestUtility.createTask(context, "lib", "lib description");
Task subDocTask1 = TestUtility.createTask(context, "doc", "doc description");
Project subProject1 = TestUtility.createMockProject(context, "mysubproject1", "filepath2a", 1, new Project[] { subsubProject }, new Task[] { subCompileTask1, subLibTask1, subDocTask1 }, null);
Task subCompileTask2 = TestUtility.createTask(context, "compile", "compile description");
Task subLibTask2 = TestUtility.createTask(context, "lib", "lib description");
Task subDocTask2 = TestUtility.createTask(context, "doc", "doc description");
Project subProject2 = TestUtility.createMockProject(context, "mysubproject2", "filepath2b", 1, null, new Task[] { subCompileTask2, subLibTask2, subDocTask2 }, null);
Project rootProject = TestUtility.createMockProject(context, "myrootproject", "filepath1", 0, new Project[] { subProject1, subProject2 }, null, null);
buildInformation = new BuildInformation(rootProject);
//now get the converted objects to simplify our matching
myRootProject = buildInformation.getProjectFromFullPath("myrootproject");
assertNotNull(myRootProject);
mySubProject1 = buildInformation.getProjectFromFullPath("myrootproject:mysubproject1");
assertNotNull(mySubProject1);
mySubProject1Comple = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:compile");
assertNotNull(mySubProject1Comple);
mySubProject1Lib = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:lib");
assertNotNull(mySubProject1Lib);
mySubProject1Doc = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:doc");
assertNotNull(mySubProject1Doc);
mySubSubProject = buildInformation.getProjectFromFullPath("myrootproject:mysubproject1:mysubsubproject");
assertNotNull(mySubSubProject);
mySubSubProjectCompile = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:mysubsubproject:compile");
assertNotNull(mySubSubProjectCompile);
mySubSubProjectLib = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:mysubsubproject:lib");
assertNotNull(mySubSubProjectLib);
mySubSubProjectDoc = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:mysubsubproject:doc");
assertNotNull(mySubSubProjectDoc);
mySubProject2 = buildInformation.getProjectFromFullPath("myrootproject:mysubproject2");
assertNotNull(mySubProject2);
mySubProject2Compile = buildInformation.getTaskFromFullPath("myrootproject:mysubproject2:compile");
assertNotNull(mySubProject2Compile);
mySubProject2Lib = buildInformation.getTaskFromFullPath("myrootproject:mysubproject2:lib");
assertNotNull(mySubProject2Lib);
mySubProject2doc = buildInformation.getTaskFromFullPath("myrootproject:mysubproject2:doc");
assertNotNull(mySubProject2doc);
}
Aggregations