ter Maven2Plugin - Architecture Rules - Wiki

Maven2Plugin

From Architecture Rules - Wiki
Jump to: navigation, search

Contents

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.


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>.

Personal tools