PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/jgitflow-maven-plugin/src/main/java/com/atlassian/maven/plugins/jgitflow/extension/command/UpdateCurrentBranchWithHotfixVersionsCommand.java

https://bitbucket.org/lukejackson/jgit-flow
Java | 76 lines | 59 code | 17 blank | 0 comment | 0 complexity | dc485eaeba732b903fffe24d34e05f3b MD5 | raw file
Possible License(s): Apache-2.0
  1. package com.atlassian.maven.plugins.jgitflow.extension.command;
  2. import java.util.List;
  3. import com.atlassian.jgitflow.core.BranchType;
  4. import com.atlassian.jgitflow.core.GitFlowConfiguration;
  5. import com.atlassian.jgitflow.core.JGitFlowReporter;
  6. import com.atlassian.jgitflow.core.command.JGitFlowCommand;
  7. import com.atlassian.jgitflow.core.exception.JGitFlowExtensionException;
  8. import com.atlassian.jgitflow.core.extension.ExtensionCommand;
  9. import com.atlassian.jgitflow.core.extension.ExtensionFailStrategy;
  10. import com.atlassian.maven.plugins.jgitflow.ReleaseContext;
  11. import com.atlassian.maven.plugins.jgitflow.helper.BranchHelper;
  12. import com.atlassian.maven.plugins.jgitflow.helper.PomUpdater;
  13. import com.atlassian.maven.plugins.jgitflow.helper.ProjectHelper;
  14. import com.atlassian.maven.plugins.jgitflow.provider.ContextProvider;
  15. import com.atlassian.maven.plugins.jgitflow.provider.VersionCacheProvider;
  16. import com.atlassian.maven.plugins.jgitflow.provider.VersionProvider;
  17. import org.apache.maven.project.MavenProject;
  18. import org.codehaus.plexus.component.annotations.Component;
  19. import org.codehaus.plexus.component.annotations.Requirement;
  20. import org.eclipse.jgit.api.Git;
  21. @Component(role = UpdateCurrentBranchWithHotfixVersionsCommand.class)
  22. public class UpdateCurrentBranchWithHotfixVersionsCommand implements ExtensionCommand
  23. {
  24. @Requirement
  25. private VersionCacheProvider versionCacheProvider;
  26. @Requirement
  27. private PomUpdater pomUpdater;
  28. @Requirement
  29. private BranchHelper branchHelper;
  30. @Requirement
  31. private VersionProvider versionProvider;
  32. @Requirement
  33. private ProjectHelper projectHelper;
  34. @Requirement
  35. private ContextProvider contextProvider;
  36. @Override
  37. public void execute(GitFlowConfiguration configuration, Git git, JGitFlowCommand gitFlowCommand, JGitFlowReporter reporter) throws JGitFlowExtensionException
  38. {
  39. try
  40. {
  41. ReleaseContext ctx = contextProvider.getContext();
  42. versionCacheProvider.cacheCurrentBranchVersions();
  43. String currentName = branchHelper.getCurrentBranchName();
  44. List<MavenProject> currentProjects = branchHelper.getProjectsForCurrentBranch();
  45. List<MavenProject> hotfixProjects = branchHelper.getProjectsForTopicBranch(BranchType.HOTFIX);
  46. pomUpdater.copyPomVersionsFromProject(hotfixProjects, currentProjects);
  47. projectHelper.commitAllPoms(git, currentProjects, ctx.getScmCommentPrefix() + "Updating " + currentName + " poms to hotfix version to avoid merge conflicts" + ctx.getScmCommentSuffix());
  48. }
  49. catch (Exception e)
  50. {
  51. throw new JGitFlowExtensionException("Error updating current branch poms to hotfix version", e);
  52. }
  53. }
  54. @Override
  55. public ExtensionFailStrategy failStrategy()
  56. {
  57. return ExtensionFailStrategy.ERROR;
  58. }
  59. }