Search in sources :

Example 1 with ModelInterpolator

use of org.apache.maven.model.interpolation.ModelInterpolator in project intellij-community by JetBrains.

the class Maven3ServerEmbedder method getProjectBuildingResults.

@NotNull
protected List<ProjectBuildingResult> getProjectBuildingResults(@NotNull MavenExecutionRequest request, @NotNull Collection<File> files) {
    final ProjectBuilder builder = getComponent(ProjectBuilder.class);
    CustomMaven3ModelInterpolator2 modelInterpolator = (CustomMaven3ModelInterpolator2) getComponent(ModelInterpolator.class);
    String savedLocalRepository = modelInterpolator.getLocalRepository();
    modelInterpolator.setLocalRepository(request.getLocalRepositoryPath().getAbsolutePath());
    List<ProjectBuildingResult> buildingResults = new SmartList<ProjectBuildingResult>();
    final ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
    projectBuildingRequest.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
    projectBuildingRequest.setResolveDependencies(false);
    try {
        if (files.size() == 1) {
            buildSinglePom(builder, buildingResults, projectBuildingRequest, files.iterator().next());
        } else {
            try {
                buildingResults = builder.build(new ArrayList<File>(files), false, projectBuildingRequest);
            } catch (ProjectBuildingException e) {
                for (ProjectBuildingResult result : e.getResults()) {
                    if (result.getProject() != null) {
                        buildingResults.add(result);
                    } else {
                        buildSinglePom(builder, buildingResults, projectBuildingRequest, result.getPomFile());
                    }
                }
            }
        }
    } finally {
        modelInterpolator.setLocalRepository(savedLocalRepository);
    }
    return buildingResults;
}
Also used : ModelInterpolator(org.apache.maven.model.interpolation.ModelInterpolator) CustomMaven3ModelInterpolator2(org.jetbrains.idea.maven.server.embedder.CustomMaven3ModelInterpolator2) ArrayList(java.util.ArrayList) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SmartList (com.intellij.util.SmartList)1 ArrayList (java.util.ArrayList)1 ModelInterpolator (org.apache.maven.model.interpolation.ModelInterpolator)1 NotNull (org.jetbrains.annotations.NotNull)1 CustomMaven3ModelInterpolator2 (org.jetbrains.idea.maven.server.embedder.CustomMaven3ModelInterpolator2)1