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.

antsupport.xml 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. <chapter id="antTasks" xreflabel="AspectJ Ant Tasks">
  2. <title>AspectJ Ant Tasks</title>
  3. <sect1 id="antTasks-intro">
  4. <title>Introduction</title>
  5. <para>
  6. AspectJ contains a compiler, <literal>ajc</literal>,
  7. that can be run from Ant.
  8. Included in the <literal>aspectjtools.jar</literal>
  9. are Ant binaries to support three
  10. ways of running the compiler:
  11. <orderedlist>
  12. <listitem>
  13. <para>
  14. <xref linkend="antTasks-iajc"/>,
  15. a task to run the AspectJ post-1.1 compiler,
  16. which supports all the eclipse and ajc options, including incremental mode.
  17. </para>
  18. </listitem>
  19. <listitem>
  20. <para>
  21. <xref linkend="antTasks-adapter"/>,
  22. an adapter class to run the new compiler using Javac tasks
  23. by setting the build.compiler property
  24. </para>
  25. </listitem>
  26. <listitem>
  27. <para>
  28. <xref linkend="antTasks-ajc"/>,
  29. a task to run build scripts compatible with the AspectJ 1.0 tasks
  30. </para>
  31. </listitem>
  32. </orderedlist>
  33. </para>
  34. <para>
  35. This describes how to install and use the tasks and the adapter.
  36. For an example Ant script, see
  37. <ulink url="../examples/build.xml">examples/build.xml</ulink>.
  38. </para>
  39. </sect1>
  40. <!-- . . . . . . . . . . . . . . . . . . . . . . . . . . . install -->
  41. <sect1 id="antTasks-install" xreflabel="Installing Ant Tasks">
  42. <title>Installing Ant Tasks</title>
  43. <para>
  44. Install Jakarta Ant 1.5.1:
  45. Please see the official Jakarta Ant website for more information
  46. and the 1.5.1 distribution. This release is source-compatible
  47. with Ant 1.3 and Ant 1.4, but the task sources must be
  48. compiled with those versions of the Ant libraries to be used
  49. under those versions of Ant.
  50. Sources are available under the Eclipse Public License v. 1.0
  51. at <ulink url="http://eclipse.org/aspectj">http://eclipse.org/aspectj</ulink>.
  52. </para>
  53. <para>
  54. In Ant 1.5, third-party tasks can be declared using a taskdef entry in
  55. the build script, to identify the name and classes.
  56. When declaring a task, include the
  57. <literal>aspectjtools.jar</literal> either in the
  58. taskdef classpath or in <literal>${ANT_HOME}/lib</literal> where it will be added
  59. to the system class path by the ant script.
  60. You may specify the task script names directly,
  61. or use the "resource" attribute to specify the default names:
  62. </para>
  63. <programlisting>
  64. <![CDATA[
  65. <taskdef
  66. resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
  67. ]]>
  68. </programlisting>
  69. <para>
  70. The current resource file retains the name "ajc" for the Ajc10 task,
  71. and uses "iajc" for the AspectJ post-1.1 task.
  72. </para>
  73. <para>
  74. In Ant 1.6, third-party tasks are declared in their own namespace
  75. using <literal>antlib.xml</literal>. For example, the following
  76. script would build and run the spacewar example, if you put the
  77. script in the examples directory and <literal>aspectjtools.jar</literal>
  78. in the <literal>${ANT_HOME}/lib</literal> directory.
  79. </para>
  80. <programlisting>
  81. <![CDATA[
  82. <project name="aspectj-ant1.6" default="spacewar"
  83. xmlns:aspectj="antlib:org.aspectj" basedir=".">
  84. <target name="spacewar">
  85. <aspectj:iajc
  86. argfiles="spacewar/debug.lst"
  87. outjar="spacewar.jar"
  88. classpath="../../lib/aspectjrt.jar"
  89. />
  90. <java classname="spacewar.Game"
  91. classpath="spacewar.jar:../../lib/aspectjrt.jar"/>
  92. </target>
  93. </project>
  94. ]]>
  95. </programlisting>
  96. <para>
  97. For more information on using Ant, please refer to Jakarta's
  98. documentation on integrating user-defined Ant tasks into builds.
  99. </para>
  100. </sect1>
  101. <!-- . . . . . . . . . . . . . . . . . . . . . . . . . . . iajc -->
  102. <sect1 id="antTasks-iajc" xreflabel="AjcTask (iajc)">
  103. <title>AjcTask (iajc)</title>
  104. <para>
  105. This task uses the AspectJ post-1.1 compiler ajc.
  106. The AspectJ compiler can be used like Javac to compile Java sources,
  107. but it can also compile AspectJ sources or weave binary aspects
  108. with Java bytecode.
  109. It can run in normal "batch" mode or in an "incremental" mode,
  110. where it only recompiles files it has to revisit.
  111. For more information on ajc, see <xref linkend="ajc-ref"/>.
  112. Unlike Javac or the Javac Ant task, this task always compiles the
  113. specified files since aspects can apply to other (updated) files.
  114. For a workaround, see <xref linkend="antTasks-iajc-uptodate"/>.
  115. </para>
  116. <para>
  117. Beyond the normal ajc compiler options, this task also supports
  118. an experimental option for an incremental "tag" file, and it
  119. can copy resources from source directories or
  120. input jars to the output jar or directory.
  121. </para>
  122. <para>
  123. This task is named iajc to avoid conflict with the 1.0 task ajc.
  124. </para>
  125. <sect2 id="antTasks-iajc-options" xreflabel="AjcTask (iajc) Options">
  126. <title>AjcTask (iajc) Options</title>
  127. <para>
  128. The following tables list the supported parameters.
  129. For any parameter specified as a Path, a single path can be
  130. specified directly as an attribute,
  131. multiple paths can be specified using a nested element of
  132. the same name, and a common path can be reused by defining it as a
  133. global and passing the id to the corresponding {name}ref attribute.
  134. See <xref linkend="antTasks-iajc-paths"/>
  135. below for more details.
  136. </para>
  137. <para>
  138. Most attributes and nested elements are optional.
  139. The compiler requires that the same version of
  140. <literal>aspectjrt.jar</literal>
  141. be specified on the classpath, and that some sources be
  142. be specified
  143. (using one or more of
  144. <literal>sourceroots</literal>,
  145. <literal>injars</literal>,
  146. <literal>inpath</literal>,
  147. <literal>argfiles</literal>, and/or
  148. <literal>srcdir</literal> (with patterns)).
  149. When in incremental mode, only
  150. <literal>sourceroots</literal> may be specified.
  151. </para>
  152. <para>Boolean parameters default to <literal>false</literal>
  153. unless otherwise stated.
  154. </para>
  155. <!-- . . . . . . . . . . . . . . . . iajc options table -->
  156. <!-- table (and caption/title) not supported by fop -->
  157. <para>
  158. <emphasis role="strong">
  159. AjcTask (iajc) options for specifying sources
  160. </emphasis>
  161. </para>
  162. <informaltable>
  163. <tgroup cols="2">
  164. <thead>
  165. <row>
  166. <entry>Attribute</entry>
  167. <entry>Description</entry>
  168. </row>
  169. </thead>
  170. <tbody>
  171. <row>
  172. <entry><para>argfiles, argfilesRef
  173. (<xref linkend="antTasks-iajc-paths"/>)
  174. </para></entry>
  175. <entry><para>
  176. An argument file contains a list of arguments read by the compiler.
  177. Each line is read into one element of the argument array
  178. and may include another argfile by reference.
  179. </para></entry>
  180. </row>
  181. <row>
  182. <entry><para>sourceRoots, sourceRootsRef
  183. (<xref linkend="antTasks-iajc-paths"/>)
  184. </para></entry>
  185. <entry><para>
  186. Directories containing source files (ending with .java or .aj) to compile.
  187. </para></entry>
  188. </row>
  189. <row>
  190. <entry><para>srcdir
  191. (<xref linkend="antTasks-iajc-paths"/>)
  192. </para></entry>
  193. <entry><para>
  194. Base directory of sources to compile, assuming there are
  195. <xref linkend="antTasks-nested-includes"/>.
  196. This approach uses the Ant process
  197. for matching .java files and is not compatible with incremental
  198. mode. Unless using filters to limit the sources included,
  199. use sourceroots instead.
  200. </para></entry>
  201. </row>
  202. <row>
  203. <entry><para>injars, injarsRef
  204. (<xref linkend="antTasks-iajc-paths"/>)
  205. </para></entry>
  206. <entry><para>
  207. Deprecated - use inpath instead.
  208. Read .class files for bytecode weaving
  209. from zip files (only).
  210. </para></entry>
  211. </row>
  212. <row>
  213. <entry><para>inpath, inpathRef
  214. (<xref linkend="antTasks-iajc-paths"/>)
  215. </para></entry>
  216. <entry><para>
  217. Read .class files for bytecode weaving
  218. from directories or zip files (like classpath).
  219. </para></entry>
  220. </row>
  221. <row>
  222. <entry><para>classpath, classpathRef
  223. (<xref linkend="antTasks-iajc-paths"/>)
  224. </para></entry>
  225. <entry><para>
  226. The classpath used by the sources being compiled.
  227. When compiling aspects, include the same version of the
  228. <literal>aspectjrt.jar</literal>.
  229. </para></entry>
  230. </row>
  231. <row>
  232. <entry><para>bootclasspath, bootclasspathRef
  233. (<xref linkend="antTasks-iajc-paths"/>)
  234. </para></entry>
  235. <entry><para>
  236. The bootclasspath specifies types to use instead of the
  237. invoking VM's when seeking types during compilation.
  238. </para></entry>
  239. </row>
  240. <row>
  241. <entry><para>extDirs, extDirsRef
  242. (<xref linkend="antTasks-iajc-paths"/>)
  243. </para></entry>
  244. <entry><para>
  245. The extension directories to use instead of those in the
  246. invoking VM when seeking types during compilation.
  247. </para></entry>
  248. </row>
  249. <row>
  250. <entry><para>aspectPath, aspectPathRef
  251. (<xref linkend="antTasks-iajc-paths"/>)
  252. </para></entry>
  253. <entry><para>
  254. Similar to classpath, aspectpath contains read-only,
  255. binary aspect libraries that are woven into sources
  256. but not included in the output.
  257. <literal>aspectpath</literal> accepts jar/zip files
  258. (but, unlike classpath, not directories).
  259. </para></entry>
  260. </row>
  261. </tbody>
  262. </tgroup>
  263. </informaltable>
  264. <para>
  265. <emphasis role="strong">
  266. AjcTask (iajc) options for specifying output
  267. </emphasis>
  268. </para>
  269. <informaltable>
  270. <tgroup cols="2">
  271. <thead>
  272. <row>
  273. <entry>Attribute</entry>
  274. <entry>Description</entry>
  275. </row>
  276. </thead>
  277. <tbody>
  278. <row>
  279. <entry><para>destDir
  280. </para></entry>
  281. <entry><para>
  282. The directory in which to place the generated class files.
  283. Only one of <literal>destDir</literal> and
  284. <literal>outJar</literal> may be set.
  285. </para></entry>
  286. </row>
  287. <row>
  288. <entry><para>outJar
  289. </para></entry>
  290. <entry><para>
  291. The zip file in which to place the generated output class files.
  292. Only one of <literal>destDir</literal> and
  293. <literal>outJar</literal> may be set.
  294. </para></entry>
  295. </row>
  296. <row>
  297. <entry><para>copyInjars
  298. </para></entry>
  299. <entry><para>
  300. (Deprecated/ignored; ajc does this.)
  301. If true, copy all non-.class files from input jar(s)
  302. to the output jar or destination directory after the
  303. compile (or incremental compile) completes.
  304. In forked mode, this copies only after the process
  305. completes, not after incremental compiles.
  306. </para></entry>
  307. </row>
  308. <row>
  309. <entry><para>sourceRootCopyFilter
  310. </para></entry>
  311. <entry><para>
  312. When set, copy all files from the sourceroot directories to the output jar
  313. or destination directory except those specified in the filter pattern.
  314. The pattern should be compatible with an Ant fileset excludes filter;
  315. when using this, most developers pass
  316. <literal>**/CVS/*,**/*.java</literal> to exclude any CVS directories
  317. or source files.
  318. See <literal>inpathDirCopyFilter</literal>.
  319. Requires <literal>destDir</literal> or <literal>outJar</literal>.
  320. </para></entry>
  321. </row>
  322. <row>
  323. <entry><para>inpathDirCopyFilter
  324. </para></entry>
  325. <entry>
  326. <para> When set, copy all files from the inpath directories
  327. to the output jar or destination directory except those
  328. specified in the filter pattern. The pattern should be
  329. compatible with an Ant fileset excludes filter; when
  330. using this, most developers pass
  331. <literal>**/CVS/*,**/*.java,**/*.class</literal> to
  332. exclude any CVS directories, source files, or unwoven
  333. .class files. (If <literal>**/*.class</literal> is not
  334. specified, it will be prepended to the filter.) See
  335. <literal>sourceRootCopyFilter</literal>. (Note that ajc
  336. itself copies all resources from input jar/zip files on
  337. the inpath.) Requires <literal>destDir</literal> or
  338. <literal>outJar</literal>.</para>
  339. </entry>
  340. </row>
  341. </tbody>
  342. </tgroup>
  343. </informaltable>
  344. <para>
  345. <emphasis role="strong">
  346. AjcTask (iajc) options for specifying compiler behavior
  347. </emphasis>
  348. </para>
  349. <informaltable>
  350. <tgroup cols="2">
  351. <thead>
  352. <row>
  353. <entry>Attribute</entry>
  354. <entry>Description</entry>
  355. </row>
  356. </thead>
  357. <tbody>
  358. <row>
  359. <entry><para>fork
  360. </para></entry>
  361. <entry><para>
  362. Run process in another VM.
  363. This gets the forking classpath either explicitly
  364. from a <literal>forkclasspath</literal> entry
  365. or by searching the task or system/Ant classpath for the
  366. first readable file with a name of the form
  367. <literal>aspectj{-}tools{.*}.jar</literal>.
  368. When forking you can specify the amount of memory used
  369. with <literal>maxmem</literal>.
  370. Fork cannot be used in incremental mode,
  371. unless using a tag file.
  372. </para></entry>
  373. </row>
  374. <row>
  375. <entry><para>forkclasspath, forkclasspathRef
  376. (<xref linkend="antTasks-iajc-paths"/>)
  377. </para></entry>
  378. <entry><para>
  379. Specify the classpath to use for the compiler when forking.
  380. </para></entry>
  381. </row>
  382. <row>
  383. <entry><para>maxmem
  384. </para></entry>
  385. <entry><para>
  386. The maximum memory to use for the new VM when fork is true.
  387. Values should have the same form as accepted by the VM, e.g., "128m".
  388. </para></entry>
  389. </row>
  390. <row>
  391. <entry><para>incremental
  392. </para></entry>
  393. <entry><para>
  394. incremental mode: Build once, then recompile only required source
  395. files when user provides input.
  396. Requires that source files be specified only using
  397. <literal>sourceroots</literal>.
  398. Incompatible with forking.
  399. </para></entry>
  400. </row>
  401. <row>
  402. <entry><para>tagfile
  403. </para></entry>
  404. <entry><para>
  405. incremental mode: Build once, then recompile only required source
  406. files when the tag file is updated, finally exiting when tag file
  407. is deleted.
  408. Requires that source files be specified only using
  409. <literal>sourceroots</literal>.
  410. </para></entry>
  411. </row>
  412. <row>
  413. <entry><para>X
  414. </para></entry>
  415. <entry><para>
  416. Set experimental option(s), using comma-separated list of accepted options
  417. Options should not contain the leading X.
  418. Some commonly-used experimental options have their
  419. own entries. The other permitted ones (currently) are
  420. serializableAspects, incrementalFile, lazyTjp,
  421. reweavable, notReweavable, noInline,
  422. terminateAfterCompilation,
  423. ajruntimelevel:1.2, and ajruntimelevel:1.5.
  424. Of these, some were deprecated in AspectJ 5
  425. (reweavable, terminateAfterCompilation, etc.).
  426. </para></entry>
  427. </row>
  428. <row>
  429. <entry><para>XterminateAfterCompilation
  430. </para></entry>
  431. <entry><para>
  432. Terminates before the weaving process, dumping out unfinished class files.
  433. </para></entry>
  434. </row>
  435. </tbody>
  436. </tgroup>
  437. </informaltable>
  438. <para>
  439. <emphasis role="strong">
  440. AjcTask (iajc) options for specifying compiler side-effects and messages
  441. </emphasis>
  442. </para>
  443. <informaltable>
  444. <tgroup cols="2">
  445. <thead>
  446. <row>
  447. <entry>Attribute</entry>
  448. <entry>Description</entry>
  449. </row>
  450. </thead>
  451. <tbody>
  452. <row>
  453. <entry><para>emacssym
  454. </para></entry>
  455. <entry><para>
  456. If true, emit <literal>.ajesym</literal> symbol files for Emacs support.
  457. </para></entry>
  458. </row>
  459. <row>
  460. <entry><para>crossref
  461. </para></entry>
  462. <entry><para>
  463. If true, emit <literal>.ajsym</literal> file into the output directory.
  464. </para></entry>
  465. </row>
  466. <row>
  467. <entry><para>verbose
  468. </para></entry>
  469. <entry><para>
  470. If true, emit compiler status messages during the compile.
  471. </para></entry>
  472. </row>
  473. <row>
  474. <entry><para>Xlistfileargs
  475. </para></entry>
  476. <entry><para>
  477. If true, emit list of file arguments during
  478. the compile (but behaves now like verbose).
  479. </para></entry>
  480. </row>
  481. <row>
  482. <entry><para>version
  483. </para></entry>
  484. <entry><para>
  485. If true, do not compile - just print AspectJ version.
  486. </para></entry>
  487. </row>
  488. <row>
  489. <entry><para>help
  490. </para></entry>
  491. <entry><para>
  492. If true, just print help for the command-line compiler.
  493. </para></entry>
  494. </row>
  495. <row>
  496. <entry><para>Xlintwarnings
  497. </para></entry>
  498. <entry><para>
  499. Same as <literal>xlint:warning</literal>:
  500. if true, set default level of all language
  501. usage messages to warning.
  502. </para></entry>
  503. </row>
  504. <row>
  505. <entry><para>Xlint
  506. </para></entry>
  507. <entry><para>
  508. Specify default level of all language usage messages to one of
  509. [<literal>error warning ignore</literal>].
  510. </para></entry>
  511. </row>
  512. <row>
  513. <entry><para>XlintFile
  514. </para></entry>
  515. <entry><para>
  516. Specify property file containing <literal>name:level</literal> associations
  517. setting level for language messages emitted during compilation.
  518. Any levels set override the default associations in
  519. <literal>org/aspectj/weaver/XLintDefault.properties</literal>.
  520. </para></entry>
  521. </row>
  522. <row>
  523. <entry><para>failonerror
  524. </para></entry>
  525. <entry><para>
  526. If true, throw BuildException to halt build if there
  527. are any compiler errors.
  528. If false, continue notwithstanding compile errors.
  529. Defaults to <literal>true</literal>.
  530. </para></entry>
  531. </row>
  532. <row>
  533. <entry><para>messageHolderClass
  534. </para></entry>
  535. <entry><para>
  536. Specify a class to use as the message holder for the compile process.
  537. The entry must be a fully-qualified name of a class resolveable from
  538. the task classpath complying with the
  539. <literal>org.aspectj.bridge.IMessageHolder</literal> interface
  540. and having a public no-argument constructor.
  541. </para></entry>
  542. </row>
  543. <row>
  544. <entry><para>showWeaveInfo
  545. </para></entry>
  546. <entry><para>
  547. If true, emit weaver messages.
  548. Defaults to <literal>false</literal>.
  549. </para></entry>
  550. </row>
  551. </tbody>
  552. </tgroup>
  553. </informaltable>
  554. <para>
  555. <emphasis role="strong">
  556. AjcTask (iajc) options for specifying Eclipse compiler options
  557. </emphasis>
  558. </para>
  559. <informaltable>
  560. <tgroup cols="2">
  561. <thead>
  562. <row>
  563. <entry>Attribute</entry>
  564. <entry>Description</entry>
  565. </row>
  566. </thead>
  567. <tbody>
  568. <row>
  569. <entry><para>nowarn
  570. </para></entry>
  571. <entry><para>
  572. If true, same as <literal>warn:none</literal>.
  573. </para></entry>
  574. </row>
  575. <row>
  576. <entry><para>deprecation
  577. </para></entry>
  578. <entry><para>
  579. If true, same as <literal>warn:deprecation</literal>
  580. </para></entry>
  581. </row>
  582. <row>
  583. <entry><para>warn
  584. </para></entry>
  585. <entry><para>
  586. One or more comma-separated warning specifications from
  587. [<literal>constructorName packageDefaultMethod deprecation,
  588. maskedCatchBlocks unusedLocals unusedArguments,
  589. unusedImports syntheticAccess assertIdentifier</literal>].
  590. </para></entry>
  591. </row>
  592. <row>
  593. <entry><para>debug
  594. </para></entry>
  595. <entry><para>
  596. If true, same as <literal>debug:lines,vars,source</literal>
  597. </para></entry>
  598. </row>
  599. <row>
  600. <entry><para>debugLevel
  601. </para></entry>
  602. <entry><para>
  603. One or more comma-separated debug specifications from
  604. [<literal>lines vars source</literal>].
  605. </para></entry>
  606. </row>
  607. <row>
  608. <entry><para>PreserveAllLocals
  609. </para></entry>
  610. <entry><para>
  611. If true, code gen preserves all local variables (for debug purposes).
  612. </para></entry>
  613. </row>
  614. <row>
  615. <entry><para>noimporterror
  616. </para></entry>
  617. <entry><para>
  618. If true, emit no errors for unresolved imports.
  619. </para></entry>
  620. </row>
  621. <row>
  622. <entry><para>referenceinfo
  623. </para></entry>
  624. <entry><para>
  625. If true, compute reference info.
  626. </para></entry>
  627. </row>
  628. <row>
  629. <entry><para>log
  630. </para></entry>
  631. <entry><para>
  632. File to log compiler messages to.
  633. </para></entry>
  634. </row>
  635. <row>
  636. <entry><para>encoding
  637. </para></entry>
  638. <entry><para>Default source encoding format
  639. (per-file encoding not supported in Ant tasks).
  640. </para></entry>
  641. </row>
  642. <row>
  643. <entry><para>proceedOnError
  644. </para></entry>
  645. <entry><para>
  646. If true, keep compiling after errors encountered,
  647. dumping class files with problem methods.
  648. </para></entry>
  649. </row>
  650. <row>
  651. <entry><para>progress
  652. </para></entry>
  653. <entry><para>
  654. If true, emit progress (requires log).
  655. </para></entry>
  656. </row>
  657. <row>
  658. <entry><para>time
  659. </para></entry>
  660. <entry><para>
  661. If true, display speed information.
  662. </para></entry>
  663. </row>
  664. <row>
  665. <entry><para>target
  666. </para></entry>
  667. <entry><para>
  668. Specify target class file format as one of
  669. [<literal>1.1 1.2</literal>].
  670. Defaults to 1.1 class file.
  671. </para></entry>
  672. </row>
  673. <row>
  674. <entry><para>source
  675. </para></entry>
  676. <entry><para>
  677. Set source compliance level to one of
  678. [<literal>1.3 1.4 1.5</literal>]
  679. (default is 1.4).
  680. 1.3 implies -source 1.3 and -target 1.1.
  681. 1.4 implies -source 1.4 and -target 1.2.
  682. 1.5 implies -source 1.5 and -target 1.5.
  683. </para></entry>
  684. </row>
  685. <row>
  686. <entry><para>source
  687. </para></entry>
  688. <entry><para>
  689. Set source assertion mode to one of
  690. [<literal>1.3 1.4</literal>].
  691. Default depends on compliance mode.
  692. </para></entry>
  693. </row>
  694. </tbody>
  695. </tgroup>
  696. </informaltable>
  697. <!-- . . . . . . . . . . . . . . . . iajc options table -->
  698. </sect2>
  699. <sect2 id="antTasks-nested-includes" xreflabel="nested matches">
  700. <title>AjcTask matching parameters specified as nested elements</title>
  701. <para>
  702. This task forms an implicit FileSet and supports all attributes of
  703. <literal>&lt;fileset&gt;</literal> (dir becomes srcdir) as well as
  704. the nested
  705. <literal>&lt;include&gt;</literal>,
  706. <literal>&lt;exclude&gt;</literal>, and
  707. <literal>&lt;patternset&gt;</literal> elements.
  708. These can be used to specify source files.
  709. However, it is better to use <literal>sourceroots</literal>
  710. to specify source directories unless using filters to exclude
  711. some files from compilation.
  712. </para>
  713. </sect2>
  714. <sect2 id="antTasks-iajc-paths" xreflabel="Path">
  715. <title>AjcTask Path-like Structures</title>
  716. <para>
  717. Some parameters are path-like structures containing one or more
  718. elements; these are
  719. <literal>sourceroots</literal>,
  720. <literal>argfiles</literal>,
  721. <literal>injars</literal>,
  722. <literal>inpath</literal>,
  723. <literal>classpath</literal>,
  724. <literal>bootclasspath</literal>,
  725. <literal>forkclasspath</literal>, and
  726. <literal>aspectpath</literal>.
  727. In all cases, these may be specified as nested elements, something
  728. like this:
  729. </para>
  730. <programlisting>
  731. <![CDATA[
  732. <iajc {attributes..} />
  733. <{name}>
  734. <pathelement path="{first-location}"/>
  735. <pathelement path="{second-location}"/>
  736. ...
  737. <{name}>
  738. ...
  739. </iajc>
  740. ]]>
  741. </programlisting>
  742. <para>
  743. As with other Path-like structures, they may be defined elsewhere
  744. and specified using the refid attribute:
  745. </para>
  746. <programlisting>
  747. <![CDATA[
  748. <path id="aspect.path">
  749. <pathelement path="${home}/lib/persist.jar"/>
  750. <pathelement path="${home}/lib/trace.jar"/>
  751. </path>
  752. ...
  753. <iajc {attributes..} />
  754. <aspectpath refid="aspect.path"/>
  755. ...
  756. </iajc>
  757. ]]>
  758. </programlisting>
  759. <para>
  760. The task also supports an attribute <literal>{name}ref</literal>
  761. for each such parameter. E.g., for <literal>aspectpath</literal>:
  762. </para>
  763. <programlisting>
  764. <![CDATA[
  765. <iajc {attributes..} aspectpathref="aspect.path"/>
  766. ]]>
  767. </programlisting>
  768. </sect2>
  769. <sect2 id="antTasks-iajc-sample" xreflabel="Sample of iajc task">
  770. <title>Sample of iajc task</title>
  771. <para>
  772. A minimal build script defines the task and runs it, specifying the sources:
  773. </para>
  774. <programlisting>
  775. <![CDATA[
  776. <project name="simple-example" default="compile" >
  777. <taskdef
  778. resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
  779. <classpath>
  780. <pathelement location="${home.dir}/tools/aspectj/lib/aspectjtools.jar"/>
  781. </classpath>
  782. </taskdef>
  783. <target name="compile" >
  784. <iajc sourceroots="${home.dir}/ec/project/src"
  785. classpath="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/>
  786. </target>
  787. </project>
  788. ]]>
  789. </programlisting>
  790. <para>
  791. Below is script with most everything in it. The compile process...
  792. </para>
  793. <orderedlist>
  794. <listitem>
  795. <para>Runs in incremental mode, recompiling when the user hits return;
  796. </para>
  797. </listitem>
  798. <listitem>
  799. <para>Reads all the source files from two directories;
  800. </para>
  801. </listitem>
  802. <listitem>
  803. <para>Reads binary .class files from input jar and directory;
  804. </para>
  805. </listitem>
  806. <listitem>
  807. <para>Uses a binary aspect library for persistence;
  808. </para>
  809. </listitem>
  810. <listitem>
  811. <para>Outputs to an application jar; and
  812. </para>
  813. </listitem>
  814. <listitem>
  815. <para>Copies resources from the source directories and binary input
  816. jar and directories to the application jar. </para>
  817. </listitem>
  818. </orderedlist>
  819. <para>
  820. When this target is built, the compiler will build once and then
  821. wait for input from the user.
  822. Messages are printed as usual.
  823. When the user has quit, then this runs the application.
  824. </para>
  825. <!-- if program changed, test in docs/test/antScriptTest -->
  826. <programlisting>
  827. <![CDATA[
  828. <target name="build-test" >
  829. <iajc outjar="${home.dir}/output/application.jar"
  830. sourceRootCopyFilter="**/CVS/*,**/*.java"
  831. inpathDirCopyFilter="**/CVS/*,**/*.java,**/*.class"
  832. incremental="true" >
  833. <sourceroots>
  834. <pathelement location="${home.dir}/ec/project/src"/>
  835. <pathelement location="${home.dir}/ec/project/testsrc"/>
  836. </sourceroots>
  837. <inpath>
  838. <pathelement location="${home.dir}/build/module.jar"/>
  839. <pathelement location="${home.dir}/build/binary-input"/>
  840. </inpath>
  841. <aspectpath>
  842. <pathelement location="${home.dir}/ec/int/persist.jar"/>
  843. </aspectpath>
  844. <classpath>
  845. <pathelement location="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/>
  846. </classpath>
  847. </iajc>
  848. <java classname="org.smart.app.Main">
  849. <classpath>
  850. <pathelement location="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/>
  851. <pathelement location="${home.dir}/ec/int/persist.jar"/>
  852. <pathelement location="${home.dir}/output/application.jar"/>
  853. </classpath>
  854. </java>
  855. </target>
  856. ]]>
  857. </programlisting>
  858. <para>
  859. For an example of a build script,
  860. see <ulink url="../examples/build.xml">
  861. ../examples/build.xml</ulink>.
  862. </para>
  863. </sect2>
  864. <sect2 id="antTasks-iajc-uptodate" xreflabel="Avoiding clean compiles">
  865. <title>Avoiding clean compiles</title>
  866. <para>
  867. Unlike javac, the ajc compiler always processes all input because
  868. new aspects can apply to updated classes and vice-versa.
  869. However, in the case where no files have been updated, there
  870. is no reason to recompile sources. One way to implement that
  871. is with an explicit dependency check using the uptodate task:
  872. </para>
  873. <programlisting>
  874. <![CDATA[
  875. <target name="check.aspects.jar">
  876. <uptodate property="build.unnecessary"
  877. targetfile="${aspects.module-jar}" >
  878. <srcfiles dir="${src1}" includes="**/*.aj"/>
  879. <srcfiles dir="${src2}/" includes="**/*.aj"/>
  880. </uptodate>
  881. </target>
  882. <target name="compile.aspects" depends="prepare,check.aspects.jar"
  883. unless="build.unnecessary">
  884. <iajc ...
  885. ]]>
  886. </programlisting>
  887. <para>
  888. When using this technique, be careful to verify that binary
  889. input jars are themselves up-to-date after they would have been
  890. modified by any build commands.
  891. </para>
  892. </sect2>
  893. <sect2 id="programmatically-handling-compiler-messages" xreflabel="programmatically-handling-compiler-messages">
  894. <title>Programmatically handling compiler messages</title>
  895. <para>
  896. Users may specify a message holder to which the compiler will pass
  897. all messages as they are generated. This will override all of the
  898. normal message printing, but does not prevent the task from failing
  899. if exceptions were thrown or if failonerror is true and the compiler
  900. detected errors in the sources.
  901. </para>
  902. <para>
  903. Handling messages programmatically could be useful when using the
  904. compiler to verify code. If aspects consist of declare [error|warning],
  905. then the compiler can act to detect invariants in the code being
  906. processed. For code to compare expected and actual messages, see the
  907. AspectJ testing module (which is not included in the binary
  908. distribution).
  909. </para>
  910. </sect2>
  911. </sect1>
  912. <!-- . . . . . . . . . . . . . . . . . . . . . . . . . . . adapter -->
  913. <sect1 id="antTasks-adapter" xreflabel="Ajc11CompilerAdapter (javac)">
  914. <title>Ajc11CompilerAdapter (javac)</title>
  915. <para>
  916. This CompilerAdapter can be used in javac task calls by setting the
  917. <literal>build.compiler</literal> property.
  918. This enables users to to easily switch between the Javac and AspectJ
  919. compilers.
  920. However, the Javac task's pruning of source files prevents the
  921. adapter from doing a correct compile in some cases,
  922. so use AjcTask where possible.
  923. </para>
  924. <sect2 id="antTasks-adapter-sample" xreflabel="Sample of compiler adapter">
  925. <title>Sample of compiler adapter</title>
  926. <para>
  927. To build using the adapter, put the
  928. <literal>aspectjtools.jar</literal>
  929. on the system/ant classpath (e.g., in
  930. <literal>${ANT_HOME}/lib</literal>)
  931. and define the
  932. <literal>build.compiler</literal>
  933. property as the fully-qualified name of the class,
  934. <literal>org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter</literal>.
  935. </para>
  936. <para>
  937. The AspectJ compiler should run for any compile using the Javac task
  938. (for options, see the Ant documentation for the Javac task).
  939. For example, the call below passes all out-of-date source files in the
  940. <literal>src/org/aspectj</literal> subdirectories to the
  941. <literal>ajc</literal> command along with the destination directory:
  942. </para>
  943. <programlisting>
  944. <![CDATA[
  945. -- command:
  946. cp aspectj1.1/lib/aspectjtools.jar ant/lib
  947. ant/bin/ant -Dbuild.compiler=org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter ...
  948. -- task invocation in the build script:
  949. <javac srcdir="src" includes="org/aspectj/**/*.java" destdir="dest" />
  950. ]]>
  951. </programlisting>
  952. <para>
  953. To pass ajc-specific arguments, use a compilerarg entry.
  954. </para>
  955. <programlisting>
  956. <![CDATA[
  957. -- command
  958. Ant -Dbuild.compiler=org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter
  959. -- build script
  960. <property name="ajc"
  961. value="org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter"/>
  962. <javac srcdir="src" includes="org/aspectj/**/*.java" destdir="dest" >
  963. <compilerarg compiler="${ajc}" line="-argfile src/args.lst"/>
  964. <javac/>
  965. ]]>
  966. </programlisting>
  967. </sect2>
  968. <sect2 id="antTasks-adapter-options" xreflabel="Compiler adapter compilerarg options">
  969. <title>Compiler adapter compilerarg options</title>
  970. <para>
  971. The adapter supports any ajc command-line option passed using compilerarg,
  972. as well as the following options available only in AjcTask.
  973. Find more details on the following options in <xref linkend="antTasks-iajc"/>.
  974. </para>
  975. <itemizedlist>
  976. <listitem><para>
  977. <literal>-Xmaxmem</literal>:
  978. set maximum memory for forking (also settable in javac).
  979. </para></listitem>
  980. <listitem><para>
  981. <literal>-Xlistfileargs</literal>:
  982. list file arguments (also settable in javac).
  983. </para></listitem>
  984. <listitem><para>
  985. <literal>-Xfailonerror</literal>:
  986. throw BuildException on compiler error (also settable in javac).
  987. </para></listitem>
  988. <listitem><para>
  989. <literal>-Xmessageholderclass</literal>:
  990. specify fully-qualified name of class to use as the message holder.
  991. </para></listitem>
  992. <listitem><para>
  993. <literal>-Xcopyinjars</literal>:
  994. copy resources from any input jars to output
  995. (default behavior since 1.1.1)
  996. </para></listitem>
  997. <listitem><para>
  998. <literal>-Xsourcerootcopyfilter {filter}</literal>:
  999. copy resources from source directories to output (minus files specified in filter)
  1000. </para></listitem>
  1001. <listitem><para>
  1002. <literal>-Xtagfile {file}</literal>:
  1003. use file to control incremental compilation
  1004. </para></listitem>
  1005. <listitem><para>
  1006. <literal>-Xsrcdir {dir}</literal>:
  1007. add to list of ajc source roots (all source files will be included).
  1008. </para></listitem>
  1009. </itemizedlist>
  1010. <para>
  1011. Special considerations when using Javac and compilerarg:
  1012. </para>
  1013. <itemizedlist>
  1014. <listitem><para>
  1015. The names above may differ slightly from what you might expect
  1016. from AjcTask; use these forms when specifying compilerarg.
  1017. </para></listitem>
  1018. </itemizedlist>
  1019. <itemizedlist>
  1020. <listitem><para>
  1021. By default the adapter will mimic the Javac task's copying of resource
  1022. files by specifying
  1023. <literal>"**/CVS/*,**/*.java,**/*.aj"</literal>
  1024. for the sourceroot copy filter.
  1025. To change this behavior, supply your own value
  1026. (e.g., <literal>"**/*"</literal> to copy nothing).
  1027. </para></listitem>
  1028. </itemizedlist>
  1029. <itemizedlist>
  1030. <listitem><para>
  1031. Warning - define the system property
  1032. <literal>build.compiler.clean</literal> to compile all files,
  1033. when available.
  1034. Javac prunes the source file list of "up-to-date" source files
  1035. based on the timestamps of corresponding .class files,
  1036. and will not compile if no sources are out of date.
  1037. This is wrong for ajc which requires all the files for each compile
  1038. and which may refer indirectly to sources using argument files.
  1039. </para>
  1040. <para>
  1041. To work around this, set the global property
  1042. <literal>build.compiler.clean</literal>.
  1043. This tells the compiler adapter to delete all .class files
  1044. in the destination directory and re-execute the javac
  1045. task so javac can recalculate the list of source files. e.g.,
  1046. </para>
  1047. <programlisting>
  1048. <![CDATA[
  1049. Ant -Dbuild.compiler=org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter
  1050. -Dbuild.compiler.clean=anything ...
  1051. ]]>
  1052. </programlisting>
  1053. <para>
  1054. Caveats to consider when using this global
  1055. <literal>build.compiler.clean</literal> property:
  1056. </para>
  1057. <orderedlist>
  1058. <listitem><para>
  1059. If javac believes there are no out-of-date source files,
  1060. then the adapter is never called and cannot clean up,
  1061. and the "compile" will appear to complete successfully
  1062. though it did nothing.
  1063. </para></listitem>
  1064. <listitem><para>
  1065. Cleaning will makes stepwise build processes fail if
  1066. they depend on the results of the prior compilation being
  1067. in the same directory, since cleaning deletes all .class files.
  1068. </para></listitem>
  1069. <listitem><para>
  1070. This clean process only permits one compile process at a
  1071. time for each destination directory because it tracks
  1072. recursion by writing a tag file to the destination directory.
  1073. </para></listitem>
  1074. <listitem><para>
  1075. When running incrementally, the clean happens only before
  1076. the initial compile.
  1077. </para></listitem>
  1078. </orderedlist>
  1079. </listitem>
  1080. </itemizedlist>
  1081. </sect2>
  1082. </sect1>
  1083. <!-- . . . . . . . . . . . . . . . . . . . . . . . . . . . Ajc10 -->
  1084. <sect1 id="antTasks-ajc" xreflabel="Ajc10 (ajc)">
  1085. <title>Ajc10 (ajc)</title>
  1086. <para>
  1087. This task handles the same arguments as those used by the AspectJ 1.0 task.
  1088. This should permit those with existing build scripts using the Ajc Ant
  1089. task to continue using the same scripts when compiling with 1.1.
  1090. This will list any use of options no longer supported in 1.1
  1091. (e.g., <literal>lenient, strict, workingdir, preprocess, usejavac</literal>,...),
  1092. and does not provide access to the new features of AspectJ 1.1.
  1093. (Developers using AspectJ 1.1 only should upgrade their scripts
  1094. to use AjcTask instead. This will not work for AspectJ 1.2 or later.)
  1095. </para>
  1096. <sect2 id="antTasks-ajc-options" xreflabel="Ajc10 (ajc) Options">
  1097. <title>Ajc10 (ajc) Options</title>
  1098. <para>
  1099. </para>
  1100. <para>
  1101. Most attributes and nested elements are optional.
  1102. The compiler requires that the same version of
  1103. <literal>aspectjrt.jar</literal>
  1104. be specified on the classpath, and that some sources be
  1105. be specified
  1106. (using one or more of
  1107. <literal>argfiles</literal> and
  1108. <literal>srcdir</literal> (with patterns)).
  1109. </para>
  1110. <para>Boolean parameters default to <literal>false</literal>
  1111. unless otherwise stated.
  1112. </para>
  1113. <!-- . . . . . . . . . . . . . . . . ajc options table -->
  1114. <table>
  1115. <title>AjcTask (ajc) options for specifying sources</title>
  1116. <tgroup cols="2">
  1117. <thead>
  1118. <row>
  1119. <entry>Attribute</entry>
  1120. <entry>Description</entry>
  1121. </row>
  1122. </thead>
  1123. <tbody>
  1124. <row>
  1125. <entry><para>srcdir
  1126. </para></entry>
  1127. <entry><para>
  1128. The base directory of the java files.
  1129. See
  1130. </para></entry>
  1131. </row>
  1132. <row>
  1133. <entry><para>destdir
  1134. </para></entry>
  1135. <entry><para>
  1136. The target directory for the output .class files
  1137. </para></entry>
  1138. </row>
  1139. <row>
  1140. <entry><para>includes
  1141. </para></entry>
  1142. <entry><para>
  1143. Comma-separated list of patterns of files that must be included.
  1144. No files are included when omitted.
  1145. </para></entry>
  1146. </row>
  1147. <row>
  1148. <entry><para>includesfile
  1149. </para></entry>
  1150. <entry><para>
  1151. The path to a file containing include patterns.
  1152. </para></entry>
  1153. </row>
  1154. <row>
  1155. <entry><para>excludes
  1156. </para></entry>
  1157. <entry><para>
  1158. Comma-separated list of patterns of files that must be excluded.
  1159. No files (except default excludes) are excluded when omitted.
  1160. </para></entry>
  1161. </row>
  1162. <row>
  1163. <entry><para>excludesfile
  1164. </para></entry>
  1165. <entry><para>
  1166. The path to a file containing exclude patterns.
  1167. </para></entry>
  1168. </row>
  1169. <row>
  1170. <entry><para>defaultexcludes
  1171. </para></entry>
  1172. <entry><para>
  1173. If true, then default excludes are used.
  1174. Default excludes are used when omitted
  1175. (i.e., defaults to <literal>true</literal>).
  1176. </para></entry>
  1177. </row>
  1178. <row>
  1179. <entry><para>classpath, classpathref
  1180. </para></entry>
  1181. <entry><para>
  1182. The classpath to use,
  1183. optionally given as a reference to a classpath Path
  1184. element defined elsewhere.
  1185. </para></entry>
  1186. </row>
  1187. <row>
  1188. <entry><para>bootclasspath, bootclasspathref
  1189. </para></entry>
  1190. <entry><para>
  1191. The bootclasspath to use,
  1192. optionally given as a reference to a bootclasspath Path
  1193. element defined elsewhere.
  1194. </para></entry>
  1195. </row>
  1196. <row>
  1197. <entry><para>extdirs
  1198. </para></entry>
  1199. <entry><para>
  1200. Paths to directories containting installed extensions.
  1201. </para></entry>
  1202. </row>
  1203. <row>
  1204. <entry><para>debug
  1205. </para></entry>
  1206. <entry><para>
  1207. If true, emit debug info in the .class files.
  1208. </para></entry>
  1209. </row>
  1210. <row>
  1211. <entry><para>deprecation
  1212. </para></entry>
  1213. <entry><para>
  1214. If true, emit messages about use of deprecated API.
  1215. </para></entry>
  1216. </row>
  1217. <row>
  1218. <entry><para>verbose
  1219. </para></entry>
  1220. <entry><para>
  1221. Emit compiler status messages during the compile.
  1222. </para></entry>
  1223. </row>
  1224. <row>
  1225. <entry><para>version
  1226. </para></entry>
  1227. <entry><para>
  1228. Emit version information and quit.
  1229. </para></entry>
  1230. </row>
  1231. <row>
  1232. <entry><para>failonerror
  1233. </para></entry>
  1234. <entry><para>
  1235. If true, throw BuildException to halt build if there
  1236. are any compiler errors.
  1237. If false, continue notwithstanding compile errors.
  1238. Defaults to <literal>true</literal>.
  1239. </para></entry>
  1240. </row>
  1241. <row>
  1242. <entry><para>source
  1243. </para></entry>
  1244. <entry><para>
  1245. Value of -source option - ignored unless <literal>1.4</literal>.
  1246. </para></entry>
  1247. </row>
  1248. </tbody>
  1249. </tgroup>
  1250. </table>
  1251. <table>
  1252. <title>Parameters ignored by the old ajc taskdef,
  1253. but now supported or buggy</title>
  1254. <tgroup cols="3">
  1255. <thead>
  1256. <row>
  1257. <entry>Attribute</entry>
  1258. <entry>Description</entry>
  1259. <entry>Supported?</entry>
  1260. </row>
  1261. </thead>
  1262. <tbody>
  1263. <row>
  1264. <entry><para>encoding
  1265. </para></entry>
  1266. <entry><para>Default encoding of source files.
  1267. </para></entry>
  1268. <entry><para>yes
  1269. </para></entry>
  1270. </row>
  1271. <row>
  1272. <entry><para>optimize
  1273. </para></entry>
  1274. <entry><para>
  1275. Whether source should be compiled with optimization.
  1276. </para></entry>
  1277. <entry><para>yes?
  1278. </para></entry>
  1279. </row>
  1280. <row>
  1281. <entry><para>target
  1282. </para></entry>
  1283. <entry><para>
  1284. Generate class files for specific VM version, one of
  1285. [<literal>1.1 1.2</literal>].
  1286. </para></entry>
  1287. <entry><para>yes
  1288. </para></entry>
  1289. </row>
  1290. <row>
  1291. <entry><para>depend
  1292. </para></entry>
  1293. <entry><para>
  1294. Enables dependency-tracking.
  1295. </para></entry>
  1296. <entry><para>no
  1297. </para></entry>
  1298. </row>
  1299. <row>
  1300. <entry><para>includeAntRuntime
  1301. </para></entry>
  1302. <entry><para>
  1303. Whether to include the Ant run-time libraries.
  1304. </para></entry>
  1305. <entry><para>no
  1306. </para></entry>
  1307. </row>
  1308. <row>
  1309. <entry><para>includeJavaRuntime
  1310. </para></entry>
  1311. <entry><para>
  1312. Whether to include the run-time libraries from the executing VM.
  1313. </para></entry>
  1314. <entry><para>no
  1315. </para></entry>
  1316. </row>
  1317. <row>
  1318. <entry><para>threads
  1319. </para></entry>
  1320. <entry><para>Multi-threaded compilation
  1321. </para></entry>
  1322. <entry><para>no
  1323. </para></entry>
  1324. </row>
  1325. </tbody>
  1326. </tgroup>
  1327. </table>
  1328. <para>
  1329. The following table shows that many of the unique parameters in
  1330. AspectJ 1.0 are no longer supported.
  1331. </para>
  1332. <table>
  1333. <title>Parameters unique to ajc</title>
  1334. <tgroup cols="3">
  1335. <thead>
  1336. <row>
  1337. <entry>Attribute</entry>
  1338. <entry>Description</entry>
  1339. </row>
  1340. </thead>
  1341. <tbody>
  1342. <row>
  1343. <entry><para>X
  1344. </para></entry>
  1345. <entry><para>
  1346. deprecated X options include
  1347. reweavable (on by default)
  1348. reweavable:compress (compressed by default)
  1349. </para></entry>
  1350. </row>
  1351. <row>
  1352. <entry><para>emacssym
  1353. </para></entry>
  1354. <entry><para>
  1355. Generate symbols for Emacs IDE support.
  1356. </para></entry>
  1357. </row>
  1358. <row>
  1359. <entry><para>argfiles
  1360. </para></entry>
  1361. <entry><para>
  1362. A comma-delimited list of argfiles that contain a line-delimited
  1363. list of source file paths (absolute or relative to the argfile).
  1364. </para></entry>
  1365. </row>
  1366. </tbody>
  1367. </tgroup>
  1368. </table>
  1369. <sect3>
  1370. <title>argfiles - argument list files</title>
  1371. <para>
  1372. An argument file is a file (usually <literal>{file}.lst</literal>)
  1373. containing a list of source file paths
  1374. (absolute or relative to the argfile).
  1375. You can use it to specify all source files to be compiled,
  1376. which ajc requires to avoid searching every possible source file
  1377. in the source path when building aspects.
  1378. If you specify an argfile to the ajc task, it will not include all
  1379. files in any specified source directory (which is the default
  1380. behavior for the Javac task when no includes are specified).
  1381. Conversely, if you specify excludes, they will be removed from
  1382. the list of files compiled even if they were specified
  1383. in an argument file.
  1384. </para>
  1385. <para>
  1386. The compiler also accepts arguments that are not source files,
  1387. but the IDE support for such files varies, and Javac does not
  1388. support them. Be sure to include exactly one argument on each line.
  1389. </para>
  1390. </sect3>
  1391. </sect2>
  1392. <sect2 id="antTasks-ajc-nested">
  1393. <title>Ajc10 parameters specified as nested elements</title>
  1394. <para>
  1395. This task forms an implicit FileSet and supports all attributes of
  1396. <literal>&lt;fileset&gt;</literal> (dir becomes srcdir) as well as
  1397. the nested
  1398. <literal>&lt;include&gt;</literal>,
  1399. <literal>&lt;exclude&gt;</literal>, and
  1400. <literal>&lt;patternset&gt;</literal> elements.
  1401. These can be used to specify source files.
  1402. </para>
  1403. <para>
  1404. <literal>ajc</literal>'s
  1405. <literal>srcdir</literal>,
  1406. <literal>classpath</literal>,
  1407. <literal>bootclasspath</literal>,
  1408. <literal>extdirs</literal>, and
  1409. <literal>jvmarg</literal>
  1410. attributes are path-like structures and can also be set via nested
  1411. <literal>&lt;src&gt;</literal>,
  1412. <literal>&lt;classpath&gt;</literal>,
  1413. <literal>&lt;bootclasspath&gt;</literal>,
  1414. <literal>&lt;extdirs&gt;</literal>, and
  1415. <literal>&lt;jvmargs&gt;</literal> elements, respectively.
  1416. </para>
  1417. </sect2>
  1418. <sect2 id="antTasks-ajc-sample" xreflabel="Sample of ajc task">
  1419. <title>Sample of ajc task</title>
  1420. <para>
  1421. Following is a declaration for the ajc task and a sample invocation
  1422. that uses the ajc compiler to compile the files listed in
  1423. <literal>default.lst</literal> into the dest dir:
  1424. </para>
  1425. <programlisting>
  1426. <![CDATA[
  1427. <project name="example" default="compile" >
  1428. <taskdef name="ajc"
  1429. classname="org.aspectj.tools.ant.taskdefs.Ajc10" >
  1430. <!-- declare classes needed to run the tasks and tools -->
  1431. <classpath>
  1432. <pathelement location="${home.dir}/tools/aspectj/lib/aspectjtools.jar"/>
  1433. </classpath>
  1434. </taskdef>
  1435. <target name="compile" >
  1436. <mkdir dir="dest" />
  1437. <ajc destdir="dest" argfiles="default.lst" >
  1438. <!-- declare classes needed to compile the target files -->
  1439. <classpath>
  1440. <pathelement location="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/>
  1441. </classpath>
  1442. </ajc>
  1443. </target>
  1444. </project>
  1445. ]]>
  1446. </programlisting>
  1447. <para>
  1448. This build script snippet
  1449. </para>
  1450. <programlisting>
  1451. <![CDATA[
  1452. <ajc srcdir="${src}"
  1453. destdir="${build}"
  1454. argfiles="demo.lst"
  1455. />
  1456. ]]>
  1457. </programlisting>
  1458. <para>
  1459. compiles all .java files specified in the demo.lst and stores the .class files in the ${build} directory. Unlike the Javac task, the includes attribute is empty by default, so only those files specified in demo.lst are included.
  1460. </para>
  1461. <para>
  1462. This next example
  1463. </para>
  1464. <programlisting>
  1465. <![CDATA[
  1466. <ajc srcdir="${src}"
  1467. destdir="${build}"
  1468. includes="spacewar/*,coordination/*"
  1469. excludes="spacewar/Debug.java"
  1470. />
  1471. ]]>
  1472. </programlisting>
  1473. <para>
  1474. compiles .java files under the <literal>${src}</literal> directory in the
  1475. spacewar and coordination packages, and stores the .class files in the
  1476. <literal>${build}</literal> directory.
  1477. All source files under spacewar/ and coordination/ are used, except Debug.java.
  1478. </para>
  1479. <para>
  1480. See <ulink url="../examples/build.xml">../examples/build.xml</ulink>
  1481. for an example build script.
  1482. </para>
  1483. </sect2>
  1484. </sect1>
  1485. <!-- . . . . . . . . . . . . . . . . . . . . . . . . . . . problems -->
  1486. <sect1 id="antTasks-problems">
  1487. <title>Isolating problems running the Ant tasks</title>
  1488. <para>
  1489. If you have problems with the tasks not solved by the documentation,
  1490. please try to see if you have the same problems when running ajc
  1491. directly on the command line.
  1492. </para>
  1493. <itemizedlist>
  1494. <listitem><para>
  1495. If the problem occurs on the command line also, then the problem
  1496. is not in the task.
  1497. (It may be in the tools; please send bug reports.)
  1498. </para></listitem>
  1499. <listitem><para>
  1500. If the problem does not occur on the command line, then it may
  1501. lie in the parameters you are supplying in Ant or in the task's
  1502. handling of them.
  1503. </para></listitem>
  1504. <listitem><para>
  1505. If the build script looks correct and the problem only occurs when
  1506. building from Ant, then please send a report
  1507. (including your build file, if possible).
  1508. </para></listitem>
  1509. </itemizedlist>
  1510. <sect2 id="antTasks-knownProblems">
  1511. <title>Known issues with the Ant tasks</title>
  1512. <para>
  1513. For the most up-to-date information on known problems,
  1514. see the
  1515. <ulink url="http://bugs.eclipse.org/bugs">bug database</ulink>
  1516. for unresolved
  1517. <ulink url="http://bugs.eclipse.org/bugs/buglist.cgi?&amp;product=AspectJ&amp;component=Compiler&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED">
  1518. compiler bugs
  1519. </ulink> or
  1520. <ulink url="http://bugs.eclipse.org/bugs/buglist.cgi?&amp;product=AspectJ&amp;component=Ant&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED">
  1521. taskdef bugs
  1522. </ulink>.
  1523. </para>
  1524. <para>
  1525. When running Ant build scripts under Eclipse 2.x variants, you will get a
  1526. VerifyError because the Eclipse Ant support fails to isolate the Ant runtime
  1527. properly. To run in this context, set up iajc to fork (and use forkclasspath).
  1528. Eclipse 3.0 will fork Ant processes to avoid problems like this.
  1529. </para>
  1530. <para>
  1531. Memory and forking: Users email most often about the ajc task running
  1532. out of memory.
  1533. This is not a problem with the task; some compiles take a lot of
  1534. memory, often more than similar compiles using javac.
  1535. </para>
  1536. <para>
  1537. Forking is now supported in both the
  1538. <xref linkend="antTasks-adapter"/> and
  1539. <xref linkend="antTasks-iajc"/>,
  1540. and you can set the maximum memory available.
  1541. You can also not fork and increase the memory available to Ant
  1542. (see the Ant documentation, searching for ANT_OPTS,
  1543. the variable they use in their scripts to pass VM options,
  1544. e.g., ANT_OPTS=-Xmx128m).
  1545. </para>
  1546. </sect2>
  1547. <sect2 id="antTasks-feedback">
  1548. <title>Ant task questions and bugs</title>
  1549. <para>
  1550. For questions, you can send email to
  1551. <ulink url="mailto:aspectj-users@dev.eclipse.org">
  1552. aspectj-users@dev.eclipse.org</ulink>.
  1553. (Do join the list to participate!)
  1554. We also welcome any bug reports, patches, and features;
  1555. you can submit them to the bug database at
  1556. <ulink url="http://bugs.eclipse.org/bugs">
  1557. http://bugs.eclipse.org/bugs</ulink>
  1558. using the AspectJ product and Ant component.
  1559. </para>
  1560. </sect2>
  1561. </sect1>
  1562. </chapter>
  1563. <!-- Local variables: -->
  1564. <!-- fill-column: 79 -->
  1565. <!-- sgml-local-ecat-files: devguide.ced -->
  1566. <!-- sgml-parent-document:("devguide.sgml" "book" "refentry") -->
  1567. <!-- End: -->