Architecture Rules eats his own dog food

While adding support for YAML configuration files I introduced a cyclic dependency (shame on me🙂 ) in our code base. If this means nothing to you there are some reasons why introducing cycles considered as a bad practice.

How to catch problems like this one?

Sounds obviously for you? For sure😉

As the problem popped up as soon as it was introduced, fixing it was a trivial task. I absolutely agree with a statement that every piece of code becomes «legacy» few hours after it’s written. Distributed development teams make such things even worse. `Individuals and interactions over processes and tools’ don’t work.

How did I discovered this? First of all, this post is about eating your own dog food, right? One of the purposes of Architecture Rules is to report on cyclic dependencies among your project’s packages and classes. And my build system was ready to catch this with just running mvn test.

How this looks like? As a plain old unit test’s failure:

Results :

Tests in error:
 testArchitecture(org.architecturerules.SimpleArchitectureTest)

Tests run: 99, Failures: 0, Errors: 1, Skipped: 0

In my case more details are in the target/surefire-reports/org.architecturerules.SimpleArchitectureTest.txt:

-------------------------------------------------------------------------------
Test set: org.architecturerules.SimpleArchitectureTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.54 sec <<< FAILURE!
testArchitecture(org.architecturerules.SimpleArchitectureTest)  Time elapsed: 0.532 sec  <<< ERROR!
org.architecturerules.exceptions.CyclicRedundancyException: 2 cyclic dependencies found:

	-- org.architecturerules.configuration.xml depends on 
	|  |
	|  |-- org.architecturerules.configuration
	|	 |-- @ org.architecturerules.configuration.xml.DigesterConfigurationFactory
	|	    \ while 
	|	     |-- org.architecturerules.configuration.DefaultConfigurationFactory
	|	       \ depends on org.architecturerules.configuration.xml
	|
	-- org.architecturerules.configuration depends on
	|  |
	|  |-- org.architecturerules.configuration.xml
	|	 |-- @ org.architecturerules.configuration.DefaultConfigurationFactory
	|	    \ while 
	|	     |-- org.architecturerules.configuration.xml.DigesterConfigurationFactory
	|	       \ depends on org.architecturerules.configuration
	|
	
	at org.architecturerules.services.CyclicRedundancyServiceImpl.buildCyclicRedundancyException(CyclicRedundancyServiceImpl.java:162)
	at org.architecturerules.services.CyclicRedundancyServiceImpl.performCyclicRedundancyCheck(CyclicRedundancyServiceImpl.java:117)
	at org.architecturerules.AbstractArchitectureRulesConfigurationTest.doTests(AbstractArchitectureRulesConfigurationTest.java:143)
	at org.architecturerules.SimpleArchitectureTest.testArchitecture(SimpleArchitectureTest.java:51)

Thanks to our Maven 2 plugin your build will fail too as soon as you introduce cycles in a dependency graph. Even if your project uses Apache Ant (sorry, it’s not my favorite tool😉 ) as a build system, you can download and use our Ant task to get the same result.

How-to setup Ant task? Sorry, it’s still not available and I have any clue. In a response to this post Mike provided this great how-to install and configure guide. Thank you, Mike!