Old post from Dec 11th, 2009
———————-
After some months evaluating Architecture Rules (AR for sort, web http://wiki.architecturerules.org/index.php?title=Main_Page) for serious use, and fiddling in a hate-love relationship with this tool (very good idea, not so well documented, some extrange behaviours that almost makes you resign), I found in their SVN and Maven repository that they have posted there the RC1 (release candidate) of the new 3.0.0 release.
For those that do not know about AR, this tool builds on top of JDepend to analyze the architecture, understood as module relationships and valid dependencies, of a Java project.
JDepend calculates OO metrics (Afferent, Efferent couplings, Instability, Abstractness, Distance) and also checks for circular dependencies between Java packages. JDepend is very fine, produces reports, has a fine GUI and there is an Eclipse plug-in available for your convenient use, but it is not easy to do validations in automated builds and continuous integration.
AR offers that. You can automate your architecture validation as an Ant task, Maven plug-in or, as it is most interesting to me, as a JUnit test case.
Thus, why this post? AR can be frustrating. You can easily get lost in dependencies, not found files and folders and different behaviours in unit tests if executed from Eclipse or from Maven. And this is why I would like to share some of my findings.
First, consider how to run it in an automated way. The Ant task or Maven plug-in have a disadvantage, they break the build if the architecture validation does not pass. It can be good for you but in my opinion I just want to know whether rules are being followed and continue with the rest of the build process, eventually running Sonar and publishing my results in Sonar dashboard.
So I finally decided to go for the JUnit test case. I can give you details on running in Ant and Maven but in this post from now on I will focus on JUnit and I will split the rest of the contents in these areas:
1. Dependencies.
2. Configuration.
3. Writing the test case.
4. Running.
Continue reading →