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.

script.html 2.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="script">Script</a></h2>
  8. <h3>Description</h3>
  9. <p>Execute a script in a
  10. <a href="http://oss.software.ibm.com/developerworks/opensource/bsf/" target="_top">BSF</a> supported language.</p>
  11. <p>All items (tasks, targets, etc) of the running project are
  12. accessible from the script, using either their <code>name</code> or
  13. <code>id</code> attributes.</p>
  14. <p>Scripts can do almost anything a task written in Java could do.</p>
  15. <h3>Parameters</h3>
  16. <table border="1" cellpadding="2" cellspacing="0">
  17. <tr>
  18. <td valign="top"><b>Attribute</b></td>
  19. <td valign="top"><b>Description</b></td>
  20. <td align="center" valign="top"><b>Required</b></td>
  21. </tr>
  22. <tr>
  23. <td valign="top">language</td>
  24. <td valign="top">The programming language the script is written in.
  25. Must be a supported BSF language</td>
  26. <td valign="top" align="center">No</td>
  27. </tr>
  28. <tr>
  29. <td valign="top">src</td>
  30. <td valign="top">The location of the script as a file, if not inline</td>
  31. <td valign="top" align="center">No</td>
  32. </tr>
  33. </table>
  34. <h3>Examples</h3>
  35. <blockquote><pre>
  36. &lt;project name=&quot;squares&quot; default=&quot;main&quot; basedir=&quot;.&quot;&gt;
  37. &lt;target name=&quot;setup&quot;&gt;
  38. &lt;script language=&quot;javascript&quot;&gt; &lt;![CDATA[
  39. for (i=1; i&lt;=10; i++) {
  40. echo = squares.createTask(&quot;echo&quot;);
  41. main.addTask(echo);
  42. echo.setMessage(i*i);
  43. }
  44. ]]&gt; &lt;/script&gt;
  45. &lt;/target&gt;
  46. &lt;target name=&quot;main&quot; depends=&quot;setup&quot;/&gt;
  47. &lt;/project&gt;
  48. </pre></blockquote>
  49. <p>generates</p>
  50. <blockquote><pre>
  51. setup:
  52. main:
  53. 1
  54. 4
  55. 9
  56. 16
  57. 25
  58. 36
  59. 49
  60. 64
  61. 81
  62. 100
  63. BUILD SUCCESSFUL
  64. </pre></blockquote>
  65. <p>Another example, using <a href="../using.html#references">references by id</a>
  66. and two different scripting languages:</p>
  67. <blockquote><pre>
  68. &lt;project name=&quot;testscript&quot; default=&quot;main&quot;&gt;
  69. &lt;target name=&quot;sub&quot;&gt;
  70. &lt;echo id=&quot;theEcho&quot;/&gt;
  71. &lt;/target&gt;
  72. &lt;target name=&quot;sub1&quot;&gt;
  73. &lt;script language=&quot;netrexx&quot;&gt;&lt;![CDATA[
  74. theEcho.setMessage(&quot;In sub1&quot;)
  75. sub.execute
  76. ]]&gt;&lt;/script&gt;
  77. &lt;/target&gt;
  78. &lt;target name=&quot;sub2&quot;&gt;
  79. &lt;script language=&quot;javascript&quot;&gt;&lt;![CDATA[
  80. theEcho.setMessage(&quot;In sub2&quot;);
  81. sub.execute();
  82. ]]&gt;&lt;/script&gt;
  83. &lt;/target&gt;
  84. &lt;target name=&quot;main&quot; depends=&quot;sub1,sub2&quot;/&gt;
  85. &lt;/project&gt;
  86. </pre></blockquote>
  87. <p>generates</p>
  88. <blockquote><pre>
  89. sub1:
  90. In sub1
  91. sub2:
  92. In sub2
  93. main:
  94. BUILD SUCCESSFUL
  95. </pre></blockquote>
  96. <hr>
  97. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  98. Reserved.</p>
  99. </body>
  100. </html>