This file is indexed.

/usr/share/doc/libjdepend-java/JDepend.html is in libjdepend-java 2.9.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <title>JDepend</title>
  <meta name="keywords" content="JDepend, Java package dependency, 
				 Java metrics, Martin Metrics"/>
  <meta name="description" content="A Java package dependency analyzer
  that generates design quality metrics."/>

  <style type="text/css">
<!--
    body {
      font-family: Lucida, Verdana, Arial, Geneva, Helvetica, sans-serif;
      margin-left: 2em;
      margin-right: 2em;
      margin-top: 2em;
      margin-bottom: 2em;
    }

    a {
      color: #000090;
      text-decoration: none;
    }

    a:hover {
      color: red;
      text-decoration: underline;
    }

    div#title { 
      color: white;
      background: #000090;
      font-size: 150%;
      font-weight: bold;
      text-align: center;
      padding-top: 0.125em;
      padding-bottom: 0.125em;
    }

    div#summary {
      margin-left: 4em;
      margin-right: 4em;
    }

    div.header {
      color: #000090;
      background: #EDEDED;
      font-weight: bold;
      border-top: 1px solid #000090;
      border-left: 1px solid #000090;
      padding-top: .25em;
      padding-bottom: .25em;
      padding-left: 0.5em;
      margin-top: 1.5em;
      margin-bottom: 0;
    }

    div.code-header {
      color: white;
      font-weight: bold;
      text-align: center;
      background: #000090;
      padding-top: .25em;
      padding-bottom: .25em;
      margin-left: 5em;
      margin-right: 5em;
      margin-left: 5em;
      margin-right: 5em;
    }

    div.code {
      background: #EDEDED;
      border-top: 1px solid #000090;
      border-bottom: 1px solid #000090;
      border-right: 1px solid #000090;
      border-left: 1px solid #000090;
      padding-left: 2em;
      margin-top: 0;
      margin-bottom: 2em;
      margin-left: 5em;
      margin-right: 5em;
    }

    div#copyright {
      color: #AAAAAA;
      font-size: 0.8em;
      text-align: center;
      margin-top: 3em;
    } 
-->
  </style>

</head>

<body>

<!--

    Title

-->

<div id="title">
JDepend
</div>

<!--

    Summary

-->

<div id="summary">
<p>
  <b><u>Summary</u></b>
</p>
<p>
JDepend traverses Java class file directories and generates design
quality metrics for each Java package. JDepend allows you to
automatically measure the quality of a design in terms of its
extensibility, reusability, and maintainability to manage package
dependencies effectively.
</p>
<p>
<i>If you like this kind of automation, you'll love my book, 
  <a href="http://www.pragmaticprogrammer.com/sk/auto/">Pragmatic Project
  Automation</a>.
</i>
</p>
</div>

<!--
    
    Table of Contents
    
-->
<div class="header">
Table of Contents
</div>

<ul>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#uses">Why Use JDepend?</a></li>
  <li><a href="#download">Downloading JDepend</a></li>
  <li><a href="#installation">Installing JDepend</a></li>
  <li><a href="#building">Building and Testing JDepend</a></li> 
  <li><a href="#howtouse">Running JDepend</a></li>
  <li><a href="#graphical">Graphical UI Navigation</a></li>
  <li><a href="#cycles">Interpreting Dependency Cycles</a></li>
  <li><a href="#customize">Customizing JDepend</a></li>
  <li><a href="#junit">Using JDepend With JUnit</a></li>
  <li><a href="#fitnesse">Using JDepend With FitNesse</a></li>
  <li><a href="#ant">Using JDepend With Ant</a></li>
  <li><a href="#limitations">Limitations</a></li>
  <li><a href="#support">Support</a></li>
  <li><a href="#donate">Donate</a></li>
  <li><a href="#reviews">Design Reviews</a></li>
  <li><a href="#license">License</a></li>
  <li><a href="#credits">Acknowledgments</a></li>
  <li><a href="#resources">Resources</a></li>
</ul>

<!--

    Overview	

-->
<div class="header">
<a name="overview"></a> 
Overview
</div>
<p>
JDepend traverses Java class file directories and generates design
quality metrics for each Java package, including:
</p>
<ul>
  <li><b>Number of Classes and Interfaces</b>
    <p>
      The number of concrete and abstract classes (and interfaces) in the
      package is an indicator of the extensibility of the package.
    </p>
  </li>
  <li><b>Afferent Couplings (Ca)</b>
    <p>
      The number of other packages that depend upon classes within 
      the package is an indicator of the package's responsibility.
    </p>
  </li>
  <li><b>Efferent Couplings (Ce)</b>
    <p>
      The number of other packages that the classes in the package depend 
      upon is an indicator of the package's independence.
    </p>
  </li>
  <li><b>Abstractness (A)</b>
    <p>
      The ratio of the number of abstract classes (and interfaces) 
      in the analyzed package to the total number of classes in 
      the analyzed package.
    </p>
    <p>
      The range for this metric is 0 to 1, with A=0 indicating a
      completely concrete package and A=1 indicating a completely 
      abstract package.
    </p>
  </li>
  <li><b>Instability (I)</b>
    <p>
      The ratio of efferent coupling (Ce) to total coupling
      (Ce + Ca) such that I = Ce / (Ce + Ca).  This metric is 
      an indicator of the package's resilience to change.
    </p>
    <p>
      The range for this metric is 0 to 1, with I=0 indicating
      a completely stable package and I=1 indicating a completely
      instable package.
    </p>
  </li>
  <li><b>Distance from the Main Sequence (D)</b>
    <p>
      The perpendicular distance of a package from the idealized
      line A + I = 1.  This metric is an indicator of the package's
      balance between abstractness and stability.  
    </p>
    <p>
      A package squarely on the main sequence is optimally balanced 
      with respect to its abstractness and stability.  Ideal packages 
      are either completely abstract and stable (x=0, y=1) or completely 
      concrete and instable (x=1, y=0).
    </p>
    <p>
      The range for this metric is 0 to 1, with D=0 indicating
      a package that is coincident with the main sequence and 
      D=1 indicating a package that is as far from the main sequence
      as possible.
    </p>
  </li>
  <li><b>Package Dependency Cycles</b>
    <p>
      Package dependency cycles are reported along with the hierarchical 
      paths of packages participating in package dependency cycles.
    </p>
  </li>
