Class GradleProjectLayout
java.lang.Object
org.machanism.machai.project.layout.ProjectLayout
org.machanism.machai.project.layout.GradleProjectLayout
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.LoggerLogger used when the Gradle model cannot be loaded.private org.gradle.tooling.model.GradleProjectCached Gradle model for the configured project root.private static final StringConventional Gradle build descriptor used for project detection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns conventional documentation roots for Gradle projects.Returns a list of child module names for multi-project Gradle builds.private org.gradle.tooling.model.GradleProjectLoads and caches the Gradle model for the configured project root.Returns the Gradle project name as a stable identifier.Returns the Gradle project name.Returns conventional production source roots for Gradle projects.getTests()Returns conventional test source roots for Gradle projects.static booleanisGradleProject(File projectDir) Checks whether the given directory appears to be a Gradle project.projectDir(File projectDir) Sets the project directory and narrows the return type for fluent usage.Methods inherited from class org.machanism.machai.project.layout.ProjectLayout
getExcludeDirs, getParentId, getProjectDir, getProjectLayoutType, getRelativePath, getRelativePath, getRelativePath, getTempDir, isExcludedPath, listDirectories, listFiles
-
Field Details
-
logger
private static final org.slf4j.Logger loggerLogger used when the Gradle model cannot be loaded. -
PROJECT_MODEL_FILE_NAME
Conventional Gradle build descriptor used for project detection.- See Also:
-
project
private org.gradle.tooling.model.GradleProject projectCached Gradle model for the configured project root.
-
-
Constructor Details
-
GradleProjectLayout
public GradleProjectLayout()Creates a Gradle project layout instance.
-
-
Method Details
-
isGradleProject
Checks whether the given directory appears to be a Gradle project.- Parameters:
projectDir- directory to check- Returns:
trueifbuild.gradleexists in the directory;falseotherwise
-
getModules
Returns a list of child module names for multi-project Gradle builds.- Overrides:
getModulesin classProjectLayout- Returns:
- list of child project names (root-relative module identifiers), or empty list if the build has no children
-
getProject
private org.gradle.tooling.model.GradleProject getProject()Loads and caches the Gradle model for the configured project root.- Returns:
- the Gradle model, or
nullwhen no root is configured or model loading fails
-
getSources
Returns conventional production source roots for Gradle projects.- Specified by:
getSourcesin classProjectLayout- Returns:
- list containing
src/main
-
getDocuments
Returns conventional documentation roots for Gradle projects.- Specified by:
getDocumentsin classProjectLayout- Returns:
- list containing
src/site
-
getTests
Returns conventional test source roots for Gradle projects.- Specified by:
getTestsin classProjectLayout- Returns:
- list containing
src/test
-
projectDir
Sets the project directory and narrows the return type for fluent usage.- Overrides:
projectDirin classProjectLayout- Parameters:
projectDir- project root directory- Returns:
- this layout instance
-
getProjectId
Returns the Gradle project name as a stable identifier.- Overrides:
getProjectIdin classProjectLayout- Returns:
- project name or empty string if the model cannot be loaded
-
getProjectName
Returns the Gradle project name.- Overrides:
getProjectNamein classProjectLayout- Returns:
- project name or empty string if the model cannot be loaded
-