Package org.machanism.machai.project.layout


package org.machanism.machai.project.layout
APIs for detecting, describing, and working with a repository's on-disk project layout.

This package centers on ProjectLayout, an abstraction that models a project as a root directory plus conventional, root-relative locations such as production sources, tests, resources, and documentation roots. Implementations typically infer these locations by applying build-tool conventions and/or inspecting build metadata (for example, Maven pom.xml, Gradle build files, JavaScript package.json workspaces, or Python pyproject.toml).

Responsibilities

  • Represent the project root directory and resolve root-relative locations for common folders.
  • Enumerate modules for multi-module repositories and provide module identifiers relative to the project root.
  • Offer consistent access to sources, tests, resources, and documentation roots across different build systems.

Terminology

  • Project root: configured via ProjectLayout.projectDir(java.io.File). Most accessors assume the root is configured.
  • Root-relative paths: returned locations are typically expressed relative to ProjectLayout.getProjectDir() and should be resolved against that directory prior to filesystem access.
  • Modules: nested projects discovered by a build tool (for example, Maven reactor modules, Gradle multi-project builds, JavaScript workspaces). Module identifiers are generally root-relative.

Provided implementations

  • MavenProjectLayout reads pom.xml (via PomReader) to determine modules and conventional source/test/resource roots.
  • GragleProjectLayout uses Gradle build metadata to return conventional source/test/document roots.
  • JScriptProjectLayout parses package.json workspaces and resolves module directories by matching workspace glob patterns.
  • PythonProjectLayout detects Python projects using pyproject.toml metadata.
  • DefaultProjectLayout provides a minimal filesystem-based fallback and may treat immediate subdirectories as potential modules.

Example


 java.io.File projectDir = new java.io.File("C:\\repo");

 ProjectLayout layout = new MavenProjectLayout().projectDir(projectDir);
 java.util.List<String> modules = layout.getModules();
 java.util.Collection<String> sources = layout.getSources();
 java.util.Collection<String> tests = layout.getTests();
 java.util.Collection<String> docs = layout.getDocuments();