1 18 23 24 package org.apache.tools.ant.taskdefs.optional.perforce; 25 26 import org.apache.tools.ant.BuildException; 27 import org.apache.tools.ant.Project; 28 import java.util.Vector ; 29 30 41 public class P4Submit extends P4Base { 42 43 48 public String change; 49 53 private String changeProperty; 54 57 private String needsResolveProperty; 58 62 public void setChange(String change) { 63 this.change = change; 64 } 65 71 public void setChangeProperty(String changeProperty) { 72 this.changeProperty = changeProperty; 73 } 74 79 public void setNeedsResolveProperty(String needsResolveProperty) { 80 this.needsResolveProperty = needsResolveProperty; 81 } 82 83 87 public void execute() throws BuildException { 88 if (change != null) { 89 execP4Command("submit -c " + change, (P4HandlerAdapter) new P4SubmitAdapter(this)); 90 } else { 91 throw new BuildException("No change specified (no support for default change yet...."); 94 } 95 } 96 97 100 public class P4SubmitAdapter extends SimpleP4OutputHandler { 101 105 public P4SubmitAdapter(P4Base parent) { 106 super(parent); 107 } 108 112 public void process(String line) { 113 super.process(line); 114 getProject().setProperty("p4.needsresolve", "0"); 115 if (util.match("/renamed/", line)) { 118 try { 119 Vector myarray = new Vector (); 120 util.split(myarray, line); 121 boolean found = false; 122 for (int counter = 0; counter < myarray.size(); counter++) { 123 if (found) { 124 String chnum = (String ) myarray.elementAt(counter + 1); 125 int changenumber = Integer.parseInt(chnum); 126 log("Perforce change renamed " + changenumber, Project.MSG_INFO); 127 getProject().setProperty("p4.change", "" + changenumber); 128 if (changeProperty != null) { 129 getProject().setNewProperty(changeProperty, chnum); 130 } 131 found = false; 132 } 133 if (((myarray.elementAt(counter))).equals("renamed")) { 134 found = true; 135 } 136 } 137 } catch (Exception e) { 139 String msg = "Failed to parse " + line + "\n" 140 + " due to " + e.getMessage(); 141 throw new BuildException(msg, e, getLocation()); 142 } 143 } 144 if (util.match("/p4 submit -c/", line)) { 145 getProject().setProperty("p4.needsresolve", "1"); 146 if (needsResolveProperty != null) { 147 getProject().setNewProperty(needsResolveProperty, "true"); 148 } 149 } 150 151 } 152 } 153 154 } 155 | Popular Tags |