use of org.gradle.tooling.model.gradle.GradleBuild in project gradle by gradle.
the class UseGradleBuildToFetchProjectModel method execute.
public Map<String, CustomModel> execute(BuildController controller) {
GradleBuild gradleBuild = controller.getBuildModel();
Map<String, CustomModel> projects = new HashMap<String, CustomModel>();
for (BasicGradleProject project : gradleBuild.getProjects()) {
projects.put(project.getName(), controller.getModel(project, CustomModel.class));
}
return projects;
}
use of org.gradle.tooling.model.gradle.GradleBuild in project gradle by gradle.
the class FetchEclipseProjects method execute.
@Override
public List<EclipseProject> execute(BuildController controller) {
List<EclipseProject> eclipseProjects = new ArrayList<EclipseProject>();
GradleBuild build = controller.getBuildModel();
collectEclipseProjects(build, eclipseProjects, controller);
return eclipseProjects;
}
use of org.gradle.tooling.model.gradle.GradleBuild in project android by JetBrains.
the class ModuleFactory method getModulePath.
@NotNull
private String getModulePath(@NotNull IdeaModule ideaModule, @NotNull SyncAction.ModuleModels moduleModels) {
GradleProject gradleProject = ideaModule.getGradleProject();
GradleBuild gradleBuild = moduleModels.findModel(GradleBuild.class);
if (gradleBuild != null) {
File moduleDirPath = getModuleDirPath(gradleBuild, gradleProject.getPath());
if (moduleDirPath == null) {
throw new IllegalStateException(String.format("Unable to find root directory for module '%1$s'", ideaModule.getName()));
}
return toCanonicalPath(moduleDirPath.getPath());
}
String projectPath = myProject.getBasePath();
// We should not be dealing with 'default' project.
assert projectPath != null;
return toSystemDependentName(getConfigPath(gradleProject, projectPath));
}
use of org.gradle.tooling.model.gradle.GradleBuild in project intellij-community by JetBrains.
the class BaseGradleProjectResolverExtension method populateModuleTasks.
@NotNull
@Override
public Collection<TaskData> populateModuleTasks(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule, @NotNull DataNode<ProjectData> ideProject) throws IllegalArgumentException, IllegalStateException {
final Collection<TaskData> tasks = ContainerUtil.newArrayList();
final String moduleConfigPath = ideModule.getData().getLinkedExternalProjectPath();
ExternalProject externalProject = resolverCtx.getExtraProject(gradleModule, ExternalProject.class);
String rootProjectPath = ideProject.getData().getLinkedExternalProjectPath();
try {
GradleBuild build = resolverCtx.getExtraProject(gradleModule, GradleBuild.class);
if (build != null) {
rootProjectPath = ExternalSystemApiUtil.toCanonicalPath(build.getRootProject().getProjectDirectory().getCanonicalPath());
}
} catch (IOException e) {
LOG.warn("construction of the canonical path for the module fails", e);
}
final boolean isFlatProject = !FileUtil.isAncestor(rootProjectPath, moduleConfigPath, false);
if (externalProject != null) {
for (ExternalTask task : externalProject.getTasks().values()) {
String taskName = isFlatProject ? task.getQName() : task.getName();
String taskGroup = task.getGroup();
if (taskName.trim().isEmpty() || isIdeaTask(taskName, taskGroup)) {
continue;
}
final String taskPath = isFlatProject ? rootProjectPath : moduleConfigPath;
TaskData taskData = new TaskData(GradleConstants.SYSTEM_ID, taskName, taskPath, task.getDescription());
taskData.setGroup(taskGroup);
taskData.setType(task.getType());
ideModule.createChild(ProjectKeys.TASK, taskData);
taskData.setInherited(StringUtil.equals(task.getName(), task.getQName()));
tasks.add(taskData);
}
return tasks;
}
for (GradleTask task : gradleModule.getGradleProject().getTasks()) {
String taskName = task.getName();
String taskGroup = getTaskGroup(task);
if (taskName == null || taskName.trim().isEmpty() || isIdeaTask(taskName, taskGroup)) {
continue;
}
TaskData taskData = new TaskData(GradleConstants.SYSTEM_ID, taskName, moduleConfigPath, task.getDescription());
taskData.setGroup(taskGroup);
ideModule.createChild(ProjectKeys.TASK, taskData);
tasks.add(taskData);
}
return tasks;
}
use of org.gradle.tooling.model.gradle.GradleBuild in project intellij-community by JetBrains.
the class GradleProjectResolverUtil method getModuleConfigPath.
@NotNull
public static String getModuleConfigPath(@NotNull ProjectResolverContext resolverCtx, @NotNull IdeaModule gradleModule, @NotNull String rootProjectPath) {
GradleBuild build = resolverCtx.getExtraProject(gradleModule, GradleBuild.class);
if (build != null) {
String gradlePath = gradleModule.getGradleProject().getPath();
File moduleDirPath = getModuleDirPath(build, gradlePath);
if (moduleDirPath == null) {
throw new IllegalStateException(String.format("Unable to find root directory for module '%s'", gradleModule.getName()));
}
try {
return ExternalSystemApiUtil.toCanonicalPath(moduleDirPath.getCanonicalPath());
} catch (IOException e) {
LOG.warn("construction of the canonical path for the module fails", e);
}
}
return GradleUtil.getConfigPath(gradleModule.getGradleProject(), rootProjectPath);
}
Aggregations