Fork me on GitHub

Project Layout

Maven Central

Introduction

Project Layout is a small utility library for describing and working with conventional project directory layouts (sources, resources, tests, docs, etc.) in a consistent way. It is intended for build tooling and plugins that need to locate well-known folders reliably across different projects.

By centralizing these conventions in one place, tools and plugins can avoid hard-coded paths, reduce duplicated logic, and behave consistently across projects.

Overview

Project Layout provides:

  • A model for well-known project directories (for example, src/main/java, src/test/resources, src/site).
  • Concrete layout definitions for common ecosystems.
  • Utilities to resolve layout paths relative to a project base directory and (when applicable) derive layout information from project metadata (for example, pom.xml).

The main value proposition is to give build tools, scanners, generators, and plugins a single dependable way to reason about project folder conventions, improving consistency and reducing duplicated path logic.

Key Features

  • Standardized representation of common project folders (sources, resources, tests, docs)
  • Built-in layout definitions:
    • Maven (MavenProjectLayout)
    • Gradle (GradleProjectLayout)
    • JavaScript (JScriptProjectLayout)
    • Python (PythonProjectLayout)
    • Default (DefaultProjectLayout)
  • Utilities for reading and deriving layout information from project metadata (for example, pom.xml via PomReader)
  • Resolves layout paths relative to a given project base directory
  • Designed to be embedded in other tools/plugins that need consistent path conventions

Getting Started

Prerequisites

  • Java 8+ (runtime)
  • Maven 3.x (build)

Basic Usage

Add the dependency:

<dependency>
  <groupId>org.machanism.machai</groupId>
  <artifactId>project-layout</artifactId>
  <version>${project.version}</version>
</dependency>

Typical Workflow

  1. Add project-layout as a dependency to your build/tooling project.
  2. Select a layout definition that matches your target project type (for example, MavenProjectLayout or GradleProjectLayout).
  3. Provide a base directory (project root) and resolve the directories you need (main sources, test sources, resources, docs).
  4. Use the resolved paths in your tooling logic (scanners, generators, compilers, packagers).

Resources