Architecture Rules

Download 2.1.1

About

Assert Your Architecture! with this open source java library. Architecture Rules leverages an xml configuration file and optional programmatic configuration to assert your code's architecture via unit tests or ant tasks. This test is able to assert that specific packages do not depend on others and is able to check for and report on cyclic dependencies among your project's packages and classes. This project wraps a industry accepted JDepend to simplify the process of maintaining a solid software architecture.

License

Licensed under Apache License 2.0 - allows use of the source code for the development of free and open source software as well as proprietary and closed source software.

Do you Assert your Architecture? Please help out with our fund raising.
Checkout what we are raising funds for. Be sure to report issues.

Sample Configuration - Simple

Back to Code By Example

Description

This is an example of a simple configuration. It should be complete enough that you could copy and paste it into your own architecture-rules.xml change a line or two, and be up and running with Architecture Rules in a matter of minutes.

This example provides all of the optional configuration values, such as sources not found, and the cyclic dependency testing.

If you only have one target directory, then be sure to delete the other ones.

Code


 <architecture>  

     <configuration>  

         <sources no-packages="exception">
             <source not-found="ignore">core\target\classes</source>
             <source not-found="ignore">web\target\classes</source>
             <source not-found="exception">ws\target\classes</source>
         </sources>  

         <cyclicalDependency test="true"></cyclicalDependency>  

     </configuration>  

     <rules>  

         <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.jdbc</package>
             </packages>
             <violations>
                 <violation>com.co.app.core.services</violation>
                 <violation>com.co.app.web</violation>
                 <violation>com.co.app.web.spring</violation>
             </violations>
          </rule>  

          <rule id="web">
             <comment>
                 presentation layer may not use dao directly
             </comment>
             <packages>
                 <package>com.co.app.web</package>
                 <package>com.co.app.web.spring</package>
                 <package>com.co.app.web.decorators</package>
             </packages>
             <violations>
                 <violation>com.co.app.core.dao</violation>
                 <violation>com.co.app.core.dao.jdbc</violation>
                 <violation>com.co.app.core.dao.ldap</violation>
             </violations>
         </rule>  

     </rules>  

 </architecture>  

Leave a Comment

Back to Code By Example

Start Here

Get Help

More Information

Architecture Propaganda

Schwag

If you assert your architecture, then let everyone know with this branded gear. architecture rules mug