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 51KB

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