You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

perforce.html 12 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <html>
  2. <head>
  3. <title>Perforce Tasks for ANT</title>
  4. </head>
  5. <body>
  6. <h1>Perforce Tasks User Manual</h1>
  7. <p>by</p>
  8. <ul>
  9. <li>Les Hughes (<a href="mailto:leslie.hughes@rubus.com">leslie.hughes@rubus.com</a>)</li>
  10. </ul>
  11. <p>Version 1.1 - 2001/01/09</p>
  12. <hr>
  13. <h2>Contents</h2>
  14. <ul>
  15. <li><a href="#intro">Introduction</a></li>
  16. <li><a href="#tasks">The Tasks</a></li>
  17. <li><a href="#changes">Change History</a></li>
  18. </ul>
  19. <br>
  20. <h2><a name="intro">Introduction</a></h2>
  21. <p>These tasks provide an interface to the <a href="http://www.perforce.com" target="_top">Perforce</a> SCM.
  22. The <code>org.apache.tools.ant.taskdefs.optional.perforce</code> package consists of a simple framework to support
  23. p4 functionality as well as some Ant tasks encapsulating frequently used (by me :-) p4 commands.
  24. However, the addition of new p4 commands is a pretty simple task (see the source).
  25. Although it is possible to use these commands on the desktop,
  26. they were primarily intended to be used by automated build systems.</p>
  27. <p><b>Note:</b> These tasks require the <a href="http://jakarta.apache.org/oro" target="_top">oro 2.0</a> regular
  28. expression package. Simply download this package and copy the jakarta-oro-2.0.jar file into Ant's lib directory.
  29. You will also need the perforce client executable (p4 or p4.exe but not p4win.exe) in your path.
  30. </p>
  31. <h2><a name="tasks">The Tasks</a></h2>
  32. <table border="0" cellspacing="0" cellpadding="3">
  33. <tr>
  34. <td><a href="#p4sync">P4Sync</a></td>
  35. <td>Synchronise a workspce to a depot</td>
  36. </tr>
  37. <tr>
  38. <td><a href="#p4change">P4Change</a></td>
  39. <td>Request a new changelist from the perforce server</td>
  40. </tr>
  41. <tr>
  42. <td><a href="#p4edit">P4Edit</a></td>
  43. <td>Open files for edit (checkout)</td>
  44. </tr>
  45. <tr>
  46. <td><a href="#p4submit">P4Submit</a></td>
  47. <td>Submit a changelist to the perforce server (checkin)</td>
  48. </tr>
  49. <tr>
  50. <td><a href="#p4have">P4Have</a></td>
  51. <td>List current files in client view, useful for reporting</td>
  52. </tr>
  53. <tr>
  54. <td><a href="#p4label">P4Label</a></td>
  55. <td>Create a label reflecting files in the current workspace</td>
  56. </tr>
  57. <tr>
  58. <td><a href="#p4counter">P4Counter</a></td>
  59. <td>Obtain or set the value of a counter</td>
  60. </tr>
  61. </table>
  62. <h3>General P4 Properties</h3>
  63. <p>Each p4 task requires a number of settings, either through build-wide properties, individual attributes
  64. or environment variables. These are
  65. </p>
  66. <table border="1" cellpadding="2" cellspacing="0">
  67. <tr>
  68. <td valign="top"><b>Property</b></td>
  69. <td valign="top"><b>Attribute</b></td>
  70. <td valign="top"><b>Env Var</b></td>
  71. <td valign="top"><b>Description</b></td>
  72. <td align="center" valign="top"><b>Default</b></td>
  73. </tr>
  74. <tr>
  75. <td valign="top">p4.port</td>
  76. <td valign="top">port</td>
  77. <td valign="top">P4PORT</td>
  78. <td valign="top">The p4d server and port to connect to</td>
  79. <td valign="top">perforce:1666</td>
  80. </tr>
  81. <tr>
  82. <td valign="top">p4.client</td>
  83. <td valign="top">client</td>
  84. <td valign="top">P4CLIENT</td>
  85. <td valign="top">The p4 client spec to use</td>
  86. <td valign="top">The logged in username</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">p4.user</td>
  90. <td valign="top">user</td>
  91. <td valign="top">P4USER</td>
  92. <td valign="top">The p4 username</td>
  93. <td valign="top">The logged in username</td>
  94. </tr>
  95. <tr>
  96. <td valign="top" align="center">--</td>
  97. <td valign="top">view</td>
  98. <td valign="top" align="center">--</td>
  99. <td valign="top">The client, branch or label view to operate upon. See the p4 user guide for more info.</td>
  100. <td valign="top">//...</td>
  101. </tr>
  102. </table>
  103. <p>
  104. Your local installation of perforce may require other settings (e.g. P4PASSWD, P4CONFIG). At the moment, these can only be set outside of Ant, as environment variables.
  105. </p>
  106. <h3>Examples</h3>
  107. <p>Setting in the environment:-</p>
  108. <p>
  109. (Unix csh)</p>
  110. <pre>setenv P4PORT myperforcebox:1666</pre>
  111. <p>(Unix sh et al)</p>
  112. <pre>P4USER=myp4userid; export P4USER</pre>
  113. <p>Using build properties:-</p>
  114. <pre>&lt;property name=&quot;p4.client&quot; value=&quot;nightlybuild&quot;/&gt;</pre>
  115. <p>Using task attributes:-</p>
  116. <pre>
  117. &lt;p4Whatever
  118. port=&quot;myserver:1666&quot;
  119. client=&quot;smoketest&quot;
  120. user=&quot;smoketestdude&quot;
  121. .
  122. .
  123. .
  124. /&gt;
  125. </pre>
  126. <p>
  127. For more information regarding the underlying 'p4' commands you are referred to the Perforce Command Reference
  128. available from the <a href="http://www.perforce.com/" target="_top">Perforce website</a>.
  129. </p>
  130. <h3>Taskdefs</h3>
  131. <p>Standard taskdefs (for you to copy'n'paste)</p>
  132. <pre>
  133. &lt;taskdef name=&quot;p4sync&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Sync&quot; /&gt;
  134. &lt;taskdef name=&quot;p4change&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Change&quot; /&gt;
  135. &lt;taskdef name=&quot;p4edit&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Edit&quot; /&gt;
  136. &lt;taskdef name=&quot;p4submit&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Submit&quot; /&gt;
  137. &lt;taskdef name=&quot;p4have&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Have&quot; /&gt;
  138. &lt;taskdef name=&quot;p4label&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Label&quot; /&gt;
  139. &lt;taskdef name=&quot;p4counter&quot; classname=&quot;org.apache.tools.ant.taskdefs.optional.perforce.P4Counter&quot; /&gt;
  140. </pre>
  141. <hr>
  142. <h2>Task Descriptions</h2>
  143. <h2><a name="p4sync">P4Sync</a></h2>
  144. <h3>Description:</h3>
  145. <p>Synchronize the current workspace with the depot.</p>
  146. <h3>Parameters</h3>
  147. <table border="1" cellpadding="2" cellspacing="0">
  148. <tr>
  149. <td valign="top"><b>Attribute</b></td>
  150. <td valign="top"><b>Description</b></td>
  151. <td align="center" valign="top"><b>Required</b></td>
  152. </tr>
  153. <tr>
  154. <td valign="top">force</td>
  155. <td valign="top">force a refresh of files</td>
  156. <td valign="top" align="center">no</td>
  157. </tr>
  158. <tr>
  159. <td valign="top">label</td>
  160. <td valign="top">sync client to label</td>
  161. <td valign="top" align="center">no</td>
  162. </tr>
  163. </table>
  164. <h3>Examples</h3>
  165. <pre>&lt;p4sync label=&quot;nightlybuild-0.0123&quot; force=&quot;yes&quot; /&gt;
  166. &lt;p4sync view=&quot;//depot/projects/projectfoo/main/src/...&quot; /&gt;
  167. </pre>
  168. <hr>
  169. <h2><a name="p4change">P4Change</a></h2>
  170. <h3>Description:</h3>
  171. <p>Request a new changelist from the perforce server.
  172. This task sets the ${p4.change} property which can then be passed to P4Submit or P4Edit.
  173. </p>
  174. <h3>Parameters</h3>
  175. <table border="1" cellpadding="2" cellspacing="0">
  176. <tr>
  177. <td valign="top"><b>Attribute</b></td>
  178. <td valign="top"><b>Description</b></td>
  179. <td align="center" valign="top"><b>Required</b></td>
  180. </tr>
  181. <tr>
  182. <td valign="top">description</td>
  183. <td valign="top">Description for ChangeList. If none specified, it will
  184. default to "AutoSubmit By Ant"</td>
  185. <td valign="top" align="center">No.</td>
  186. </tr>
  187. </table>
  188. <h3>Examples</h3>
  189. <pre>&lt;p4change description="Change Build Number in Script"&gt;
  190. </pre>
  191. <hr>
  192. <h2><a name="p4edit">P4Edit</a></h2>
  193. <h3>Description:</h3>
  194. <p>Open file(s) for edit. P4Change should be used to obtain a new changelist for P4Edit as,
  195. although P4Edit can open files to the default change, P4Submit cannot yet submit it.
  196. </p>
  197. <h3>Parameters</h3>
  198. <table border="1" cellpadding="2" cellspacing="0">
  199. <tr>
  200. <td valign="top"><b>Attribute</b></td>
  201. <td valign="top"><b>Description</b></td>
  202. <td align="center" valign="top"><b>Required</b></td>
  203. </tr>
  204. <tr>
  205. <td valign="top">view</td>
  206. <td valign="top">The filespec to request to edit</td>
  207. <td valign="top" align="center">Yes</td>
  208. </tr>
  209. <tr>
  210. <td valign="top">change</td>
  211. <td valign="top">An existing changelist number to assign files to.</td>
  212. <td valign="top" align="center">No, but see above.</td>
  213. </tr>
  214. </table>
  215. <h3>Examples</h3>
  216. <pre>
  217. &lt;p4edit
  218. view=&quot;//depot/projects/projectfoo/main/src/Blah.java...&quot;
  219. change=&quot;${p4.change}&quot; /&gt;
  220. </pre>
  221. <hr>
  222. <h2><a name="p4submit">P4Submit</a></h2>
  223. <h3>Description:</h3>
  224. <p>Submit a changelist, usually obtained from P4Change.
  225. </p>
  226. <h3>Parameters</h3>
  227. <table border="1" cellpadding="2" cellspacing="0">
  228. <tr>
  229. <td valign="top"><b>Attribute</b></td>
  230. <td valign="top"><b>Description</b></td>
  231. <td align="center" valign="top"><b>Required</b></td>
  232. </tr>
  233. <tr>
  234. <td valign="top">change</td>
  235. <td valign="top">The changelist number to submit</td>
  236. <td valign="top" align="center">Yes</td>
  237. </tr>
  238. </table>
  239. <h3>Examples</h3>
  240. <pre>&lt;p4submit change=&quot;${p4.change}&quot; /&gt;
  241. </pre>
  242. <hr>
  243. <h2><a name="p4have">P4Have</a></h2>
  244. <h3>Description:</h3>
  245. <p>List handy file info reflecting the current client contents.
  246. </p>
  247. <h3>Parameters</h3>
  248. <table border="1" cellpadding="2" cellspacing="0">
  249. <tr>
  250. <td valign="top"><b>Attribute</b></td>
  251. <td valign="top"><b>Description</b></td>
  252. <td align="center" valign="top"><b>Required</b></td>
  253. </tr>
  254. <tr>
  255. <td valign="top">None</td>
  256. <td valign="top" align="center">--</td>
  257. <td valign="top" align="center">--</td>
  258. </tr>
  259. </table>
  260. <h3>Examples</h3>
  261. <pre>&lt;p4have /&gt;
  262. </pre>
  263. <hr>
  264. <h2><a name="p4label">P4Label</a></h2>
  265. <h3>Description:</h3>
  266. <p>Create a new label and set contents to reflect current client file revisions.
  267. </p>
  268. <h3>Parameters</h3>
  269. <table border="1" cellpadding="2" cellspacing="0">
  270. <tr>
  271. <td valign="top"><b>Attribute</b></td>
  272. <td valign="top"><b>Description</b></td>
  273. <td align="center" valign="top"><b>Required</b></td>
  274. </tr>
  275. <tr>
  276. <td valign="top">name</td>
  277. <td valign="top">The name of the label</td>
  278. <td valign="top" align="center">Yes</td>
  279. </tr>
  280. <tr>
  281. <td valign="top">view</td>
  282. <td valign="top">client view to use for label</td>
  283. <td valign="top" align="center">No</td>
  284. </tr>
  285. <tr>
  286. <td valign="top">desc</td>
  287. <td valign="top">Label Description</td>
  288. <td valign="top" align="center">No</td>
  289. </tr>
  290. </table>
  291. <h3>Examples</h3>
  292. <pre>
  293. &lt;p4label
  294. name=&quot;NightlyBuild:${DSTAMP}:${TSTAMP}&quot;
  295. desc=&quot;Auto Nightly Build&quot;
  296. /&gt;
  297. </pre>
  298. <hr>
  299. <h2><a name="p4counter">P4Counter</a></h2>
  300. <h3>Description:</h3>
  301. <p>Obtain or set the value of a counter
  302. </p>
  303. <h3>Parameters</h3>
  304. <table border="1" cellpadding="2" cellspacing="0">
  305. <tr>
  306. <td valign="top"><b>Attribute</b></td>
  307. <td valign="top"><b>Description</b></td>
  308. <td align="center" valign="top"><b>Required</b></td>
  309. </tr>
  310. <tr>
  311. <td valign="top">name</td>
  312. <td valign="top">The name of the counter</td>
  313. <td valign="top" align="center">Yes</td>
  314. </tr>
  315. <tr>
  316. <td valign="top">value</td>
  317. <td valign="top">The new value for the counter</td>
  318. <td valign="top" align="center">No</td>
  319. </tr>
  320. </table>
  321. <h3>Examples</h3>
  322. <pre>
  323. &lt;p4counter name=&quot;last-clean-build&quot; /&gt;
  324. &lt;p4counter name=&quot;last-clean-build&quot; value=&quot;${TSTAMP}&quot; /&gt;
  325. </pre>
  326. <hr>
  327. <h2><a name="changes">Change History</a></h2>
  328. <table border="1" cellpadding="2" cellspacing="0">
  329. <tr>
  330. <td valign="top">Sept 2000</td>
  331. <td valign="top" align="center">--</td>
  332. <td valign="top">Internal Release within Rubus</td>
  333. </tr>
  334. <tr>
  335. <td valign="top">Nov 2000</td>
  336. <td valign="top">V1.0</td>
  337. <td valign="top">Initial Release donated to ASF :-)</td>
  338. </tr>
  339. <tr>
  340. <td valign="top">Jan 2001</td>
  341. <td valign="top">V1.1</td>
  342. <td valign="top">fixed cross platform (NT/Unix) bug<br>refactored p4 output handling code<br>refactored exec'ing code</td>
  343. </tr>
  344. </table>
  345. </body>
  346. </html>