</ul>

<!--
    
    Uses

-->
<div class="header">
<a name="uses"></a> 
Why Use JDepend?
</div>
<p>
Before using JDepend, it is important to understand that
&quot;good&quot; design quality metrics are not necessarily indicative
of good designs.  Likewise, &quot;bad&quot; design quality metrics are
not necessarily indicative of bad designs.  The design quality metrics
produced by JDepend should not be used as yard sticks by which all
designs are measured.
</p>
<p>
The design quality metrics produced by JDepend are intended to be used
by designers to measure the designs they create, understand those
designs, and automatically check that the designs exhibit expected
qualities while undergoing continuous refactoring.  Refactoring will
undoubtedly lead to some adjustment of these metrics as the shape of
the design changes.  
</p>
<p>
<b>Measure Design Quality</b>
</p>
<p>
The quality of a design can be measured in part by quantifying its
degrees of extensibility, reusability, and maintainability.  These
qualities are all influenced by the inter-package dependencies of the
design.  Designs are more extensible when they are independent of
implementation details, allowing them to adapt to new implementations
without internal modification or breaking their existing contracts.
This same independence tends to increase the reuse potential of
portions of the design.  Independent portions of the design containing
high-level abstractions can be extracted from portions containing
implementation details.
</p>
<p>
The maintainability of a design is improved when changes can easily be
made without propagating to other parts of the system.  JDepend allows
you to automatically measure the quality of a design in terms of its
extensibility, reusability, and maintainability to effectively manage
and control package dependencies.
</p>
<p>
<b>Invert Dependencies</b>
</p>
<p>
The goal of using JDepend is to ultimately invert package dependencies
such that low-abstraction packages depend upon high-abstraction
packages.  This inversion of dependencies allows the high-abstraction
packages to be reused independently while being extensible to an open
set of implementations.  In general, dependencies upon stable packages
are desirable, while dependencies upon instable packages are
undesirable.  JDepend allows dependencies to be iteratively examined
and refactored as an integral part of software design and development.
</p>
<p>
<b>Foster Parallel, Extreme Programming</b>
</p>
<p>
Packages that are stable should be the centerpieces of a loosely
coupled application so the speed of the development team is not
adversely affected by the propagation of software changes.  Stable
packages form design-by-contract facades to other subsystems, allowing
teams to develop in parallel at an extreme pace.  Moreover, by
measuring the software design quality, the overall impact of proposed
software changes can be accurately estimated.  JDepend allows teams to
identify and use desirable dependencies in the system and avoid those
dependencies that cause changes to ripple throughout the system.
</p>
<p>
<b>Isolate Third-Party Package Dependencies</b>
</p>
<p>
Third-party package dependencies can be easily identified and isolated
by examining the afferent couplings to those packages.  Once the
dependency on these third-party packages has been measured with
JDepend, the dependency can be managed by effectively designing
abstract and stable packages that encapsulate the third-party package
implementation details.
</p>
<p>
<b>Package Release Modules</b>
</p>
<p>
Packages that are cohesive and independent can be released as
autonomous modules with their own release schedules and version
numbers.  Single packages, or groups of related packages collaborating
in a framework, that are candidates for independent release can be
harvested by evaluating their design quality metrics using JDepend.
</p>
<p>
<b>Identify Package Dependency Cycles</b>
</p>
<p>
Packages participating in a package dependency cycle are in a deadly
embrace with respect to reusability and their release cycle.  Package
dependency cycles can be easily identified by reviewing the textual
reports of dependency cycles.  Once these dependency cycles have been
identified with JDepend, they can be broken by employing various
object-oriented techniques.
</p>

<!--

    Download	

-->
<div class="header">
<a name="download"></a> 
Downloading JDepend
</div>
<p>
<a href="http://www.clarkware.com/software/jdepend-2.9.1.zip">JDepend
2.9</a> is the latest major version release.  It includes all the
minor version changes.
</p>
<p>
The distribution contains a JAR file, source code, sample application,
API documentation, and this document.
</p>


<!--

    Installation	

-->
<div class="header">
<a name="installation"></a> 
Installing JDepend
</div>
<p>
<b>Windows</b>
</p>
<p>
To install JDepend, follow these steps:
</p>
<ol>
  <li>
    <p>
      Unzip the <code>jdepend-&lt;version&gt;.zip</code> distribution
      file to a directory referred to as <code>%JDEPEND_HOME%</code>.
    </p>
  </li>
  <li>
    <p>
      Add JDepend to the classpath:
    </p>
    <p>
      <code>set CLASSPATH=%CLASSPATH%;%JDEPEND_HOME%\lib\jdepend-&lt;version&gt;.jar</code>
    </p>
  </li>
