Common Dependency Rules

Modular Java,
by convention

CODERU enforces clean module boundaries directly in your package hierarchy — no separate config file, no custom DSL. Just four reserved package names and an automated rule checker.

Get Started Read the Rules

Why CODERU?

Java's built-in package system doesn't prevent unwanted cross-module dependencies. CODERU closes that gap.

⚠

The Problem

Java offers no language construct to define module hierarchies or restrict inter-package access. In large codebases this inevitably leads to tangled, spaghetti-like dependencies that violate information hiding.

◈

The Solution

CODERU stands for Common Dependency Rules. Four reserved package names — api, impl, common, factory — each carry precise access semantics that are checked automatically at build time.

⚙

Automated Enforcement

A design rule is worthless if violations go undetected. CODERU ships as a Maven plugin and a JUnit adapter so rule violations break the build, not just a code-review comment.

How it works

Place your classes into packages whose names follow the CODERU conventions and the tool infers all access rights automatically.

▶

api

Publicly accessible from anywhere in the program — the stable interface of a module. Typically holds interfaces and value types.

■

impl

Private to the direct parent module only. Implementation details stay hidden from the rest of the codebase — enforced at build time.

◆

common

Shared utilities visible to all sibling modules (and their descendants), but not to unrelated parts of the tree.

★

factory

Can access all siblings including impl — the designated place for wiring / dependency-injection logic without leaking internals.

How CODERU compares

CODERU targets intra-module structure — a complementary layer to existing tools.

Tool Scope Definition location Granularity
CODERU Intra-module (inside a JAR) Package names in source code Any depth
OSGi / Jigsaw Inter-module (between JARs) Manifest / module-info JAR level
Sonargraph / Structure101 Architecture-level Separate proprietary config High-level
ArchUnit Custom rules JUnit test code Pattern-based

Quick start

Add one plugin entry to your pom.xml and your next build will catch all violations.

Maven plugin

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

See the Usage Guide for incremental adoption strategies, package exclusions, and the JUnit adapter.