Ejemplo n.º 1
0
  private boolean ensureNoLocalModifications()
      throws ComponentLookupException, ScmException, MojoExecutionException {

    if (!Boolean.getBoolean("sesat.mojo.localModifications.ignore")) {

      final ScmManager scmManager = (ScmManager) container.lookup(ScmManager.ROLE);

      loadPomProject();

      final StatusScmResult result =
          scmManager.status(
              scmManager.makeScmRepository(project.getScm().getDeveloperConnection()),
              new ScmFileSet(pomProject.getBasedir()));

      if (!result.isSuccess()) {

        getLog().error(result.getCommandOutput());
        throw new MojoExecutionException("Failed to ensure checkout has no modifications");
      }

      if (0 < result.getChangedFiles().size()) {

        throw new MojoExecutionException(
            "Your checkout has local modifications. "
                + "Server deploy can *only* be done with a clean workbench.");
      }

      return result.isSuccess() && 0 == result.getChangedFiles().size();
    }
    return true; // sesat.mojo.localModifications.ignore
  }
 /**
  * Creates the provider instance to access the given repository.
  *
  * @param repository the repository to access with the provider to be created.
  * @return the provider to access the given repository.
  * @throws ScmException if the provider cannot be created.
  */
 private ScmProvider createScmProvider(final ScmRepository repository) throws ScmException {
   try {
     final ScmProvider provider = scmManager.getProviderByRepository(repository);
     return provider;
   } catch (final NoSuchScmProviderException e) {
     throw new ScmException("Cannot create SCM provider.", e);
   }
 }
Ejemplo n.º 3
0
  private void tagDeploy() throws ComponentLookupException, ScmException {

    final ScmManager scmManager = (ScmManager) container.lookup(ScmManager.ROLE);
    final String date = new SimpleDateFormat("yyyyMMddHHmm").format(now);

    loadPomProject();

    final TagScmResult result =
        scmManager.tag(
            scmManager.makeScmRepository(project.getScm().getDeveloperConnection()),
            new ScmFileSet(pomProject.getBasedir()), // TODO server-side copy
            profile + "-deployments/" + date + "-" + project.getArtifactId(),
            "sesat " + profile + " deployment");

    if (!result.isSuccess()) {
      throw new ScmException(result.getCommandOutput());
    }
  }