Thanks to Tim Vernum for responding to my last post about Detecting Cycles with ANT/JDepend, I now know about the tool Classycle which is much better suited for the task. Here is the ANT target I added to my build.xml file replacing the old approach:

  <target name="classycle" depends="-init">
    <taskdef name="classycleDependencyCheck"
    <classycleDependencyCheck failOnUnwantedDependencies="true">

      <fileset dir="${}/dist">
        <include name="shared-${build.revision}.jar"/>
        <include name="datareceipt-DO-NOT-USE-${build.revision}.jar"/>
        <include name="webapp-DO-NOT-USE-${build.revision}.jar"/>

      show allPaths onlyFailures
      {root} =
      [all] = ${root}.*
      check absenceOfPackageCycles > 1 in [all]


As you can see this is a lot smaller and simpler than the previous approach.

Some notes:

  • Another nice advantage of this approach is that you do not need to classcyle.jar to your ${ANT\_HOME}/lib directory. With the JDepend approach you need to add the JDepend JAR file to the ${ANT\_HOME}/lib directory.
  • I still use the Checkstyle ImportControl check for enforcing the project layering/dependency rules. The immediate feedback this gives in the Eclipse IDE via the eclipse-cs is invaluable. That said, Classycle looks very capable.