}
@Override
public void finish(ReleaseContext ctx, List<MavenProject> reactorProjects, MavenSession session) throws JGitFlowReleaseException
{
JGitFlow flow = null;
MavenProject rootProject = ReleaseUtil.getRootProject(reactorProjects);
MavenSession currentSession = session;
try
{
flow = JGitFlow.getOrInit(ctx.getBaseDir(), ctx.getFlowInitContext());
writeReportHeader(ctx,flow.getReporter());
setupSshCredentialProviders(ctx,flow.getReporter());
String featureLabel = getFeatureFinishName(ctx, flow);
// make sure we are on specific feature branch
flow.git().checkout().setName(flow.getFeatureBranchPrefix() + featureLabel).call();
if(ctx.isEnableFeatureVersions())
{
updateFeaturePomsWithNonFeatureVersion(featureLabel, flow, ctx, reactorProjects, session);
//reload the reactor projects
MavenSession featureSession = getSessionForBranch(flow, flow.getFeatureBranchPrefix() + featureLabel, reactorProjects, session);
List<MavenProject> featureProjects = featureSession.getSortedProjects();
currentSession = featureSession;
rootProject = ReleaseUtil.getRootProject(featureProjects);
}
if(ctx.isPushFeatures())
{
projectHelper.ensureOrigin(reactorProjects, flow);
}
if(!ctx.isNoBuild())
{
try
{
mavenExecutionHelper.execute(rootProject, ctx, currentSession);
}
catch (MavenExecutorException e)
{
throw new JGitFlowReleaseException("Error building: " + e.getMessage(), e);
}
}
getLogger().info("running jgitflow feature finish...");
flow.featureFinish(featureLabel)
.setKeepBranch(ctx.isKeepBranch())
.setSquash(ctx.isSquash())
.setRebase(ctx.isFeatureRebase())
.setAllowUntracked(ctx.isAllowUntracked())
.setPush(ctx.isPushFeatures())
.setNoMerge(ctx.isNoFeatureMerge())
.call();
//make sure we're on develop
flow.git().checkout().setName(flow.getDevelopBranchName()).call();
}
catch (JGitFlowException e)
{
throw new JGitFlowReleaseException("Error finish feature: " + e.getMessage(), e);
}
catch (GitAPIException e)
{
throw new JGitFlowReleaseException("Error finish feature: " + e.getMessage(), e);
}
catch (ReactorReloadException e)
{
throw new JGitFlowReleaseException("Error finish feature: " + e.getMessage(), e);
}
catch (IOException e)
{
throw new JGitFlowReleaseException("Error finish feature: " + e.getMessage(), e);
}
finally
{
if(null != flow)
{
flow.getReporter().flush();
}
}
}