</ol>
<p>
<b>Unix (bash)</b>
</p>
<p>
To install JDepend, follow these steps:
</p>
<ol>
  <li>
    <p>
      Unzip the <code>jdepend-&lt;version&gt;.zip</code> distribution
      file to a directory referred to as <code>$JDEPEND_HOME</code>.
    </p>
  </li>
  <li>
    <p>
      Change file permissions:
    </p>
    <p>
      <code>chmod -R a+x $JDEPEND_HOME</code>
    </p>
  </li>
  <li>Add JDepend to the classpath:
    <p>
      <code>export CLASSPATH=$CLASSPATH:$JDEPEND_HOME/lib/jdepend-&lt;version&gt;.jar</code>
    </p>
  </li>
</ol>

<!--

    Building	

-->
<div class="header">
<a name="building"></a> 
Building and Testing JDepend
</div>
<p>
The JDepend distribution includes the pre-built classes in the
<code>$JDEPEND_HOME/lib/jdepend-&lt;version&gt;.jar</code> file.
</p>
<p>
<b>Building</b>
</p>
<p>
An <a href="http://jakarta.apache.org/ant" target="_parent">Ant</a>
build file is included in <code>$JDEPEND_HOME/build.xml</code> to
build the <code>$JDEPEND_HOME/dist/jdepend-&lt;version&gt;.jar</code>
file from the included source code.
</p>
<p>
To build JDepend, use:
</p>
<div>
<blockquote>
<pre>
cd $JDEPEND_HOME
ant jar
</pre>
</blockquote>
</div>
<p>
<b>Testing</b>
</p>
<p>
The JDepend distribution includes
<a href="http://www.junit.org" target="_parent">JUnit</a>
test cases to validate the integrity of JDepend.  
</p>
<p>
To test JDepend, use:
</p>
<div>
<blockquote>
<pre>
cd $JDEPEND_HOME
ant test
</pre>
</blockquote>
</div>

<!--

    How To Use	

-->
<div class="header">
<a name="howtouse"></a> 
Running JDepend
</div>
<p>
JDepend provides a graphical, textual, and XML user interface to
visualize Java package metrics, dependencies, and cycles.
</p>
<p>
<b>Graphical UI</b>
</p>
<p>
The graphical user interface displays a hierarchical tree for both the
afferent and efferent couplings of each analyzed Java package.
</p>
<p>
To run JDepend with the graphical user interface, use the following syntax:
</p>
<div>
<blockquote>
<pre>
java jdepend.swingui.JDepend [-components &lt;components&gt;] &lt;directory&gt; [directory2 [directory 3] ...]
</pre>
</blockquote>
</div>
<p>
For example, to analyze all the Java class files in the
<code>$JDEPEND_HOME/build</code> directory, use: 
</p>
<div>
<blockquote>
<pre>
java jdepend.swingui.JDepend $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
<b>Textual UI</b>
</p>
<p>
The textual user interface displays detailed metrics, dependencies,
and cycles for each analyzed Java package.  For the convenience of
importing these metrics into other applications, the summary section
contains comma-separated metrics for each Java package.
Alternatively, the XML user interface can be used for easier
integration with other tools.
</p>
<p>
To run JDepend with the textual user interface, use the following
syntax:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend [-components &lt;components&gt;] [-file &lt;output file&gt;] &lt;directory&gt; [directory2 [directory 3] ...]
</pre>
</blockquote>
</div>
<p>
For example, to analyze all the Java class files in the
<code>$JDEPEND_HOME/build</code> directory, use: 
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
Alternatively, the text report can be written to file using:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend -file report.txt $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
<a href="jdepend-text.out" target="_parent">Example output</a> from the
textual UI shows the analysis of the sample application, an example
electronic payment framework.  The relevant source for the sample
application is distributed in
<code>$JDEPEND_HOME/sample</code>.
</p>
<p>
<b>XML UI</b>
</p>
<p>
The XML user interface displays detailed metrics, dependencies, and
cycles for each analyzed Java package in an XML format for easier
integration with other tools.
</p>
<p>
To run JDepend with the XML user interface, use the following syntax:
</p>
<div>
<blockquote>
<pre>
java jdepend.xmlui.JDepend [-components &lt;components&gt;] [-file &lt;output file&gt;] &lt;directory&gt; [directory2 [directory 3] ...]
</pre>
</blockquote>
</div>
<p>
For example, to analyze all the Java class files in the
<code>$JDEPEND_HOME/build</code> directory, use: 
</p>
<div>
<blockquote>
<pre>
java jdepend.xmlui.JDepend $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
Alternatively, the XML report can be written to file using:
</p>
<div>
<blockquote>
<pre>
java jdepend.xmlui.JDepend -file report.xml $JDEPEND_HOME/build
</pre>
</blockquote>
</div>
<p>
<a href="jdepend-xml.out" target="_parent">Example output</a> from the
XML UI shows the analysis of the sample application, an example
electronic payment framework.  The relevant source for the sample
application is distributed in
<code>$JDEPEND_HOME/sample</code>.
</p>
<p>
You can then transform the XML format into a format of your liking.
For example, David Bock contributed an XSL stylesheet that transforms
the JDepend XML output into a <a
href="http://www.research.att.com/sw/tools/graphviz/"
target="_parent">Graphviz</a> dot file format.  David's stylesheet is
distributed with JDepend in the <code>contrib/jdepend2dot.xsl</code>
file.
</p>
<p>
To create a sample Graphviz file, use:
</p>
<div>
<blockquote>
<pre>
ant jdepend-to-graphviz
</pre>
</blockquote>
</div>
<p>
This will create a <code>docs/jdepend-report.dot</code> file.  If
you have Graphviz installed, you can then convert that .dot file 
into a .png file using: 
</p>
<div>
<blockquote>
<pre>
dot -Tpng -o jdepend.png jdepend.dot
</pre>
</blockquote>
</div>

