KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antmod > tasks > PromoteToBranchTask


1 package org.antmod.tasks;
2
3 import java.io.File JavaDoc;
4
5 import org.antmod.scm.ScmSystem;
6 import org.antmod.scm.ScmVersion;
7 import org.antmod.util.AntUtil;
8
9 /**
10  * Ant task that does "MergeToBranch" to the latest branch
11  * and promotes the patch-level version of the latest branch.
12  *
13  * @see MergeToBranchTask
14  *
15  * @author Klaas Waslander
16  */

17 public class PromoteToBranchTask extends MergeToBranchTask {
18
19     /**
20      * Public default constructor.
21      */

22     public PromoteToBranchTask() {
23     }
24     
25     public void execute() {
26         // first enforce merging & committing to the latest branch
27
TargetVersionInfo latestBranchTarget = new TargetVersionInfo();
28         latestBranchTarget.setValue(TargetVersionInfo.LATESTBRANCH);
29         setTargetVersion(latestBranchTarget);
30         
31         // now do normal execution
32
super.execute();
33     }
34     
35     protected String JavaDoc getIntroductionText() {
36         return "Merge & commit trunk changes to new version of latest branch";
37     }
38
39     protected boolean askUserConfirmation(ScmVersion localVersion, ScmVersion targetVersion) {
40         String JavaDoc isOkay = AntUtil.ask(getProject(), "Merge, commit & promote changes from '" + localVersion + "' to '" + targetVersion + "' now? ", "yes,no");
41         return "yes".equalsIgnoreCase(isOkay);
42     }
43
44     protected void commitMergedChanges(ScmSystem scm, File JavaDoc checkoutDir, ScmVersion localVersion, ScmVersion targetVersion) {
45         super.commitMergedChanges(scm, checkoutDir, localVersion, targetVersion);
46
47         ScmVersion latestTag = scm.getLatestVersion(checkoutDir);
48         ScmVersion newTag = latestTag.getNextIncrement();
49         logWarning("");
50         logWarning("-- Promoting version of branch '" + targetVersion + "' to '" + newTag + "'...");
51         scm.createTagInBranch(targetVersion, newTag);
52     }
53 }
54
Popular Tags