Exceptions
This page documents the many Exceptions that the Architecture Rules library may through throughout the course of building the configuration, and executing the rules and cyclic dependency testing. All of these exceptions are RuntimeExceptions unless otherwise stated.
CyclicRedundencyException
If the cyclic redundancy test is run (via setting <cyclicalDependency test=”true”/>) and any cyclic redundancies are found, this exception is thrown.
When any cyclic dependencies are encountered, this exception is thrown. The exception message will report all packages that are involved in cyclic dependencies.
An example message looks like:
...architecturerules.exceptions.CyclicRedundancyException: cyclic dependencies found: -- test.com.seventytwomiles.services | | | |-- test.com.seventytwomiles.model | | | |-- test.com.seventytwomiles.dao.hibernate | | -- test.com.seventytwomiles.model | | | |-- test.com.seventytwomiles.services | | -- test.com.seventytwomiles.dao.hibernate | |-- test.com.seventytwomiles.services
DependencyConstraintException
When any defined violation occurs, this exception is thrown. The message will tell you which package was violated, who who the violating package was.
The message (as of the time of this writing) looks like:
dependency constraint failed in 'dao' rule which constrains packages 'com.seventytwomiles.dao'
IllegalArchitectureRuleException
IllegalArchitectureRuleException is thrown when a rule defines a violation in the package that it describes.
For example:
<rule id="dao"> <comment> dao layer depends on no other layers </comment> <packages> <package>com.company.app.core.dao</package> <package>com.company.app.core.dao.hibernate</package> </packages> <violations> <violation>com.company.app.core.dao</violation> </violations> </rule>
Would throw this exception because JDepend can not test that the dao package does not depend on the dao package. An exception is thrown telling you to remove this violation. The violation could be ignored by the tests, but it is not. Users should understand that this can not be tested and remove this violation.
SourceNotFoundException
When a source is defined and the not-found property is set to exception this SourceNotFoundException will be thrown if the source directory does not exist or can not be found.
<source>core/target/classes</source>
If you are getting this exception and don’t want it because you understand that your entire project was not built and so a given source may not exit all the time, then use this configuration:
<source not-found="ignore">...</source>
The default not-found value is exception.
NoPackagesFoundException
<source not-found="exception">...</source>
Once all of the defined source elements have been loaded, if no classes are found the NoPackagesFoundException is thrown. When no packages are found, no tests are run, which can be deceiving when everything comes back looking okay.
To disable this exception (which is not recommended) set:
<sources no-packages="ignore">
The default value for no-packages is exception
1 Comment »
RSS feed for comments on this post · TrackBack URI
Posted by Architecture Rules 102 | 72 Miles
June 5, 2008 @ 8:52 am
[...] defined source directories, if no classes are found, then throw an Exception, more specifically, a NoPackagesFoundException. Here are the configuration options for [...]