String (Maven40ServerEmbedderImpl embedder, @NotNull final File file, @NotNull List<String> activeProfiles, @NotNull List<String> inactiveProfiles) { final StringWriter w = new StringWriter(); try { final MavenExecutionRequest request = embedder.createRequest(file, activeProfiles, inactiveProfiles); embedder.executeWithMavenSession(request, () -> { try { // copied from DefaultMavenProjectBuilder.buildWithDependencies ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class); ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest()); MavenProject project = buildingResult.getProject(); XMLWriter writer = new PrettyPrintXMLWriter(new PrintWriter(w), StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE), "\n", null, null); writeHeader(writer); writeEffectivePom(project, writer); } catch (Exception e) { throw new RuntimeException(e); } }); } catch (Exception e) { return null; } return w.toString(); }