<!--

    Graphical UI Navigation

-->
<div class="header">
<a name="graphical"></a> 
Graphical UI Navigation	
</div>
<p>
The graphical user interface displays the afferent and efferent
couplings of each analyzed Java package, presented in the familiar
Java Swing tree structure.
</p>
<p>
Figure 1 shows the analysis of the sample application, an example
electronic payment framework.  The relevant source for the sample
application is distributed in <code>$JDEPEND_HOME/sample</code>.
</p>
<p>
<a href="images/figure1b.jpg" target="_parent">
  <img src="images/figure1a.jpg" alt="Figure 1"/>
</a>
<br/>
Figure 1 (Click to view full-scale)
</p>
<p>
The root of each tree displays a branch for each analyzed Java
package, annotated with the following metrics:
</p>
<ul>
  <li>
    <b>CC</b> - Concrete Class Count
  </li>
  <li>
    <b>AC</b> - Abstract Class (and Interface) Count
  </li>
  <li>
    <b>Ca</b> - Afferent Couplings (Ca)
  </li>
  <li>
    <b>Ce</b> - Efferent Couplings (Ce)
  </li>
  <li>
    <b>A</b> - Abstractness (0-1)
  </li>
  <li>
    <b>I</b> - Instability (0-1)
  </li>
  <li>
    <b>D</b> - Distance from the Main Sequence (0-1)
  </li>
  <li>
    <b>V</b> - Volatility (0-1)
  </li>
  <li>
    <b>Cyclic</b> - If the package contains a dependency cycle
  </li>
</ul>
<p>
For organizational purposes, package metrics are only displayed at the
root of each tree.  For convenience, selecting any node of the tree
displays the currently selected package's metrics in the status bar.
</p>
<p>
<b>Efferent Couplings</b>
</p>
<p>
The top tree displays the efferent couplings of each analyzed Java
package.  Branches of the tree can be opened up to explore packages
that the currently selected package depends upon (Figure 2).
</p>
<p>
<a href="images/figure2b.jpg" target="_parent">
  <img src="images/figure2b.jpg" alt="Figure 2"/>
</a>
<br/>
Figure 2 (Click to view full-scale)
</p>
<p>
For the <code>epayment.adapters</code> package, we see that it depends
upon 4 other packages:
the <code>com.abc.epayment</code>, <code>com.xyz.epayment</code>,
<code>epayment.framework</code>, and the <code>epayment.response</code> 
packages.  Furthermore, it's completely concrete (A=0) and completely 
instable (I=1).  This balance earns it a spot squarely on the main 
sequence (D=0).  We can conclude from these metrics that dependencies on
this package are undesirable because it's both dependent and irresponsible.
It's sensitive to modifications made to any of it's efferent couplings and
not accountable to any other package.  Therefore, it's important that other 
packages in the system not become dependent on this package, as they'll in turn 
become fragile by any modifications made to the details of the 
<code>epayment.adapters</code> package and its dependencies.  As a concrete
package, it's not capable of being extended without being modified.
</p>
<p>
For the <code>epayment.framework</code> package, we see that it does
not depend on any other packages in the application (Ce=0).  However,
it is responsible to every other package (Ca=5) while exhibiting a
high degree of abstractness (A=0.83) and stability (I=0).  While not
completely balanced, this package is very near the main sequence
(D=0.17).  We can conclude from these metrics that dependencies on
this package are desirable because it's both independent and
responsible.  It's abstractness also indicates that it's capable of
being extended to accommodate new implementations without being
modified.
</p>
<p>
Packages that were imported, but not analyzed, are not shown in the
efferent dependency tree.  Third-party software packages that weren't
analyzed, for example, will not be shown in the efferent tree, as
their efferent dependencies are not available.
</p>
<p>
<b>Afferent Couplings</b>
</p>
<p>
The bottom tree displays the afferent couplings of each analyzed Java
package.  Branches of the tree can be opened up to explore packages
that use the currently selected package (Figure 3).
</p>
<p>
<a href="images/figure3b.jpg" target="_parent">
  <img src="images/figure3b.jpg" alt="Figure 3"/>
</a>
<br/>
Figure 3 (Click to view full-scale)
</p>
<p>
For the <code>epayment.adapters</code> package, we see that it is not
used by any other package in the application.  This confirms our
observations of the efferent dependency tree.
</p>
<p>
For the <code>epayment.framework</code> package, we see that it's used
by all the other user-defined packages in the framework.  However, it
does not have any efferent couplings (Ce=0) and exhibits a high degree
of abstractness (A=0.83) and stability (I=0).  This is a requirement
of a software framework - we want it to be heavily used, thereby
making it very responsible to its clients, yet be highly abstract to
allow extensibility without modification.
</p>
<p>
For the <code>com.abc.epayment</code> package, a third-party software
package, we see that it's used by the <code>epayment.adapters</code>
package.  There are no metrics displayed for this package however, as
it's a third-party package that was not analyzed by JDepend.  It was
imported by a user-defined package (<code>epayment.adapters</code>),
so it is shown in the afferent dependency tree.
</p>
<p>
Using the afferent dependency tree, it's easy to identify which
user-defined packages are dependent upon third-party software
packages.
</p>

<!--

    Interpreting Dependency Cycles

