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