Package org.machanism.machai.project.layout


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

A ProjectLayout represents a configured project root and exposes conventional locations as paths relative to that root. The concrete implementations in this package adapt that common API to Maven, Gradle, JavaScript/TypeScript, Python, and unknown project structures. Callers should configure the root with ProjectLayout.projectDir(java.io.File) before querying a layout.

Responsibilities

  • Expose production-source, test-source, and documentation directories as root-relative paths.
  • Discover child modules from build metadata or filesystem conventions where the ecosystem supports it.
  • Provide project identifiers, names, parent identifiers, and a layout type when the underlying metadata supplies them.
  • Offer shared path, directory-scanning, exclusion, and temporary-directory utilities through ProjectLayout.
  • Parse Maven descriptors and serialize Maven models with PomReader.

Supported layouts

  • MavenProjectLayout reads pom.xml, including Maven modules, build source roots, resources, tests, project coordinates, and parent coordinates.
  • GradleProjectLayout uses the Gradle Tooling API for project and child-module names and supplies conventional src/main, src/test, and src/site roots.
  • JScriptProjectLayout reads package.json workspace globs and identifies matching workspace directories containing their own package descriptor.
  • PythonProjectLayout recognizes public projects described by pyproject.toml; source, test, and documentation discovery currently returns empty collections.
  • DefaultProjectLayout provides a filesystem fallback that treats non-excluded immediate subdirectories as module candidates and returns empty location collections.

Typical usage


 java.io.File projectDir = new java.io.File("repo");
 ProjectLayout layout = new MavenProjectLayout().projectDir(projectDir);
 java.util.Collection<String> sources = layout.getSources();
 java.util.Collection<String> tests = layout.getTests();
 java.util.List<String> modules = layout.getModules();
 

Returned paths are intended to be resolved against projectDir. A layout may return null for modules when the project is not a parent project; callers should therefore handle that result according to the selected implementation's contract.