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

ant-ajc-task.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <meta http-equiv="Content-Language" content="en-us">
  6. <title>AjcTask Ant Support for AspectJ 1.1</title>
  7. </head>
  8. <body>
  9. <h2>
  10. <a NAME="ajc"></a>AjcTask Ant Support for AspectJ 1.1</h2>
  11. <h3>
  12. Description</h3>
  13. This task uses the AspectJ<small><sup>tm</sup></small> 1.1 compiler
  14. <code>ajc</code>.
  15. The AspectJ compiler can be used like
  16. <a href="http://jakarta.apache.org/ant/manual/CoreTasks/javac.html">Javac</a>
  17. to compile Java sources, but it can also compile AspectJ sources or
  18. weave binary aspects with Java bytecode. It can run in normal "batch" mode
  19. or in an "incremental" mode, where it only recompiles files it has to revisit.
  20. For more information on <tt>ajc</tt>, see the links from
  21. the <a href="index.html">AspectJ docs home</a>. The main things to remember:
  22. <ul>
  23. <li>In incremental mode, sources may only be specified using source root directories.
  24. </li>
  25. <li>A .class file may only be woven once. That means
  26. binaries in injars or aspectjpath must have been compiled with jikes or javac
  27. or, if using ajc, with noweave.
  28. </li>
  29. </ul>
  30. This task is named <tt>iajc</tt> now to avoid conflict with the
  31. 1.0 task <tt>ajc</tt>, but the name may change to <tt>ajc</tt> in
  32. the future.
  33. <p>
  34. See <a href="#compilerMessages">below</a> for
  35. an introduction to handling compiler messages programmatically.
  36. <p>
  37. <h3>
  38. Parameters</h3>
  39. <h4>Parameters supported by <code>ajc</code></h4>
  40. <table BORDER CELLSPACING=0 CELLPADDING=2 >
  41. <tr>
  42. <td VALIGN=TOP><b>Attribute</b></td>
  43. <td VALIGN=TOP><b>Description</b></td>
  44. <td ALIGN=CENTER VALIGN=TOP><b>Required</b></td>
  45. </tr>
  46. <tr>
  47. <th colspan="3">Specifying source and destination files</th>
  48. </tr>
  49. <td VALIGN=TOP>sourceroots</td>
  50. <td VALIGN=TOP>a list of base directories of the source files.
  51. All source files (.java and .aj) in the base directories are compiled.
  52. May also be specified as a <a href="nestedElements">nested element</a>.
  53. </td>
  54. <td ALIGN=CENTER VALIGN=TOP>Yes, in incremental mode.</td>
  55. </tr>
  56. <tr>
  57. <td VALIGN=TOP>outjar</td>
  58. <td VALIGN=TOP>Path to an output jar to generate with all output classes.</td>
  59. <td ALIGN=CENTER VALIGN=TOP>No</td>
  60. </tr>
  61. <tr>
  62. <td VALIGN=TOP>destdir</td>
  63. <td VALIGN=TOP>Specify where to place the generated class files.</td>
  64. <td ALIGN=CENTER VALIGN=TOP>No</td>
  65. </tr>
  66. <tr>
  67. <td VALIGN=TOP>classpath</td>
  68. <td VALIGN=TOP>the classpath required by the source files to compile.
  69. May also be specified as a <a href="nestedElements">nested element</a>.
  70. </td>
  71. <td ALIGN=CENTER VALIGN=TOP>No</td>
  72. </tr>
  73. <tr>
  74. <td VALIGN=TOP>srcdir</td>
  75. <td VALIGN=TOP>the nested source base directory to compile,
  76. specified as a <a href="nestedElements">nested element</a>.
  77. </td>
  78. <td ALIGN=CENTER VALIGN=TOP>No</td>
  79. </tr>
  80. <tr>
  81. <td VALIGN=TOP>aspectpath</td>
  82. <td VALIGN=TOP>the aspectpath to use -- like classpath, only for
  83. read-only, binary aspect libraries (only accepts jar/zip files, no directories).
  84. May also be specified as a <a href="nestedElements">nested element</a>.
  85. </td>
  86. <td ALIGN=CENTER VALIGN=TOP>No</td>
  87. </tr>
  88. <tr>
  89. <td VALIGN=TOP>bootclasspath</td>
  90. <td VALIGN=TOP>location of bootstrap class files.</td>
  91. <td ALIGN=CENTER VALIGN=TOP>No</td>
  92. </tr>
  93. <tr>
  94. <td VALIGN=TOP>classpathref</td>
  95. <td VALIGN=TOP>the classpath to use, given as a<a href="http://jakarta.apache.org/ant/manual/using.html#references">
  96. reference</a> to a PATH defined elsewhere.</td>
  97. <td ALIGN=CENTER VALIGN=TOP>No</td>
  98. </tr>
  99. <tr>
  100. <td VALIGN=TOP>bootclasspathref</td>
  101. <td VALIGN=TOP>location of bootstrap class files, given as a <a href="http://jakarta.apache.org/ant/manual/using.html#references">reference</a>
  102. to a PATH defined elsewhere.</td>
  103. <td ALIGN=CENTER VALIGN=TOP>No</td>
  104. </tr>
  105. <tr>
  106. <th colspan="3">Specifying compiler behavior</th>
  107. </tr>
  108. <tr>
  109. <td VALIGN=TOP>noweave</td>
  110. <td VALIGN=TOP>If true, produce binaries for the -injars option (only) --
  111. defaults to <tt>false</tt>.</td>
  112. <td ALIGN=CENTER VALIGN=TOP>No</td>
  113. </tr>
  114. <tr>
  115. <td VALIGN=TOP>incremental</td>
  116. <td VALIGN=TOP>build once, then recompile on demand only required files;
  117. defaults to <tt>false</tt>.
  118. By default, files are recompiled based on input passed to stdin
  119. (see tagfile)</td>
  120. <td ALIGN=CENTER VALIGN=TOP>No</td>
  121. </tr>
  122. <tr>
  123. <td VALIGN=TOP>tagfile</td>
  124. <td VALIGN=TOP>File that controls when incremental builds are done
  125. and when the task completes.</td>
  126. <td ALIGN=CENTER VALIGN=TOP>No</td>
  127. </tr>
  128. <tr>
  129. <td VALIGN=TOP>X</td>
  130. <td VALIGN=TOP>Set experimental option(s), using comma-separated list
  131. of accepted options (unlisted here -- for XLint, use
  132. the xlint entries). Options should not contain the leading X.</td> <!-- XXX list -->
  133. <td ALIGN=CENTER VALIGN=TOP>No</td>
  134. </tr>
  135. <tr>
  136. <th colspan="3">Specifying compiler side-effects and messages</th>
  137. </tr>
  138. <tr>
  139. <td VALIGN=TOP>emacssym</td>
  140. <td VALIGN=TOP>whether to emit <tt>.ajesym</tt> symbol files for Emacs support;
  141. defaults to <tt>false</tt>.</td>
  142. <td ALIGN=CENTER VALIGN=TOP>No</td>
  143. </tr>
  144. <tr>
  145. <td VALIGN=TOP>verbose</td>
  146. <td VALIGN=TOP>whether to emit compiler status messages during the compile;
  147. defaults to <tt>false</tt>.</td>
  148. <td ALIGN=CENTER VALIGN=TOP>No</td>
  149. </tr>
  150. <tr>
  151. <td VALIGN=TOP>version</td>
  152. <td VALIGN=TOP>if true, do not compile - just print AspectJ version;
  153. defaults to <tt>false</tt>.</td>
  154. <td ALIGN=CENTER VALIGN=TOP>No</td>
  155. </tr>
  156. <tr>
  157. <td VALIGN=TOP>help</td>
  158. <td VALIGN=TOP>if true, just print help for the command-line compiler;
  159. defaults to <tt>false</tt>.</td>
  160. <td ALIGN=CENTER VALIGN=TOP>No</td>
  161. </tr>
  162. <tr>
  163. <td VALIGN=TOP>Xlintenabled</td>
  164. <td VALIGN=TOP>same as <tt>xlint:all</tt>,
  165. whether to emit language usage messages during the compile;
  166. defaults to <tt>false</tt>.</td>
  167. <td ALIGN=CENTER VALIGN=TOP>No</td>
  168. </tr>
  169. <tr>
  170. <td VALIGN=TOP>Xlintfile</td>
  171. <td VALIGN=TOP>specify property file containing name:level associations
  172. for any overrides to the default associations for language usage
  173. messaged emitted during the compile.</td>
  174. <td ALIGN=CENTER VALIGN=TOP>No</td>
  175. </tr>
  176. <!--
  177. <tr>
  178. <td VALIGN=TOP>Xlint</td>
  179. <td VALIGN=TOP>Specify which language usage messages to emit
  180. during compile, using comma-separated list of entries.
  181. <td ALIGN=CENTER VALIGN=TOP>No</td>
  182. </tr>
  183. -->
  184. <tr>
  185. <td VALIGN=TOP>failonerror</td>
  186. <td VALIGN=TOP>whether the build continues notwithstanding compile errors;
  187. defaults to <tt>true</tt>.&nbsp;</td>
  188. <td ALIGN=CENTER VALIGN=TOP>No</td>
  189. </tr>
  190. <tr>
  191. <td VALIGN=TOP>messageholderclass</td>
  192. <td VALIGN=TOP>Specify a class to use as the message holder for the compile
  193. process. The entry must be a fully-qualified name of a class resolveable
  194. from the task classpath complying with the <tt>org.aspectj.bridge.IMessageHolder</tt>
  195. interface and having a public no-argument constructor.</td>
  196. <td ALIGN=CENTER VALIGN=TOP>No</td>
  197. </tr>
  198. <tr>
  199. <th colspan="3">Eclipse compiler options</th>
  200. </tr>
  201. <tr>
  202. <td VALIGN=TOP>nowarn</td>
  203. <td VALIGN=TOP>same as <tt>warn:none</tt>;
  204. defaults to <tt>false</tt>.&nbsp;</td>
  205. <td ALIGN=CENTER VALIGN=TOP>No</td>
  206. </tr>
  207. <tr>
  208. <td VALIGN=TOP>deprecation</td>
  209. <td VALIGN=TOP>same as <tt>warn:deprecation</tt>;
  210. defaults to <tt>false</tt>.&nbsp;</td>
  211. <td ALIGN=CENTER VALIGN=TOP>No</td>
  212. </tr>
  213. <tr>
  214. <td VALIGN=TOP>warn</td>
  215. <td VALIGN=TOP>one or more comma-separated warning specifications:
  216. <tt>constructorName</tt>,
  217. <tt>packageDefaultMethod</tt>,
  218. <tt>deprecation</tt>,
  219. <tt>maskedCatchBlocks</tt>,
  220. <tt>unusedLocals</tt>,
  221. <tt>unusedArguments</tt>,
  222. <tt>unusedImports</tt>,
  223. <tt>syntheticAccess</tt>, or
  224. <tt>assertIdentifier</tt>.</td>
  225. <td ALIGN=CENTER VALIGN=TOP>No</td>
  226. </tr>
  227. <tr>
  228. <td VALIGN=TOP>debug</td>
  229. <td VALIGN=TOP>same as <tt>debug:lines,vars,source</tt></td>
  230. <td ALIGN=CENTER VALIGN=TOP>No</td>
  231. </tr>
  232. <tr>
  233. <td VALIGN=TOP>debuglevel</td>
  234. <td VALIGN=TOP>one or more comma-separated debug specifications:
  235. <tt>lines</tt>,
  236. <tt>vars</tt>, or
  237. <tt>source</tt>.
  238. </td>
  239. <td ALIGN=CENTER VALIGN=TOP>No</td>
  240. </tr>
  241. <tr>
  242. <td VALIGN=TOP>PreserveAllLocals</td>
  243. <td VALIGN=TOP>code gen preserves all local variables (for debug purposes);
  244. defaults to <tt>false</tt>.&nbsp;</td>
  245. <td ALIGN=CENTER VALIGN=TOP>No</td>
  246. </tr>
  247. <tr>
  248. <td VALIGN=TOP>noimporterror</td>
  249. <td VALIGN=TOP>no errors for unresolved imports;
  250. defaults to <tt>false</tt>.&nbsp;</td>
  251. <td ALIGN=CENTER VALIGN=TOP>No</td>
  252. </tr>
  253. <tr>
  254. <td VALIGN=TOP>referenceinfo</td>
  255. <td VALIGN=TOP>compute reference info;
  256. defaults to <tt>false</tt>.&nbsp;</td>
  257. <td ALIGN=CENTER VALIGN=TOP>No</td>
  258. </tr>
  259. <tr>
  260. <td VALIGN=TOP>log</td>
  261. <td VALIGN=TOP>File to log compiler messages to.</td>
  262. <td ALIGN=CENTER VALIGN=TOP>No</td>
  263. </tr>
  264. <tr>
  265. <td VALIGN=TOP>encoding</td>
  266. <td VALIGN=TOP>default source encoding format</td>
  267. <td ALIGN=CENTER VALIGN=TOP>No</td>
  268. </tr>
  269. <tr>
  270. <td VALIGN=TOP>proceedonerror</td>
  271. <td VALIGN=TOP>keep compiling when error, dumping class files with problem methods;
  272. defaults to <tt>false</tt>.&nbsp;</td>
  273. <td ALIGN=CENTER VALIGN=TOP>No</td>
  274. </tr>
  275. <tr>
  276. <td VALIGN=TOP>progress</td>
  277. <td VALIGN=TOP>show progress (requires log);
  278. defaults to <tt>false</tt>.&nbsp;</td>
  279. <td ALIGN=CENTER VALIGN=TOP>No</td>
  280. </tr>
  281. <tr>
  282. <td VALIGN=TOP>time</td>
  283. <td VALIGN=TOP>display speed information;
  284. defaults to <tt>false</tt>.&nbsp;</td>
  285. <td ALIGN=CENTER VALIGN=TOP>No</td>
  286. </tr>
  287. <!--
  288. <tr>
  289. <td VALIGN=TOP>noexit</td>
  290. <td VALIGN=TOP>disable System.exit; defaults to <tt>true</tt>.
  291. (<em>If false, this kills the Ant process</em>;
  292. to halt compile gracefully, use <tt>failonerror</tt>);
  293. &nbsp;</td>
  294. <td ALIGN=CENTER VALIGN=TOP>No</td>
  295. </tr>
  296. -->
  297. <tr>
  298. <td VALIGN=TOP>target</td>
  299. <td VALIGN=TOP>Specify target class file format (must be "1.1" or "1.2");
  300. defaults to 1.1 class file.&nbsp;</td>
  301. <td ALIGN=CENTER VALIGN=TOP>No</td>
  302. </tr>
  303. <tr>
  304. <td VALIGN=TOP>compliance</td>
  305. <td VALIGN=TOP>Set "1.3" or "1.4" source compliance level
  306. (e.g., no import from default package in 1.4);
  307. defaults to 1.3 compliance level.&nbsp;</td>
  308. <td ALIGN=CENTER VALIGN=TOP>No</td>
  309. </tr>
  310. <tr>
  311. <td VALIGN=TOP>source</td>
  312. <td VALIGN=TOP>source assertion mode ("1.3" or "1.4");
  313. default depends on compliance mode.&nbsp;</td>
  314. <td ALIGN=CENTER VALIGN=TOP>No</td>
  315. </tr>
  316. </table>
  317. <a name="nestedElements"></a>
  318. <h3>Nested Elements</h3>
  319. This taskdef should support nested elements as the old one did;
  320. see <a href="taskdef-ajc10.html#nestedElements">taskdef-ajc10.html#nestedElements</a>.
  321. <a name="compilerMessages"></>
  322. <h3>Programmatically handling compiler messages</h3>
  323. Users may specify a message holder which is passed all
  324. messages generated by the compiler synchronously. This overrides all of the normal
  325. message printing, but does not prevent the task from failing if failonerror is true
  326. and errors or exceptions were encountered.
  327. Handling messages programmatically could be useful
  328. when using the compiler to inspect code.
  329. If aspects consist of declare [error|warning], then
  330. the compiler can act to detect invariants in the code being processed.
  331. For code to compare expected and actual messages, see the AspectJ
  332. testing module (which is not included in the binary distribution).
  333. <hr>
  334. <center>
  335. </center>
  336. </body>
  337. </html>