コード例 #1
0
  @Override
  public void execute(GitFlowConfiguration configuration, Git git, JGitFlowCommand gitFlowCommand)
      throws JGitFlowExtensionException {
    try {
      BranchType branchType = branchHelper.getCurrentBranchType();
      ProjectCacheKey cacheKey = null;

      switch (branchType) {
        case RELEASE:
          cacheKey = ProjectCacheKey.RELEASE_BRANCH;
          break;

        case HOTFIX:
          cacheKey = ProjectCacheKey.HOTFIX_BRANCH;
          break;

        case DEVELOP:
          cacheKey = ProjectCacheKey.DEVELOP_BRANCH;
          break;

        case MASTER:
          cacheKey = ProjectCacheKey.MASTER_BRANCH;
          break;

        case FEATURE:
          cacheKey = ProjectCacheKey.FEATURE_BRANCH;
          break;

        default:
          throw new JGitFlowExtensionException(
              "Unsupported branch type '"
                  + branchType.name()
                  + "' while running "
                  + this.getClass().getSimpleName()
                  + " command");
      }

      ReleaseContext ctx = contextProvider.getContext();
      List<MavenProject> branchProjects = branchHelper.getProjectsForCurrentBranch();

      projectHelper.checkPomForVersionState(VersionState.RELEASE, branchProjects);

      if (!ctx.isAllowSnapshots()) {
        List<String> snapshots =
            projectHelper.checkForNonReactorSnapshots(cacheKey, branchProjects);
        if (!snapshots.isEmpty()) {
          String details = Joiner.on(ls).join(snapshots);
          throw new UnresolvedSnapshotsException(
              "Cannot finish a "
                  + branchType.name().toLowerCase()
                  + " due to snapshot dependencies:"
                  + ls
                  + details);
        }
      }
    } catch (Exception e) {
      throw new JGitFlowExtensionException(
          "Error verifying version state in poms: " + e.getMessage(), e);
    }
  }
コード例 #2
0
  @Override
  public void execute(MavenProject project, MavenSession session) throws MavenExecutorException {
    ReleaseContext ctx = contextProvider.getContext();

    String goal = ctx.getGoals();

    if (ctx.isNoDeploy()) {
      goal = "clean install";
    }

    execute(project, session, goal);
  }
コード例 #3
0
  @Override
  public void execute(MavenProject project, MavenSession session, String goals)
      throws MavenExecutorException {
    ReleaseContext ctx = contextProvider.getContext();

    List<String> argList = new ArrayList<String>();

    if (ctx.isUseReleaseProfile()) {
      argList.add("-DperformRelease=true");
    }

    String args = ctx.getArgs();
    if (Strings.isNullOrEmpty(args)) {

      // use default user properties + default profiles

      Properties userProps = session.getUserProperties();

      for (String key : userProps.stringPropertyNames()) {
        argList.add("-D" + key + "=\"" + userProps.getProperty(key) + "\"");
      }

      for (String profileId : getActiveProfileIds(project, session)) {
        argList.add("-P" + profileId);
      }

    } else {

      // use user specific release arguments
      argList.add(args.trim());
    }

    String additionalArgs = Joiner.on(" ").join(argList);

    ReleaseResult result = new ReleaseResult();
    ReleaseEnvironment env = new DefaultReleaseEnvironment();
    env.setSettings(session.getSettings());
    MavenExecutor mavenExecutor = mavenExecutors.get(env.getMavenExecutorId());

    mavenExecutor.executeGoals(
        ctx.getBaseDir(), goals, env, ctx.isInteractive(), additionalArgs, result);
  }
コード例 #4
0
  @Override
  public void execute(GitFlowConfiguration configuration, Git git, JGitFlowCommand gitFlowCommand)
      throws JGitFlowExtensionException {
    try {
      JGitFlow flow = jGitFlowProvider.gitFlow();
      ReleaseContext ctx = contextProvider.getContext();

      String originalBranchName = branchHelper.getCurrentBranchName();

      // check out develop and reload the reactor
      SessionAndProjects sessionAndProjects =
          checkoutAndGetProjects.run(flow.getDevelopBranchName());
      List<MavenProject> developProjects = sessionAndProjects.getProjects();

      String developLabel =
          labelProvider.getNextVersionLabel(
              VersionType.DEVELOPMENT, ProjectCacheKey.DEVELOP_BRANCH, developProjects);

      pomUpdater.updatePomsWithNextDevelopmentVersion(
          ProjectCacheKey.DEVELOP_BRANCH, developProjects);

      projectHelper.commitAllPoms(
          flow.git(),
          developProjects,
          ctx.getScmCommentPrefix()
              + "updating poms for "
              + developLabel
              + " development"
              + ctx.getScmCommentSuffix());

      flow.git().checkout().setName(originalBranchName).call();

    } catch (Exception e) {
      throw new JGitFlowExtensionException(
          "Error updating develop poms to next development version", e);
    }
  }