use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class GradleManager method configureExecutionWorkspace.
/**
* Add composite participants
*/
private static void configureExecutionWorkspace(@Nullable GradleProjectSettings compositeRootSettings, GradleSettings settings, GradleExecutionSettings result, Project project, String projectPath) {
if (compositeRootSettings == null || compositeRootSettings.getCompositeBuild() == null)
return;
GradleProjectSettings.CompositeBuild compositeBuild = compositeRootSettings.getCompositeBuild();
if (compositeBuild.getCompositeDefinitionSource() == CompositeDefinitionSource.SCRIPT) {
if (pathsEqual(compositeRootSettings.getExternalProjectPath(), projectPath))
return;
for (BuildParticipant buildParticipant : compositeBuild.getCompositeParticipants()) {
if (pathsEqual(buildParticipant.getRootPath(), projectPath))
continue;
if (buildParticipant.getProjects().stream().anyMatch(path -> pathsEqual(path, projectPath))) {
continue;
}
result.getExecutionWorkspace().addBuildParticipant(new GradleBuildParticipant(buildParticipant.getRootPath()));
}
return;
}
for (GradleProjectSettings projectSettings : settings.getLinkedProjectsSettings()) {
if (projectSettings == compositeRootSettings)
continue;
if (compositeBuild.getCompositeParticipants().stream().noneMatch(participant -> pathsEqual(participant.getRootPath(), projectSettings.getExternalProjectPath()))) {
continue;
}
GradleBuildParticipant buildParticipant = new GradleBuildParticipant(projectSettings.getExternalProjectPath());
ExternalProjectInfo projectData = ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, projectSettings.getExternalProjectPath());
if (projectData == null || projectData.getExternalProjectStructure() == null)
continue;
Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(projectData.getExternalProjectStructure(), ProjectKeys.MODULE);
for (DataNode<ModuleData> moduleNode : moduleNodes) {
ModuleData moduleData = moduleNode.getData();
if (moduleData.getArtifacts().isEmpty()) {
Collection<DataNode<GradleSourceSetData>> sourceSetNodes = ExternalSystemApiUtil.findAll(moduleNode, GradleSourceSetData.KEY);
for (DataNode<GradleSourceSetData> sourceSetNode : sourceSetNodes) {
buildParticipant.addModule(sourceSetNode.getData());
}
} else {
buildParticipant.addModule(moduleData);
}
}
result.getExecutionWorkspace().addBuildParticipant(buildParticipant);
}
}
use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class GradleParentProjectForm method collapseIfPossible.
private static void collapseIfPossible(@NotNull EditorTextField editorTextField, @NotNull ProjectSystemId systemId, @NotNull Project project) {
Editor editor = editorTextField.getEditor();
if (editor != null) {
String rawText = editor.getDocument().getText();
if (StringUtil.isEmpty(rawText))
return;
if (EMPTY_PARENT.equals(rawText)) {
editorTextField.setEnabled(false);
return;
}
final Collection<ExternalProjectInfo> projectsData = ProjectDataManager.getInstance().getExternalProjectsData(project, systemId);
for (ExternalProjectInfo projectInfo : projectsData) {
if (projectInfo.getExternalProjectStructure() != null && projectInfo.getExternalProjectPath().equals(rawText)) {
editorTextField.setEnabled(true);
ExternalProjectPathField.collapse(editorTextField.getEditor(), projectInfo.getExternalProjectStructure().getData().getExternalName());
return;
}
}
}
}
use of com.intellij.openapi.externalSystem.model.ExternalProjectInfo in project intellij-community by JetBrains.
the class GradleTestRunConfigurationProducer method getTasksToRun.
@NotNull
public static List<String> getTasksToRun(@NotNull Module module) {
for (GradleTestTasksProvider provider : GradleTestTasksProvider.EP_NAME.getExtensions()) {
final List<String> tasks = provider.getTasks(module);
if (!ContainerUtil.isEmpty(tasks)) {
return tasks;
}
}
final List<String> result;
final String externalProjectId = ExternalSystemApiUtil.getExternalProjectId(module);
if (externalProjectId == null)
return ContainerUtil.emptyList();
final String projectPath = ExternalSystemApiUtil.getExternalProjectPath(module);
if (projectPath == null)
return ContainerUtil.emptyList();
final ExternalProjectInfo externalProjectInfo = ExternalSystemUtil.getExternalProjectInfo(module.getProject(), GradleConstants.SYSTEM_ID, projectPath);
if (externalProjectInfo == null)
return ContainerUtil.emptyList();
boolean trimSourceSet = false;
if (StringUtil.endsWith(externalProjectId, ":test") || StringUtil.endsWith(externalProjectId, ":main")) {
result = TEST_SOURCE_SET_TASKS;
trimSourceSet = true;
} else {
final DataNode<ModuleData> moduleNode = GradleProjectResolverUtil.findModule(externalProjectInfo.getExternalProjectStructure(), projectPath);
if (moduleNode == null)
return ContainerUtil.emptyList();
final DataNode<TaskData> taskNode;
final String sourceSetId = StringUtil.substringAfter(externalProjectId, moduleNode.getData().getExternalName() + ':');
if (sourceSetId == null) {
taskNode = ExternalSystemApiUtil.find(moduleNode, ProjectKeys.TASK, node -> GradleCommonClassNames.GRADLE_API_TASKS_TESTING_TEST.equals(node.getData().getType()) && StringUtil.equals("test", node.getData().getName()));
} else {
trimSourceSet = true;
taskNode = ExternalSystemApiUtil.find(moduleNode, ProjectKeys.TASK, node -> GradleCommonClassNames.GRADLE_API_TASKS_TESTING_TEST.equals(node.getData().getType()) && StringUtil.startsWith(sourceSetId, node.getData().getName()));
}
if (taskNode == null)
return ContainerUtil.emptyList();
final String taskName = taskNode.getData().getName();
result = ContainerUtil.list("clean" + StringUtil.capitalize(taskName), taskName);
}
final String path;
if (!externalProjectId.startsWith(":")) {
path = ":";
} else {
final List<String> pathParts = StringUtil.split(externalProjectId, ":");
if (trimSourceSet && !pathParts.isEmpty())
pathParts.remove(pathParts.size() - 1);
final String join = StringUtil.join(pathParts, ":");
path = ":" + join + (!join.isEmpty() ? ":" : "");
}
return ContainerUtil.map(result, s -> path + s);
}
Aggregations