Package org.machanism.machai.project.layout


package org.machanism.machai.project.layout
Detects project types and describes their conventional on-disk layouts.

The central contract, ProjectLayout, exposes source, test, and documentation locations together with available module and project-identity metadata. Configure an implementation with its project root using ProjectLayout.projectDir(java.io.File) before calling accessors that inspect project files. Location strings are generally relative to that root; resolve them against the configured directory before filesystem access. The locations describe conventions and, except where noted for exported Access source, do not guarantee that the paths exist.

Layout selection

The descriptor checks provide a way to choose a specialized implementation: MavenProjectLayout.isMavenProject(java.io.File) checks for pom.xml; GradleProjectLayout.isGradleProject(java.io.File) checks for build.gradle; and JScriptProjectLayout.isPackageJsonPresent(java.io.File) checks for package.json. PythonProjectLayout.isPythonProject(java.io.File) additionally validates that pyproject.toml describes a named, non-private project. MSAccessProjectLayout.isAccessProject(java.io.File) recognizes an msaccess-vcs-addin export by the presence of vcs-options.json in the root or an immediate child directory. Use DefaultProjectLayout as a generic fallback when no specialized layout applies; it does not infer source, test, documentation, or module locations.

Supported layouts

  • MavenProjectLayout reads the Maven model. For projects with packaging=pom, it exposes declared modules; it also reports configured or conventional source and test roots, resources, the conventional src/site documentation location, and available project and parent identifiers.
  • GradleProjectLayout uses the Gradle Tooling API for the project model and direct child names. It reports conventional src/main, src/test, and src/site locations and does not inspect custom source sets.
  • JScriptProjectLayout reads array-form workspaces globs from package.json; matching directories are reported only when they contain their own package.json. It does not infer source, test, or documentation locations.
  • PythonProjectLayout recognizes a named, non-private pyproject.toml project but does not currently infer module, source, test, or documentation locations.
  • MSAccessProjectLayout reports the detected msaccess-vcs-addin export directory as a source location; it does not define test or documentation locations.
  • DefaultProjectLayout supplies empty source, test, and documentation collections without interpreting project metadata.

ProjectLayout also provides shared path conversion, directory scanning, exclusion-pattern, project identity, and temporary-directory operations. Maven model parsing and serialization are provided by PomReader.

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();

Some metadata accessors read descriptors when invoked and may report invalid or unreadable input according to the implementation. A null module list may indicate that modules are not declared; callers should handle it rather than assuming every layout returns an empty list.