List of usage examples for org.apache.maven.project.validation ModelValidationResult getMessages
public List<String> getMessages()
From source file:org.eclipse.che.maven.server.MavenServerImpl.java
License:Open Source License
private void validate(File pom, List<Exception> exceptions, List<MavenProjectProblem> problems) throws RemoteException { for (Throwable exception : exceptions) { if (exception instanceof IllegalStateException && exception.getCause() != null) { exception = exception.getCause(); }/* w w w. ja v a 2 s .c om*/ if (exception instanceof InvalidProjectModelException) { ModelValidationResult validationResult = ((InvalidProjectModelException) exception) .getValidationResult(); if (validationResult != null) { problems.addAll(validationResult.getMessages().stream() .map(s -> MavenProjectProblem.newStructureProblem(pom.getPath(), s)) .collect(Collectors.toList())); } else { problems.add(MavenProjectProblem.newStructureProblem(pom.getPath(), exception.getCause().getMessage())); } } if (exception instanceof ProjectBuildingException) { String message = exception.getCause() == null ? exception.getMessage() : exception.getCause().getMessage(); problems.add(MavenProjectProblem.newStructureProblem(pom.getPath(), message)); } else { MavenServerContext.getLogger().info(exception); problems.add(MavenProjectProblem.newStructureProblem(pom.getPath(), exception.getMessage())); } } }
From source file:org.jetbrains.idea.maven.server.embedder.Maven2ServerEmbedderImpl.java
License:Apache License
private void validate(File file, Collection<Exception> exceptions, Collection<MavenProjectProblem> problems, Collection<MavenId> unresolvedArtifacts) throws RemoteException { for (Exception each : exceptions) { Maven2ServerGlobals.getLogger().info(each); if (each instanceof InvalidProjectModelException) { ModelValidationResult modelValidationResult = ((InvalidProjectModelException) each) .getValidationResult(); if (modelValidationResult != null) { for (Object eachValidationProblem : modelValidationResult.getMessages()) { problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), (String) eachValidationProblem)); }/*w ww . ja v a 2s . c om*/ } else { problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), each.getCause().getMessage())); } } else if (each instanceof ProjectBuildingException) { String causeMessage = each.getCause() != null ? each.getCause().getMessage() : each.getMessage(); problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), causeMessage)); } else { problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), each.getMessage())); } } unresolvedArtifacts.addAll(retrieveUnresolvedArtifactIds()); }
From source file:org.jetbrains.idea.maven.server.Maven30ServerEmbedderImpl.java
License:Apache License
private void validate(@Nonnull File file, @Nonnull Collection<Exception> exceptions, @Nonnull Collection<MavenProjectProblem> problems, @javax.annotation.Nullable Collection<MavenId> unresolvedArtifacts) throws RemoteException { for (Throwable each : exceptions) { Maven3ServerGlobals.getLogger().info(each); if (each instanceof IllegalStateException && each.getCause() != null) { each = each.getCause();/*from w w w. j a va2s . co m*/ } if (each instanceof InvalidProjectModelException) { ModelValidationResult modelValidationResult = ((InvalidProjectModelException) each) .getValidationResult(); if (modelValidationResult != null) { for (Object eachValidationProblem : modelValidationResult.getMessages()) { problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), (String) eachValidationProblem)); } } else { problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), each.getCause().getMessage())); } } else if (each instanceof ProjectBuildingException) { String causeMessage = each.getCause() != null ? each.getCause().getMessage() : each.getMessage(); problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), causeMessage)); } else { problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), each.getMessage())); } } if (unresolvedArtifacts != null) { unresolvedArtifacts.addAll(retrieveUnresolvedArtifactIds()); } }