jMolecules - ArchUnit rules

Architectural concepts in Java

License

License

GroupId

GroupId

org.jmolecules
ArtifactId

ArtifactId

jmolecules-archunit
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

jMolecules - ArchUnit rules
Architectural concepts in Java

Download jmolecules-archunit

How to add to project

<!-- https://jarcasting.com/artifacts/org.jmolecules/jmolecules-archunit/ -->
<dependency>
    <groupId>org.jmolecules</groupId>
    <artifactId>jmolecules-archunit</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.jmolecules/jmolecules-archunit/
implementation 'org.jmolecules:jmolecules-archunit:1.0.0'
// https://jarcasting.com/artifacts/org.jmolecules/jmolecules-archunit/
implementation ("org.jmolecules:jmolecules-archunit:1.0.0")
'org.jmolecules:jmolecules-archunit:jar:1.0.0'
<dependency org="org.jmolecules" name="jmolecules-archunit" rev="1.0.0">
  <artifact name="jmolecules-archunit" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jmolecules', module='jmolecules-archunit', version='1.0.0')
)
libraryDependencies += "org.jmolecules" % "jmolecules-archunit" % "1.0.0"
[org.jmolecules/jmolecules-archunit "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jmolecules : jmolecules-ddd jar 1.0.0
com.tngtech.archunit : archunit jar 0.13.1
org.springframework : spring-core jar 5.2.6.RELEASE

Project Modules

There are no modules declared in this project.

jMolecules – Architectural abstractions for Java

A set of libraries to help developers work with architectural concepts in Java. Goals:

  • Express that a piece of code (package, class, method…​) implements an architectural concept.

  • Make it easy for the human reader to determine what kind of architectural concepts a given piece of code is.

  • Allow tool integration (to do interesting stuff like generating persistence or static architecture analysis to check for validations of the architectural rules.)

Expressing DDD concepts

Example:

import org.jmolecules.ddd.annotation.*;

@Entity
public class BankAccount { /* ... */ }

@ValueObject
public class Currency { /* ... */ }

@Repository
public class Accounts { /* ... */ }

When we take Ubiquitous Language serious, we want names (for classes, methods, etc.) that only contain words from the domain language. That means the titles of the building blocks should not be part of the names. So in a banking domain we don’t want BankAccountEntity, CurrencyVO or even AccountRepository as types. Instead, we want BankAccount, Currency and Accounts – like in the example above.

Still, we want to express that a given class (or other architectural element) is a special building block; i.e. uses a design pattern. jMolecules provide a set of standard annotations (and alternatively marker interfaces) for the building blocks known from DDD.

Libraries

  • jmolecules-ddd — annotations and interfaces to express DDD building blocks (value objects, entities, aggregate roots etc.) in code.

  • jmolecules-events — annotations and interfaces to express the concept of events in code.

Expressing architecture

jMolecules provides annotations to mark a package as a layer (or ring):

import org.jmolecules.architecture.layered.*;

@DomainLayer
package org.acmebank.domain;

@ApplicationLayer
package org.acmebank.application;

That way, all classes in the respective package are considered to be part of the annotated layer.

Alternatively, classes can be annotated directly:

import org.jmolecules.architecture.layered.*;

@DomainLayer
@Entity
public class BankAccount { /* ... */ }

@ApplicationLayer
@Service
public class TransferMoney { /* ... */ }

Currently, annotations for Layered and Onion Architecture exist.

Libraries

  • jmolecules-architecture — annotations to express architectural styles in code.

    • jmolecules-architecture-layered — Layered architecture

      • @DomainLayer

      • @ApplicationLayer

      • @InfrastructureLayer

      • @InterfaceLayer

    • jmolecules-architecture-onion — Onion architecture

      • Classic

        • @DomainModelRing

        • @DomainServiceRing

        • @ApplicationServiceRing

        • @InfrastructureRing

      • Simplified (does not separate domain model and services)

        • @DomainRing

        • @ApplicationRing

        • @InfrastructureRing

Technology integration

  • jmolecules-archunit — ArchUnit rules that verify the aggregate structures in your model.

  • jmolecules-jpa — A ByteBuddy plugin to derive default JPA mappings for code that expresses DDD building blocks via jmolecules-ddd.

  • jmolecules-spring — A ByteBuddy plugin to derive Spring component annotations for code that expresses DDD building blocks via jmolecules-ddd.

Examples

  • jmolecules-examples — A collection of examples to showcase the usage of the concept types and annotations as well as the technology integration.

Installation

To use jMolecules in your project just install it from the Maven central repository.

Maven

<dependency>
  <groupId>org.jmolecules</groupId>
  <artifactId>jmolecules-ddd</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle

compile("org.jmolecules:jmolecules-ddd:1.0.0")

Release instructions

  • mvn release:prepare -DscmReleaseCommitComment="$ticketId - Release version $version." -DscmDevelopmentCommitComment="$ticketId - Prepare next development iteration."

  • mvn release:perform -Dgpg.keyname=$keyname

org.jmolecules

xMolecules

Architectural abstractions in code. Logo by Stephanie Leeson for thenounproject.com

Versions

Version
1.0.0