예제 #1
0
  /**
   * Creates a Verifier against passed in {@link MavenDeployment}.
   *
   * @param mavenDeployment
   * @return
   * @throws VerificationException
   * @throws IOException
   */
  public Verifier createMavenVerifier(final MavenDeployment mavenDeployment)
      throws VerificationException, IOException {
    System.setProperty("maven.home", mavenDeployment.getMavenHomeFile().getAbsolutePath());
    Verifier verifier =
        new Verifier(mavenDeployment.getMavenProjectFile().getAbsolutePath()) {
          @Override
          public void executeGoals(List<String> goals, Map envVars) throws VerificationException {
            try {
              super.executeGoals(goals, envVars);
            } catch (VerificationException e) {
              // HACK: Strip out the entire log which is included in the message by default! :-(
              File logFile = new File(getBasedir(), getLogFileName());
              throw new VerificationException(
                  "Goals execution failed: "
                      + goals
                      + "; see log for more details: "
                      + logFile.getAbsolutePath(),
                  e.getCause());
            }
          }
        };
    verifier.setLogFileName(mavenDeployment.getLogFileName());
    verifier.setLocalRepo(mavenDeployment.getLocalRepositoryFile().getAbsolutePath());
    verifier.resetStreams();

    List<String> options = new ArrayList<String>();
    options.add("-X");
    options.add("-Dmaven.repo.local=" + mavenDeployment.getLocalRepositoryFile().getAbsolutePath());
    options.add("-s " + mavenDeployment.getSettingsXmlFile().getAbsolutePath());
    verifier.setCliOptions(options);
    return verifier;
  }
예제 #2
0
  public void run() {
    status = "started";
    File mavenProject = getTestFile("pom.xml").getParentFile();

    System.setProperty("maven.home", TestProperties.getString("maven.instance"));
    Verifier verifier;
    try {
      verifier = new Verifier(mavenProject.getAbsolutePath(), false);
      status = "verifierCreated";
    } catch (VerificationException e) {
      status = "failCreation" + e.getMessage();
      return;
    }

    File mavenRepository = new File(TestProperties.getString("maven.local.repo"));
    verifier.setLocalRepo(mavenRepository.getAbsolutePath());

    verifier.resetStreams();

    List<String> options = new ArrayList<String>();
    options.add("-X");
    options.add("-Dmaven.repo.local=" + mavenRepository.getAbsolutePath());
    options.add("-s " + getOverridableFile("settings.xml"));
    verifier.setCliOptions(options);

    status = "pre-execute";
    try {
      verifier.executeGoal("dependency:resolve");
      status = "executed";
    } catch (VerificationException e) {
      status = "failExecute" + e.getMessage();
    }
  }
  @SuppressWarnings("unchecked")
  protected Verifier getVerifier(String test, boolean setTargetPlatform, File userSettings)
      throws Exception {
    /*
    Test JVM can be started in debug mode by passing the following
    env to execute(...) methods.

          java.util.Map<String, String> env = new java.util.HashMap<String, String>();
          env.put("MAVEN_OPTS", "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
     */

    // oddly enough, Verifier uses this system property to locate maven install
    System.setProperty("maven.home", getMavenHome());

    File testDir = getBasedir(test);

    Verifier verifier = new Verifier(testDir.getAbsolutePath());
    verifier.getCliOptions().add("-Dmaven.home=" + getMavenHome());
    verifier.getCliOptions().add("-Dtycho-version=" + getTychoVersion());
    if (setTargetPlatform) {
      verifier.getCliOptions().add("-Dtycho.targetPlatform=" + getTargetPlatforn());
    }
    verifier.getCliOptions().add("-X");
    verifier.getCliOptions().add("-s " + userSettings.getCanonicalPath());
    verifier.getVerifierProperties().put("use.mavenRepoLocal", "true");
    verifier.setLocalRepo(EnvironmentUtil.getLocalRepo());

    String customOptions = System.getProperty("it.cliOptions");
    if (customOptions != null && customOptions.trim().length() > 0) {
      verifier.getCliOptions().add(customOptions);
    }

    String m2eState = System.getProperty("m2eclipse.workspace.state");
    String m2eResolver = System.getProperty("m2eclipse.workspace.resolver");

    if (m2eState != null && m2eResolver != null) {
      verifier.getVerifierProperties().put("m2eclipse.workspace.state", m2eState);
    }

    return verifier;
  }