This post originated from an RSS feed registered with Java Buzz
by Tim Vernum.
Original Post: Detecting Cycles with Classycle
Feed Title: A word used to describe something
Feed URL: http://blog.adjective.org/feed/category/Development/rss2
Feed Description: Tim's random musings on software development, java, jetty and other such frivolities.
Since he was writing about checking for cyclic packages with JDepend, I though it would be
worth showing how to do the same thing with classycle.
Like Oliver, I used to have some clunky ant scripts that called JDepend and
tried to determine whether JDepend had detected any package cycles. It works,
but as you can see from Oliver's blog it's harder than it really should be.
With classycle it's incredibly simple.
Here's a (trimmed down) classycle rules file:
show allPaths onlyFailures
{root} = com.example.system
[all] = ${root}.*
check absenceOfPackageCycles > 1 in [all]
It checks all the classes in the com.example.system.* packages. The only
rule that I've specified here is to check for package cycles, but classycle is
much more powerful than that, and we use it to check layering, and to check
that our package dependencies conform to certain rules (e.g.
com.example.system.ui and com.example.system.persist must be independent of one
another)