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.

Maven 2 Plugin

Introduction

The maven-architecture-rules-plugin allows you to assert your architecture and include the tests right inside the maven build cycle. You can use this plugin to with zero configuration to leverage our cyclic dependency test or, within just a few minutes, you can write up your architecture-rules.xml to define your software layers.

Lets have a look at:

• Attributes

• How to install

• For a single project

• For a multi-module project

• Use our rules

• Use your rules

• Configuration & Goals

Attributes

  • Requires a Maven 2.0 project to be executed.
  • Executes as an aggregator plugin.
  • Requires dependency resolution of artifacts in scope: compile.
  • Binds by default to the lifecycle phase: test.
  • Invokes the execution of the lifecycle phase compile prior to executing itself.

How to Install

First, add our repository hosted in the Google code’s svn to your pom.xml:


<project>
  <pluginRepositories>
    <pluginRepository>
      <id>whatever.you.like</id>
      <url>
        http://architecturerules.googlecode.com/svn/maven2/
      <url>
      <!-- enable snapshots from this repo -->
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
</project>

For a single project


<project>
  <build>
    <plugins>
      <plugin>
        <groupId>info.manandbytes</groupId>
        <artifactId>
          maven-architecture-rules-plugin
        </artifactId>
        <version>0.0-SNAPSHOT</version>
        <configuration />
        <executions>
          <execution>
            <phase>test</phase>
            <goals>
              <goal>assert</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

For a multi-module project


<project>
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>info.manandbytes</groupId>
          <artifactId>
            maven-architecture-rules-plugin
          </artifactId>
          <version>0.0-SNAPSHOT</version>
          <configuration />
          <executions>
            <execution>
              <phase>test</phase>
              <goals>
                <goal>assert</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>info.manandbytes</groupId>
        <artifactId>
          maven-architecture-rules-plugin
        </artifactId>
        <version>0.0-SNAPSHOT</version>
      </plugin>
    </plugins>
  </build>
</project>

Use our rules

Without defining any of your own rules, we can inspect your code for cyclic dependencies.

You may run mvn test (or any other goal which includes test phase,
i.e. package or verify but not just compile) right now. All
other steps are optional.

Use your rules

See the sample configuration for an example of how to create your own architecture-rules.xml that you can just drop right into your test\resources directory.

Configuration & Goals

The plugin is attached to the test phase already, but if you need to assert your architecture without running all of the phases, you can use the assert goal.

Goal Description
architecture-rules:assert Assert your architecture

The configuration parameters are all optional. We try to provide sensible defaults to minimize on the amount of required declarations.

Name Type Description
configurationFileName String Name of the configuration file used by Architecture Rules.

Default value is: architecture-rules.xml.

failOnError boolean If your failed rules shouldn’t break a build (you *had* to introduce a dependency a day before a release, which of course isn’t nice, but you can easily correct the problem a few days after a release) set this parameter to false.

Default value is: true.

skip boolean Skip current project (i.e. in aggregation or multi-module project ) and don’t run Architecture Rules assertions against it.

Default value is: false.

skipRoot boolean For aggregation or multi-module project we don’t run Architecture Rules assertions by default. To change this behavior use -Darchitecture-rules.skipRoot=false

Default value is: true<.tt>.

Leave a Comment

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