Package org.apache.maven.impl
Record Class DefaultSourceRoot
java.lang.Object
java.lang.Record
org.apache.maven.impl.DefaultSourceRoot
- Record Components:
scope- in which context the source files will be used (main or test)language- language of the source filesmoduleName- name of the Java module which is built by the sourcestargetVersionOrNull- version of the platform where the code will be executeddirectory- root directory where the sources are storedincludes- patterns for the files to include, or empty if unspecifiedexcludes- patterns for the files to exclude, or empty if nothing to excludestringFiltering- whether resources are filtered to replace tokens with parameterized valuestargetPathOrNull- an explicit target path, overriding the default valueenabled- whether the directory described by this source element should be included in the build
- All Implemented Interfaces:
SourceRoot
public record DefaultSourceRoot(ProjectScope scope, Language language, @Nullable String moduleName, @Nullable Version targetVersionOrNull, Path directory, List<String> includes, List<String> excludes, boolean stringFiltering, @Nullable Path targetPathOrNull, boolean enabled)
extends Record
implements SourceRoot
A default implementation of
SourceRoot built from the model.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSourceRoot(Path baseDir, ProjectScope scope, Resource resource) Creates a new instance from the given resource.DefaultSourceRoot(ProjectScope scope, Language language, String moduleName, Version targetVersionOrNull, Path directory, List<String> includes, List<String> excludes, boolean stringFiltering, Path targetPathOrNull, boolean enabled) Canonical constructor.DefaultSourceRoot(ProjectScope scope, Language language, Path directory) Creates a simple instance with no Java module, no target version, and no include or exclude pattern. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedirectoryrecord component.booleanenabled()Returns the value of theenabledrecord component.final booleanIndicates whether some other object is "equal to" this one.excludes()Returns the value of theexcludesrecord component.static DefaultSourceRootCreates a new instance from the given model.final inthashCode()Returns a hash code value for this object.includes()Returns the value of theincludesrecord component.language()Returns the value of thelanguagerecord component.matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes) Returns a matcher combining the include and exclude patterns.module()Returns the name of the Java module (or other language-specific module) which is built by the sources.Returns the value of themoduleNamerecord component.scope()Returns the value of thescoperecord component.booleanReturns the value of thestringFilteringrecord component.Returns an explicit target path, overriding the default value.Returns the value of thetargetPathOrNullrecord component.Returns the version of the platform where the code will be executed.Returns the value of thetargetVersionOrNullrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.maven.api.SourceRoot
targetPath
-
Constructor Details
-
DefaultSourceRoot
Creates a simple instance with no Java module, no target version, and no include or exclude pattern.- Parameters:
scope- in which context the source files will be used (main or test)language- the language of the source filesdirectory- the root directory where the sources are stored
-
DefaultSourceRoot
public DefaultSourceRoot(@Nonnull ProjectScope scope, @Nonnull Language language, @Nullable String moduleName, @Nullable Version targetVersionOrNull, @Nullable Path directory, @Nullable List<String> includes, @Nullable List<String> excludes, boolean stringFiltering, @Nullable Path targetPathOrNull, boolean enabled) Canonical constructor.- Parameters:
scope- in which context the source files will be used (main or test)language- language of the source filesmoduleName- name of the Java module which is built by the sourcestargetVersionOrNull- version of the platform where the code will be executeddirectory- root directory where the sources are storedincludes- patterns for the files to include, ornullor empty if unspecifiedexcludes- patterns for the files to exclude, ornullor empty if nothing to excludestringFiltering- whether resources are filtered to replace tokens with parameterized valuestargetPathOrNull- an explicit target path, overriding the default valueenabled- whether the directory described by this source element should be included in the build
-
DefaultSourceRoot
Creates a new instance from the given resource. This is used for migration from the previous way of declaring resources.Important: The
targetPathfrom the resource is stored as-is (converted to aPathbut not resolved against any directory). This preserves the Maven 3.x behavior wheretargetPathis relative to the output directory, not the project base directory. The actual resolution happens later viaSourceRoot.targetPath(Project).- Parameters:
baseDir- the base directory for resolving relative paths (used only for the source directory)scope- the scope of the resource (main or test)resource- a resource element from the model
-
-
Method Details
-
fromModel
public static DefaultSourceRoot fromModel(Session session, Path baseDir, Function<ProjectScope, String> outputDir, Source source) Creates a new instance from the given model.- Parameters:
session- the session of resolving extensible enumerationsbaseDir- the base directory for resolving relative pathsoutputDir- supplier of output directory relative tobaseDirsource- a source element from the model
-
matcher
Returns a matcher combining the include and exclude patterns.- Specified by:
matcherin interfaceSourceRoot- Parameters:
defaultIncludes- the default includes if unspecified by the useruseDefaultExcludes- whether to add the default set of patterns to exclude, mostly Source Code Management (SCM) files- Returns:
- a matcher combining the include and exclude patterns
-
module
Returns the name of the Java module (or other language-specific module) which is built by the sources.- Specified by:
modulein interfaceSourceRoot- Returns:
- the name of the Java module (or other language-specific module) which is built by the sources
-
targetVersion
Returns the version of the platform where the code will be executed.- Specified by:
targetVersionin interfaceSourceRoot- Returns:
- the version of the platform where the code will be executed
-
targetPath
Returns an explicit target path, overriding the default value.The returned path, if present, is stored as provided in the configuration and is typically relative to the output directory. Use
SourceRoot.targetPath(Project)to get the fully resolved absolute path.- Specified by:
targetPathin interfaceSourceRoot- Returns:
- an explicit target path, overriding the default value
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
scope
Returns the value of thescoperecord component.- Specified by:
scopein interfaceSourceRoot- Returns:
- the value of the
scoperecord component
-
language
Returns the value of thelanguagerecord component.- Specified by:
languagein interfaceSourceRoot- Returns:
- the value of the
languagerecord component
-
moduleName
Returns the value of themoduleNamerecord component.- Returns:
- the value of the
moduleNamerecord component
-
targetVersionOrNull
Returns the value of thetargetVersionOrNullrecord component.- Returns:
- the value of the
targetVersionOrNullrecord component
-
directory
Returns the value of thedirectoryrecord component.- Specified by:
directoryin interfaceSourceRoot- Returns:
- the value of the
directoryrecord component
-
includes
Returns the value of theincludesrecord component.- Specified by:
includesin interfaceSourceRoot- Returns:
- the value of the
includesrecord component
-
excludes
Returns the value of theexcludesrecord component.- Specified by:
excludesin interfaceSourceRoot- Returns:
- the value of the
excludesrecord component
-
stringFiltering
public boolean stringFiltering()Returns the value of thestringFilteringrecord component.- Specified by:
stringFilteringin interfaceSourceRoot- Returns:
- the value of the
stringFilteringrecord component
-
targetPathOrNull
Returns the value of thetargetPathOrNullrecord component.- Returns:
- the value of the
targetPathOrNullrecord component
-
enabled
public boolean enabled()Returns the value of theenabledrecord component.- Specified by:
enabledin interfaceSourceRoot- Returns:
- the value of the
enabledrecord component
-