-->
<div class="header">
<a name="cycles"></a> 
Interpreting Dependency Cycles	
</div>
<p>
Package dependency cycles are best observed using the textual or XML
user interface.  In general, all packages dependencies that intersect
a dependency cycle are reported.  This includes packages directly
participating in a cycle and packages that depend on packages directly
participating in a cycle.
</p>
<p>
The intent is to identify sets of packages that must be reused and
released together.  To break reported cycles, focus on those packages
directly participating in a cycle.
</p>
<p>
Here's an example of a two-package cycle, as reported by the textual UI:
</p>
<div>
<blockquote>
<pre>
    com.xyz.ejb
       |
       |   com.xyz.servlet
       |-> com.xyz.ejb
</pre>
</blockquote>
</div>
<p>
This indicates that the <code>com.xyz.ejb</code> package depends on
the
<code>com.xyz.servlet</code> package, which in turn depends on the
<code>com.xyz.ejb</code> package.  These two package must be released and
reused together.
</p>
<p>
Here's an example of a package that depends on the two-package cycle
described above, as reported by the textual UI:
</p>
<div>
<blockquote>
<pre>
    com.xyz.client
       |
       |-> com.xyz.ejb
       |   com.xyz.servlet
       |-> com.xyz.ejb
</pre>
</blockquote>
</div>
<p>
This indicates that the <code>com.xyz.client</code> package depends on
the <code>com.xyz.ejb</code> package, which in turn forms a cyclic
dependency with the <code>com.xyz.servlet</code> package.
The <code>com.xyz.client</code> package itself isn't part of the
cycle, but since it depends on a package in the cycle, it can't be
reused/released without it.
</p>

<!--

    Customizing	

-->
<div class="header">
<a name="customize"></a> 
Customizing JDepend
</div>
<p>
JDepend can be customized by using command-line options and/or by
creating a <code>jdepend.properties</code> file in the user's home
directory or any directory in the classpath.
</p>
<p>
<b>Components</b>
</p>
<p>
JDepend can calculate metrics and dependencies for components:
packages that contain one or more sub-packages.
</p>
<p>
For example, given the following package hierarchy:
</p>
<div>
<blockquote>
<pre>
com.xyz.package_a.subpackage_a
com.xyz.package_a.subpackage_b
com.xyz.package_a.subpackage_c
com.xyz.package_b.subpackage_a
com.xyz.package_b.subpackage_b
</pre>
</blockquote>
</div>
<p>
Assume you want to collect metrics and dependencies for the
<code>com.xyz.package_a</code> and <code>com.xyz.package_b</code>
packages, but not for any of their contained packages.  For example,
if there is a dependency from <code>com.xyz.package_a.subpackage_a</code>
to <code>com.xyz.package_b.subpackage_b</code>, then you want it
to be reported as a dependency from <code>com.xyz.package_a</code>
to <code>com.xyz.package_b.subpackage_b</code>.
</p>
<p>
To do that, use the <code>-components</code> command-line argument:
</p>
<div>
<blockquote>
<pre>
java jdepend.textui.JDepend -components com.xyx.package_a,com.xyz.package_b /path/to/classes
</pre>
</blockquote>
</div>
<p>
Note that if component packages are named using the
<code>-components</code> option, then no other packages
are reported.
</p>
<p>
<b>Package Filters</b>
</p>
<p>
JDepend will ignore all package names specified as values to the
<code>ignore</code> property name prefix in the 
<code>jdepend.properties</code> file. By default, no packages are filtered. 
</p>
<p>
The following example <code>jdepend.properties</code> file will ignore
all package names prefixed by <code>java</code>, <code>javax</code>,
<code>sun</code>, <code>com.sun</code>, and the package 
<code>com.xyz.tests</code>:
</p>
<div>
<blockquote>
<pre>
ignore.java=java.*,javax.*
ignore.sun=sun.*,com.sun.*
ignore.tests=com.xyz.tests
</pre>
</blockquote>
</div>
<p>
Packages can also be filtered programmatically by creating a
<code>PackageFilter</code> instance defining the filters and
then passing it to the <code>JDepend</code> constructor.
</p>
<p>
The following example will ignore all package names prefixed by
<code>java</code> and <code>javax</code>, in addition to any
package filters specified in an existing 
<code>jdepend.properties</code> file:
</p>
<div>
<blockquote>
<pre>
PackageFilter filter = new PackageFilter();
filter.addPackage("java.*");
filter.addPackage("javax.*");
JDepend jdepend = new JDepend(filter);
</pre>
</blockquote>
</div>
<p>
The following example will ignore only the package names prefixed
by <code>java</code> and <code>javax</code>, regardless of any package
filters specified in an existing
<code>jdepend.properties</code> file:
</p>
<div>
<blockquote>
<pre>
Collection filters = new ArrayList();
filters.add("java.*");
filters.add("javax.*");
PackageFilter filter = new PackageFilter(filters);
JDepend jdepend = new JDepend(filter);
</pre>
</blockquote>
</div>
<p>
<b>Volatility</b>
</p>
<p>
Packages that are not expected to change can be specifically
configured with a volatility (V) value in the
<code>jdepend.properties</code> file. 
V can either be 0 or 1.  If V=0, meaning the package is not at 
all subject to change, then the package will automatically fall 
directly on the main sequence (D=0).  If V=1, meaning that the
package is subject to change, then the distance from the main
sequence is not affected. By default, all packages are 
configured with V=1. 
</p>
<p>
For example, a package like <code>java.lang</code> is generally not
volatile. That is, for all practical purposes this package is
maximally stable.  Creating dependencies on it is not cause for
concern.  Thus, if you include this package in analysis, it's best to
set its V=0.
</p>
<p>
The following example <code>jdepend.properties</code> file will set
the <code>java.lang</code> package's volatility to 0:
</p>
<div>
<blockquote>
<pre>
java.lang=0
</pre>
</blockquote>
</div>
<p>
Volatility can also be programmatically set on individual packages
prior to analysis by creating a package instance, setting its
volatility, then registering it with the
<code>JDepend</code> instance before analysis.
</p>
<p>
The following example sets V=0 for the <code>java.lang</code> package:
</p>
<div>
<blockquote>
<pre>
JavaPackage javaLang = new JavaPackage("java.lang");
javaLang.setVolatility(0);
// or
JavaPackage javaLang = new JavaPackage("java.lang", 0);
        
