use of org.jetbrains.plugins.gradle.model.data.CompositeBuildData in project intellij-community by JetBrains.
the class CompositeBuildDataService method importData.
public void importData(@NotNull final Collection<DataNode<CompositeBuildData>> toImport, @Nullable ProjectData projectData, @NotNull final Project project, @NotNull IdeModifiableModelsProvider modelsProvider) {
if (toImport.isEmpty()) {
if (projectData != null) {
GradleProjectSettings projectSettings = GradleSettings.getInstance(project).getLinkedProjectSettings(projectData.getLinkedExternalProjectPath());
if (projectSettings != null && projectSettings.getCompositeBuild() != null && projectSettings.getCompositeBuild().getCompositeDefinitionSource() == CompositeDefinitionSource.SCRIPT) {
projectSettings.setCompositeBuild(null);
}
}
return;
}
if (toImport.size() != 1) {
throw new IllegalArgumentException(String.format("Expected to get a single composite data node but got %d: %s", toImport.size(), toImport));
}
CompositeBuildData compositeBuildData = toImport.iterator().next().getData();
GradleProjectSettings projectSettings = GradleSettings.getInstance(project).getLinkedProjectSettings(compositeBuildData.getRootProjectPath());
if (projectSettings != null) {
GradleProjectSettings.CompositeBuild compositeBuild = new GradleProjectSettings.CompositeBuild();
compositeBuild.setCompositeDefinitionSource(CompositeDefinitionSource.SCRIPT);
for (BuildParticipant buildParticipant : compositeBuildData.getCompositeParticipants()) {
compositeBuild.getCompositeParticipants().add(buildParticipant.copy());
}
projectSettings.setCompositeBuild(compositeBuild);
}
}
use of org.jetbrains.plugins.gradle.model.data.CompositeBuildData in project intellij-community by JetBrains.
the class GradleProjectResolver method exposeCompositeBuild.
@NotNull
private static Collection<IdeaModule> exposeCompositeBuild(ProjectImportAction.AllModels allModels, DefaultProjectResolverContext resolverCtx, DataNode<ProjectData> projectDataNode) {
if (resolverCtx.getSettings() != null && !resolverCtx.getSettings().getExecutionWorkspace().getBuildParticipants().isEmpty()) {
return Collections.emptyList();
}
CompositeBuildData compositeBuildData;
List<IdeaModule> gradleIncludedModules = new SmartList<>();
List<IdeaProject> includedBuilds = allModels.getIncludedBuilds();
if (!includedBuilds.isEmpty()) {
ProjectData projectData = projectDataNode.getData();
compositeBuildData = new CompositeBuildData(projectData.getLinkedExternalProjectPath());
for (IdeaProject project : includedBuilds) {
if (!project.getModules().isEmpty()) {
String rootProjectName = project.getName();
BuildParticipant buildParticipant = new BuildParticipant();
gradleIncludedModules.addAll(project.getModules());
GradleProject gradleProject = project.getModules().getAt(0).getGradleProject();
String projectPath = null;
do {
try {
projectPath = ExternalSystemApiUtil.toCanonicalPath(gradleProject.getProjectDirectory().getCanonicalPath());
} catch (IOException e) {
LOG.warn("construction of the canonical path for the module fails", e);
}
} while ((gradleProject = gradleProject.getParent()) != null);
if (projectPath != null) {
buildParticipant.setRootProjectName(rootProjectName);
buildParticipant.setRootPath(projectPath);
for (IdeaModule module : project.getModules()) {
try {
String modulePath = ExternalSystemApiUtil.toCanonicalPath(module.getGradleProject().getProjectDirectory().getCanonicalPath());
buildParticipant.getProjects().add(modulePath);
} catch (IOException e) {
LOG.warn("construction of the canonical path for the module fails", e);
}
}
compositeBuildData.getCompositeParticipants().add(buildParticipant);
}
}
}
projectDataNode.createChild(CompositeBuildData.KEY, compositeBuildData);
}
return gradleIncludedModules;
}
Aggregations