Class MavenProjectLayout
java.lang.Object
org.machanism.machai.project.layout.ProjectLayout
org.machanism.machai.project.layout.MavenProjectLayout
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns documentation source directories for Maven projects.org.apache.maven.model.ModelgetModel()Returns the parsed Maven model for the configured project directory.Returns a list of modules for multi-module Maven projects.Returns the parent artifactId, if a parent is configured.Returns the Maven artifactId as the project identifier.Returns the Maven project name.Returns a list of source directories for the Maven project.getTests()Returns a list of test directories for the Maven project.static booleanisMavenProject(File projectDir) Checks whether the given directory appears to be a Maven project.model(org.apache.maven.model.Model model) Sets the Maven model directly.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
findDirectories, findFiles, getExcludeDirs, getProjectDir, getProjectLayoutType, getRelativePath, getRelativePath, getRelativePath
-
Constructor Details
-
MavenProjectLayout
public MavenProjectLayout()
-
-
Method Details
-
isMavenProject
Checks whether the given directory appears to be a Maven project.- Parameters:
projectDir- directory to check- Returns:
trueif apom.xmlfile exists in the directory;falseotherwise
-
getModules
Returns a list of modules for multi-module Maven projects.A project is treated as multi-module when its
packagingispom.- Overrides:
getModulesin classProjectLayout- 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
Sets the Maven model directly.- Parameters:
model- Maven model- Returns:
- this instance for chaining
-
getSources
Returns a list of source directories for the Maven project.The method inspects the Maven
buildsection. When source/test source directories are not defined, it applies Maven defaults.- Specified by:
getSourcesin classProjectLayout- Returns:
- list of source and resource directories, expressed as paths relative to the configured project root
-
getDocuments
Returns documentation source directories for Maven projects.- Specified by:
getDocumentsin classProjectLayout- Returns:
- list containing
src/site
-
getTests
Returns a list of test directories for the Maven project.- Specified by:
getTestsin classProjectLayout- Returns:
- list of test source and test resource directories, expressed as paths relative to the configured project root
-
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 Maven artifactId as the project identifier.- Overrides:
getProjectIdin classProjectLayout- Returns:
- artifactId
-
getProjectName
Returns the Maven project name.- Overrides:
getProjectNamein classProjectLayout- Returns:
- name or
nullif not defined
-
getParentId
Returns the parent artifactId, if a parent is configured.- Overrides:
getParentIdin classProjectLayout- Returns:
- parent artifactId or
null
-