Class GragleProjectLayout

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

public class GragleProjectLayout extends ProjectLayout
A Gradle-specific ProjectLayout implementation.

This layout uses the Gradle Tooling API to load a GradleProject model and expose a minimal set of layout information:

  • module names (based on the Gradle project children)
  • conventional source roots (defaults to src/main)
  • conventional test roots (defaults to src/test)
  • documentation inputs (defaults to src/site)

Note: This implementation does not currently parse custom source sets; it returns conventional directories only.

Since:
0.0.2
Author:
Viktor Tovstyi
  • Constructor Details

    • GragleProjectLayout

      public GragleProjectLayout()
  • Method Details

    • isGradleProject

      public static boolean isGradleProject(File projectDir)
      Checks whether the given directory appears to be a Gradle project.
      Parameters:
      projectDir - directory to check
      Returns:
      true if build.gradle exists in the directory; false otherwise
    • getModules

      public List<String> getModules()
      Returns a list of child module names for multi-project Gradle builds.
      Overrides:
      getModules in class ProjectLayout
      Returns:
      list of child project names (root-relative module identifiers), or empty list if the build has no children
    • getSources

      public List<String> getSources()
      Returns conventional production source roots for Gradle projects.
      Specified by:
      getSources in class ProjectLayout
      Returns:
      list containing src/main
    • getDocuments

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

      public List<String> getTests()
      Returns conventional test source roots for Gradle projects.
      Specified by:
      getTests in class ProjectLayout
      Returns:
      list containing src/test
    • projectDir

      public GragleProjectLayout 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 Gradle project name as a stable identifier.
      Overrides:
      getProjectId in class ProjectLayout
      Returns:
      project name or empty string if the model cannot be loaded
    • getProjectName

      public String getProjectName()
      Returns the Gradle project name.
      Overrides:
      getProjectName in class ProjectLayout
      Returns:
      project name or empty string if the model cannot be loaded