JDepend jdepend = new JDepend();
jdepend.addDirectory("/path/to/classes");
jdepend.addPackage(javaLang);
jdepend.analyze();
</pre>
</blockquote>
</div>
<p>
Wildcards are not supported for configuring sets of packages with a
volatility value.
</p>
<p>
<b>Inner Classes</b>
</p>
<p>
By default, inner classes are analyzed.
</p>
<p>
The following example <code>jdepend.properties</code> file will
disable analyzing inner classes:
</p>
<div>
<blockquote>
<pre>
analyzeInnerClasses=false
</pre>
</blockquote>
</div>

<!--

    JUnit	

-->
<div class="header">
<a name="junit"></a> 
Using JDepend With JUnit	
</div>
<p>
In the spirit of automation, metrics can be automatically collected by
JDepend so that they never go stale or require visual inspection.  As
the software evolves through refactorings, the design quality test
cases can be run as a sanity check to ensure that the design has not
formed too many undesirable dependencies.
</p>
<p>
Tolerances for any collected metrics (e.g., the distance from the main
sequence (D)) can be codified in a
<a href="http://www.junit.org" target="_parent">JUnit</a> test case
that automatically checks the metrics for conformance to a desired
result and provides immediate visual feedback.  Tests can also be
written to fail if any package dependency other than those declared in
a dependency constraint are detected. The existence of package
dependency cycles can also be automatically checked by a JUnit test.
</p>
<p>
<b>Dependency Constraint Tests</b>
</p>
<p>
The following example JUnit test case tests whether a package
dependency constraint is met.  This test fails if any package
dependency other than those declared in the dependency constraint are
detected:
</p>
<div class="code-header">
JUnit Package Dependency Constraint Test
</div>
<div class="code">
<pre>
import java.io.*;
import java.util.*;
import junit.framework.*;

public class ConstraintTest extends TestCase {

    private JDepend jdepend;

    public ConstraintTest(String name) {
        super(name);
    }

    protected void setUp() throws IOException {
			
        jdepend = new JDepend();
		
        jdepend.addDirectory("/path/to/project/util/classes");
        jdepend.addDirectory("/path/to/project/ejb/classes");
        jdepend.addDirectory("/path/to/project/web/classes");
    }
	
    /**
     * Tests that the package dependency constraint
     * is met for the analyzed packages.
     */
    public void testMatch() {
        
        DependencyConstraint constraint = new DependencyConstraint();

        JavaPackage ejb = constraint.addPackage("com.xyz.ejb");
        JavaPackage web = constraint.addPackage("com.xyz.web");
        JavaPackage util = constraint.addPackage("com.xyz.util");
		
        ejb.dependsUpon(util);
        web.dependsUpon(util);
		
        jdepend.analyze();		

        assertEquals("Dependency mismatch",
          	     true, jdepend.dependencyMatch(constraint));
    }
    
    public static void main(String[] args) {
        junit.textui.TestRunner.run(ConstraintTest.class);
    }
}
</pre>
</div>
<p>
<b>Dependency Cycle Tests</b>
</p>
<p>
The following example JUnit test case tests for the existence of
package dependency cycles:
</p>
<div class="code-header">
JUnit Package Dependency Cycle Test
</div>
<div class="code">
<pre>
import java.io.*;
import java.util.*;
import junit.framework.*;

public class CycleTest extends TestCase {

    private JDepend jdepend;

    public CycleTest(String name) {
        super(name);
    }

    protected void setUp() throws IOException {
			
        jdepend = new JDepend();
		
        jdepend.addDirectory("/path/to/project/ejb/classes");
        jdepend.addDirectory("/path/to/project/web/classes");
        jdepend.addDirectory("/path/to/project/thirdpartyjars");
    }
	
    /**
     * Tests that a single package does not contain
     * any package dependency cycles.
     */
    public void testOnePackage() {
    
        jdepend.analyze();
        
        JavaPackage p = jdepend.getPackage("com.xyz.ejb");
        
        assertEquals("Cycle exists: " + p.getName(), 
        	     false, p.containsCycle());
    }
    
    /**
     * Tests that a package dependency cycle does not 
     * exist for any of the analyzed packages.
     */
    public void testAllPackages() {
    
        Collection packages = jdepend.analyze();
        
        assertEquals("Cycles exist", 
                     false, jdepend.containsCycles());
    }
    
    public static void main(String[] args) {
        junit.textui.TestRunner.run(CycleTest.class);
    }
}
</pre>
</div>
<p>
<b>Main Sequence Distance Tests</b>
</p>
<p>
The following example JUnit test case tests the conformance of
packages to a distance from the main sequence (D) within
project-defined tolerances:
</p>
<div class="code-header">
JUnit Main Sequence Distance Test
</div>
<div class="code">
<pre>
import java.io.*;
import java.util.*;
import junit.framework.*;

public class DistanceTest extends TestCase {

    private JDepend jdepend;

    public DistanceTest(String name) {
        super(name);
    }

    protected void setUp() throws IOException {
			
        jdepend = new JDepend();
		
        jdepend.addDirectory("/path/to/project/ejb/classes");
        jdepend.addDirectory("/path/to/project/web/classes");
        jdepend.addDirectory("/path/to/project/thirdpartyjars");
    }
	
