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 13 KiB

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