Java 类org.apache.maven.project.validation.ModelValidationResult 实例源码

项目:intellij-ce-playground    文件:Maven30ServerEmbedderImpl.java   
private void validate(@NotNull File file,
                      @NotNull Collection<Exception> exceptions,
                      @NotNull Collection<MavenProjectProblem> problems,
                      @Nullable Collection<MavenId> unresolvedArtifacts) throws RemoteException {
  for (Throwable each : exceptions) {
    Maven3ServerGlobals.getLogger().info(each);

    if (each instanceof IllegalStateException && each.getCause() != null) {
      each = each.getCause();
    }

    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());
  }
}
项目:intellij-ce-playground    文件:Maven2ServerEmbedderImpl.java   
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));
        }
      }
      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());
}
项目:intellij-ce-playground    文件:Maven32ServerEmbedderImpl.java   
private void validate(@NotNull File file,
                      @NotNull Collection<Exception> exceptions,
                      @NotNull Collection<MavenProjectProblem> problems,
                      @Nullable Collection<MavenId> unresolvedArtifacts) throws RemoteException {
  for (Throwable each : exceptions) {
    Maven3ServerGlobals.getLogger().info(each);

    if (each instanceof IllegalStateException && each.getCause() != null) {
      each = each.getCause();
    }

    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());
  }
}
项目:che    文件:MavenServerImpl.java   
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();
    }

    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()));
    }
  }
}
项目:tools-idea    文件:Maven3ServerEmbedderImpl.java   
private void validate(File file,
                      Collection<Exception> exceptions,
                      Collection<MavenProjectProblem> problems,
                      Collection<MavenId> unresolvedArtifacts) throws RemoteException {
  for (Exception each : exceptions) {
    Maven3ServerGlobals.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));
        }
      }
      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());
}
项目:tools-idea    文件:Maven2ServerEmbedderImpl.java   
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));
        }
      }
      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());
}
项目:oceano    文件:InvalidProjectModelException.java   
public InvalidProjectModelException( String projectId, String message, File pomFile,
                                     ModelValidationResult validationResult )
{
    super( projectId, message, pomFile );

    this.validationResult = validationResult;
}
项目:SpecialSourceMP    文件:InstallRemappedFileMojo.java   
/**
 * Validates the user-supplied artifact information.
 *
 * @throws MojoExecutionException If any artifact coordinate is invalid.
 */
private void validateArtifactInformation()
        throws MojoExecutionException
{
    Model model = generateModel();

    ModelValidationResult result = modelValidator.validate( model );

    if ( result.getMessageCount() > 0 )
    {
        throw new MojoExecutionException(
                "The artifact information is incomplete or not valid:\n" + result.render( "  " ) );
    }
}
项目:oceano    文件:InvalidProjectModelException.java   
public final ModelValidationResult getValidationResult()
{
    return validationResult;
}
项目:oceano    文件:InvalidProjectModelException.java   
/**
 * @param projectId
 * @param pomLocation      absolute path of the pom file
 * @param message
 * @param validationResult
 * @deprecated use {@link File} constructor for pomLocation
 */
public InvalidProjectModelException( String projectId, String pomLocation, String message,
                                     ModelValidationResult validationResult )
{
    this( projectId, message, new File( pomLocation ), validationResult );
}