    /**
     * Tests the conformance of a single package to a 
     * distance from the main sequence (D) within a 
     * tolerance.
     */
    public void testOnePackage() {
    
        double ideal = 0.0;
        double tolerance = 0.125;  // project-dependent
        
        jdepend.analyze();
        
        JavaPackage p = jdepend.getPackage("com.xyz.ejb");

        assertEquals("Distance exceeded: " + p.getName(), 
        	     ideal, p.distance(), tolerance);
    }
    
    /**
     * Tests the conformance of all analyzed packages to a 
     * distance from the main sequence (D) within a tolerance.
     */
    public void testAllPackages() {
    
        double ideal = 0.0;
        double tolerance = 0.5;  // project-dependent
        
        Collection packages = jdepend.analyze();
        
        Iterator iter = packages.iterator();
        while (iter.hasNext()) {
            JavaPackage p = (JavaPackage)iter.next();
            assertEquals("Distance exceeded: " + p.getName(), 
            	         ideal, p.distance(), tolerance);
        }
    }
    
    public static void main(String[] args) {
        junit.textui.TestRunner.run(DistanceTest.class);
    }
}
</pre>
</div>

<!--

    FitNesse

-->
<div class="header">
<a name="fitnesse"></a> 
Using JDepend With FitNesse	
</div>
<p>
Writing JUnit tests to detect unwanted dependencies and package cycles
can be awkward.  Bob Martin contributed the <a
href="http://www.butunclebob.com/ArticleS.UncleBob.JdependFixture"
target="_parent">Module Dependencies FitNesse fixture</a> that allows
you to represent your package dependencies as a table.  The fixture
uses the JDepend API to ensure that only the dependencies declared in
the table actually exist in your software.
</p>
<p>
For example, the following table describes a system with three
components: <code>ejb</code>,
<code>web</code>, and <code>util</code>.  The <code>ejb</code>
and <code>web</code> components depend upon the <code>util</code>
component.
</p>
<center>
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="4">Module Dependencies</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>ejb</td>
    <td>web</td>
    <td>util</td>
  </tr>
  <tr>
    <td>ejb</td>
    <td>&nbsp;</td>
    <td style="background-color: #FFAAAA">&nbsp;</td>
    <td style="background-color: #AAFFAA" align="center">X</td>
  </tr>
  <tr>
    <td>web</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td style="background-color: #AAFFAA" align="center">X</td>
  </tr>
  <tr>
    <td>util</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</center>
<p>
When this table is executed as a <a href="http://fitnesse.org"
target="_parent">FitNesse</a> fixture, and if the <code>ejb</code>
and <code>web</code> components actually did depend upon
the <code>util</code> component, then the cells containing an X would
be colored green.  Any other unexpected component dependencies, such
as the <code>ejb</code> component depending on the <code>web</code>
component, would result in the corresponding cell turning red.  
</p>
<p>
Cycles result in all corresponding cells within the cycle to turn red
and be marked with the word 'cycle'.  The fixture sports other handy
features, as well.  Refer to <a
href="http://www.butunclebob.com/ArticleS.UncleBob.JdependFixture"
target="_parent">Bob's blog</a> for detailed usage information.  
</p>
<p>
The <a
href="http://www.butunclebob.com/ArticleS.UncleBob.JdependFixture"
target="_parent">Module Dependencies fixture</a> is distributed with
JDepend in the <code>contrib/fitnesse</code> directory.
</p>
<!--

    Ant	

-->
<div class="header">
<a name="ant"></a> 
Using JDepend With Ant
</div>
<p>
<a href="http://jakarta.apache.org/ant" target="_parent">Ant</a>
includes a task for automatically running JDepend.
</p>
<p>
Java class file directories to analyze are defined by the nested
<code>&lt;classespath&gt;</code> element.
</p>
<p>
<b>Text Reports</b>
</p>
<p>
The following example Ant task runs JDepend on the <code>build</code>
directory and writes the text report to
the <code>docs/jdepend-report.txt</code> file:
</p>
<div class="code-header">
JDepend Ant Task
</div>
<div class="code">
<pre>
&lt;target name="jdepend"&gt;

  &lt;jdepend outputfile="docs/jdepend-report.txt"&gt;
      &lt;exclude name="java.*"/&gt;
      &lt;exclude name="javax.*"/&gt;
      &lt;classespath&gt;
        &lt;pathelement location="build" /&gt;
      &lt;/classespath&gt;
      &lt;classpath location="build" /&gt;
  &lt;/jdepend&gt;

&lt;/target&gt;
</pre>
</div>
<p>
<b>XML Reports</b>
</p>
<p>
Ant 1.5 and above includes a <code>format</code> attribute for the
JDepend Ant task and a default XSL stylesheet to transform a JDepend
XML report into an HTML report.
</p>
<p>
The following example Ant task runs JDepend on the <code>build</code>
directory, writes the XML report to
the <code>docs/jdepend-report.xml</code> file, and generates
the <code>jdepend.html</code> file using the <code>jdepend.xsl</code>
stylesheet distributed with Ant 1.5 (and above) in
the <code>etc</code> directory:
</p>
<div class="code-header">
JDepend Ant Task
</div>
<div class="code">
<pre>
&lt;target name="jdepend"&gt;

  &lt;jdepend format="xml" outputfile="docs/jdepend-report.xml"&gt;
      &lt;exclude name="java.*"/&gt;
      &lt;exclude name="javax.*"/&gt;
      &lt;classespath&gt;
        &lt;pathelement location="classes" /&gt;
      &lt;/classespath&gt;
      &lt;classpath location="classes" /&gt;
  &lt;/jdepend&gt;

  &lt;style basedir="docs" destdir="docs"
         includes="jdepend-report.xml" 
         style="${ant.home}/etc/jdepend.xsl" /&gt;

