Пример #1
0
  /**
   * @param goals
   * @param serverProperties
   * @param module
   * @param monitor
   * @return
   * @throws CoreException
   */
  public static boolean runBuild(
      List<String> goals, Properties serverProperties, IModule module, IProgressMonitor monitor)
      throws CoreException {
    IMaven maven = MavenPlugin.getMaven();
    IMavenExecutionContext executionContext = maven.createExecutionContext();
    MavenExecutionRequest executionRequest = executionContext.getExecutionRequest();
    executionRequest.setPom(getModelFile(module));
    if (serverProperties != null && serverProperties.isEmpty() == false) {
      Server fabric8Server = new Server();
      fabric8Server.setId(serverProperties.getProperty(SERVER_ID));
      fabric8Server.setUsername(serverProperties.getProperty(SERVER_USER));
      fabric8Server.setPassword(serverProperties.getProperty(SERVER_PASSWORD));
      executionRequest.addServer(fabric8Server);
    }
    executionRequest.setGoals(goals);

    MavenExecutionResult result = maven.execute(executionRequest, monitor);
    for (Throwable t : result.getExceptions()) {
      Activator.getLogger().error(t);
    }
    return !result.hasExceptions();
  }