Class MavenProjectLayout

java.lang.Object
org.machanism.machai.project.layout.ProjectLayout
org.machanism.machai.project.layout.MavenProjectLayout

public class MavenProjectLayout extends ProjectLayout
A Maven-specific ProjectLayout implementation.

This layout reads Maven build metadata from pom.xml to determine:

  • modules for multi-module projects (when packaging=pom)
  • source and resource directories
  • test source and resource directories
  • documentation inputs (defaults to src/site)
Since:
0.0.2
Author:
Viktor Tovstyi
See Also:
  • Constructor Details

    • MavenProjectLayout

      public MavenProjectLayout()
  • Method Details

    • isMavenProject

      public static boolean isMavenProject(File projectDir)
      Checks whether the given directory appears to be a Maven project.
      Parameters:
      projectDir - directory to check
      Returns:
      true if a pom.xml file exists in the directory; false otherwise
    • getModules

      @Nullable public List<String> getModules()
      Returns a list of modules for multi-module Maven projects.

      A project is treated as multi-module when its packaging is pom.

      Overrides:
      getModules in class ProjectLayout
      Returns:
      list of module directories (as declared in pom.xml), or null if the project is not a parent.
    • getModel

      public org.apache.maven.model.Model getModel()
      Returns the parsed Maven model for the configured project directory.
      Returns:
      Maven model
    • model

      public MavenProjectLayout model(org.apache.maven.model.Model model)
      Sets the Maven model directly.
      Parameters:
      model - Maven model
      Returns:
      this instance for chaining
    • getSources

      public Set<String> getSources()
      Returns a list of source directories for the Maven project.

      The method inspects the Maven build section. When source/test source directories are not defined, it applies Maven defaults.

      Specified by:
      getSources in class ProjectLayout
      Returns:
      list of source and resource directories, expressed as paths relative to the configured project root
    • getDocuments

      public List<String> getDocuments()
      Returns documentation source directories for Maven projects.
      Specified by:
      getDocuments in class ProjectLayout
      Returns:
      list containing src/site
    • getTests

      public List<String> getTests()
      Returns a list of test directories for the Maven project.
      Specified by:
      getTests in class ProjectLayout
      Returns:
      list of test source and test resource directories, expressed as paths relative to the configured project root
    • projectDir

      public MavenProjectLayout projectDir(File projectDir)
      Sets the project directory and narrows the return type for fluent usage.
      Overrides:
      projectDir in class ProjectLayout
      Parameters:
      projectDir - project root directory
      Returns:
      this layout instance
    • getProjectId

      public String getProjectId()
      Returns the Maven artifactId as the project identifier.
      Overrides:
      getProjectId in class ProjectLayout
      Returns:
      artifactId
    • getProjectName

      public String getProjectName()
      Returns the Maven project name.
      Overrides:
      getProjectName in class ProjectLayout
      Returns:
      name or null if not defined
    • getParentId

      public String getParentId()
      Returns the parent artifactId, if a parent is configured.
      Overrides:
      getParentId in class ProjectLayout
      Returns:
      parent artifactId or null