&lt;/target&gt;
</pre>
</div>

<!--

    Limitations	

-->
<div class="header">
<a name="limitations"></a> 
Limitations
</div>
<p>
JDepend has the following known limitations:
</p>
<ul>
  <li>
    <p>
      Cyclic dependency detection may not report all cycles reachable
      from a given package.  The detection algorithm stops once any
      given cycle is detected. If the same cycle is reachable from
      another package, the cycle may be reported more than once. In
      general, you want to aggressively remove any cycles.
    </p>
  </li>
  <li>
    <p>
      JDepend does not collect source code complexity metrics.  If you
      are interested in collecting these types of metrics, the
      JavaNCSS tool referenced in the <a
      href="#resources">Resources</a> section is recommended.
    </p>
  </li>
  <li>
    <p>
      The design quality metrics generated by JDepend are imperfect.
      They are intended to be used to pragmatically and responsibly
      measure design quality in a relative sense, rather than as a
      yard stick for all designs.
    </p>
  </li>
  <li>
    <p>
      Java interfaces are treated as equals with Java abstract
      classes.  In other words, although there are practical design
      advantages to using interfaces in concert with abstract classes,
      JDepend treats them uniformly in the calculation of
      abstractness.  Likewise, abstract classes that implement
      interfaces are counted as abstract classes, in addition to their
      interface, regardless of whether they are always referenced
      outside the package as their interface type.
    </p>
  </li>
  <li>
    <p>
      JDepend does not currently support the calculation of Ca and Ce
      in terms of the number of classes inside a package that have
      afferent or efferent couplings to classes inside other packages.
      Rather, JDepend calculates Ca and Ce strictly in terms of the
      number of packages with which a package has afferent or efferent
      couplings, based on the collective analysis of all imported
      packages.  This deviates slightly from the original Ca and Ce
      definitions proposed by Robert Martin.
    </p>
  </li>
</ul>

<!--

    Support	

-->
<div class="header">
<a name="support"></a> 
Support	
</div>
<p>
If you have any questions, comments, enhancement requests, success
stories, or bug reports regarding JDepend, or if you want to be
notified when new versions of JDepend are available, please email
<a href="mailto:mike@clarkware.com">mike@clarkware.com</a>.
Your information will be kept private.
</p>
<p>
A <a href="http://groups.yahoo.com/group/jdepend/"
target="_parent">mailing list</a> is also available to discuss JDepend
or to be notified when new versions of JDepend are available.
</p>

<!--

    Donate

-->
<div class="header">
Donate
<a name="donate"></a> 
</div>
<p>
Please support the ongoing development of JDepend by purchasing a copy
of the book <a
href="http://www.pragmaticprogrammer.com/sk/auto/">Pragmatic Project
Automation</a>.
</p>
<p>
Thanks in advance!
</p>

<!--

    Design Reviews

-->
<div class="header">
<a name="reviews"></a> 
Design Reviews	
</div>
<p>
Move forward with confidence by getting a timely and valuable second
opinion on your design and/or code.  You get an in-depth evaluation
that includes a presentation of the key recommendations and a full
written report of observations and detailed recommendations.
</p>
<p>
<a href="mailto:mike@clarkware.com">Contact me</a> for more details.
</p>

<!--

    License

-->
<div class="header">
<a name="license"></a> 
License
</div>
<p>
JDepend is licensed under the
<a href="http://www.clarkware.com/software/license.txt">BSD License</a>.
</p>

<!--

    Credits

-->
<div class="header">
<a name="credits"></a> 
Acknowledgments
</div>
<p>
Many thanks to Robert Martin for originally describing these design
quality metrics and writing the C++ dependency analyzer from which
JDepend was adapted.  I am especially grateful that he allowed me to
stand on his shoulders in adapting his work for the Java community.
</p>

<!--

    Resources

-->
<div class="header">
<a name="resources"></a> 
Resources
</div>
<ul>
  <li>
    <p>
      <a href="http://www.amazon.com/exec/obidos/ASIN/0135974445/clarkware-20"
	 target="_parent">
	"Agile Software Development: Principles, Patterns, 
	and Practices"</a>, by Martin, R. (Prentice Hall, 2002)
    </p>
  </li>
  <li>
    <p>
      <a href="http://www.amazon.com/exec/obidos/ASIN/0132038374/clarkware-20" 
	 target="_parent">
	"Designing Object-Oriented C++ Applications Using The
	Booch Method"</a>, by Martin, R. (Prentice Hall, 1995)
    </p>
  </li>
  <li>
    <p>
      <a href="http://www.objectmentor.com/publications/oodmetrc.pdf" 
	 target="_parent">"Object Oriented Design Quality Metrics: 
	An Analysis of Dependencies"</a>, by Martin, R.
    </p>
  </li>
  <li>
    <p>
      <a href="http://www.kclee.com/clemens/java/javancss" 
	 target="_parent">JavaNCSS</a> - Clemens Lahme's JavaNCSS
      measures Non-Commenting Source Statements (NCSS),
      the Cyclomatic Complexity Number (McCabe metric), and
      other quantitative source-level metrics.
    </p>
  </li>
</ul>

<div id="copyright">
Copyright &copy; 1999-2005 Clarkware Consulting, Inc.
<br/>
All Rights Reserved
</div>

</body>
</html>