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.

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