Usage Guide

Introduction

CODERU is available from the Maven Central Repository. There are two ways to integrate the CODERU check tool in your build process:

Example

The different configuration options will be explained on an example project. We suppose there are the following rule violations (shown as red arcs in a diagram):

Example Project Structure with Violations

It is important to notice that dependencies between the classes under "org.coderu.example" package are checked only. The dependencies to and within foreign libraries are not considered.

As Maven Plugin

The simplest way to check your code is to extend the plugins section of the pom with the coderu-maven-plugin.

Basic Configuration

In the basic configuration, you just define one execution with the goal test:

<plugin>
    <groupId>org.coderu</groupId>
    <artifactId>coderu-maven-plugin</artifactId>
    <version>1.1.0</version>
    <executions>
        <execution>
            <id>coderu</id>
            <goals>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Configured this way, the whole code of the project will be covered with the check. The check would expose all violations listed in the example above.

Partial check: Bottom-Up strategy

Although the basic configuration is right for a new project, it may not be possible if the project has not been developed with CODERU in focus from the beginning.

Instead of covering the whole project, it is possible to define particular subtrees to check. In the following configuration, only packages org.coderu.example.common and org.coderu.example.gui.common (and their successors) will be considered:

<configuration>
    <rootPackages>
        <param>org.coderu.example.common</param>
        <param>org.coderu.example.gui.common</param>
    </rootPackages>
</configuration>

The check will consider defined packages only and yield fewer violations.

Partial check: Top-Down strategy

With the depth tag, the "top-down" refactoring strategy is supported. The depth tag defines the depth in the package hierarchy up to which the check will be done.

<configuration>
    <depth>4</depth>
</configuration>

With depth "4", only violations between common, gui, and business will be checked.

Exclude packages from check

Additional to both strategies above, packages can be excluded from the check by defining the excludedPackages tag.

<configuration>
    <excludedPackages>
        <param>org.coderu.example.common.loggig</param>
        <param>org.coderu.example.gui.common</param>
    </excludedPackages>
</configuration>

Prohibit class references in same package

With the tag classesDependencyInPackageAllowed you can prohibit dependencies between classes within the same package.

<configuration>
    <classesDependencyInPackageAllowed>false</classesDependencyInPackageAllowed>
</configuration>

Default value is true. By setting it to false, you enforce all dependencies between classes being mirrored in the package hierarchy. This ensures the absence of cycles on the package level and prevents bad design.

Use synonyms

With the tags public, private, common, and factory, you can rename predefined CODERU package names (api, impl, common, and factory accordingly).

<configuration>
    <public>public_</public>
    <private>private_</private>
    <common>shared</common>
    <factory>builder</factory>
</configuration>