Class Source
- All Implemented Interfaces:
Serializable,InputLocationTracker
directory element, which is relative to the POM.
The directory content can optionally be reduced to a subset with the includes and
excludes elements. The kind of sources (codes, resources, etc.) and their
usage (main code, tests, etc.) is specified by the scope element.
Default source directories
If no source directories are specified, the default values depend on whether module names are specified:src/${scope}/${lang}if no module is specifiedsrc/${module}/${scope}/${lang}if a module is specified
${scope} is the value of the scope element (typically main or test),
${lang} is the value of the lang element (typically java or resources),
and ${module} is the optional module element.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class used to create Source instances. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSource(Source.Builder builder) Constructor for this class, to be called from its subclasses andSource.Builder. -
Method Summary
Modifier and TypeMethodDescriptiongetLang()Specifies the language of the source files - typicallyjavaorresources.Name of the Java module (or other language-specific module) which is built by the sources.getScope()Specifies in which context the source files will be used - typicallymainortest.Specifies an explicit target path, overriding the default value.The version of the platform where the code will be executed.booleanWhether the directory described by this source element should be included in the build.booleanWhether resources are filtered to replace tokens with parameterized values.static Source.BuilderCreates a newSourcebuilder instance.static Source.BuildernewBuilder(boolean withDefaults) Creates a newSourcebuilder instance using default values or not.static Source.BuildernewBuilder(Source from) Creates a newSourcebuilder instance using the specified object as a basis.static Source.BuildernewBuilder(Source from, boolean forceCopy) Creates a newSourcebuilder instance using the specified object as a basis.static SourceCreates a newSourceinstance.static SourcenewInstance(boolean withDefaults) Creates a newSourceinstance using default values or not.with()Creates a new builder with this object as the basis.withDirectory(String directory) Creates a newSourceinstance using the specified directory.withEnabled(boolean enabled) Creates a newSourceinstance using the specified enabled.withExcludes(Collection<String> excludes) Creates a newSourceinstance using the specified excludes.withIncludes(Collection<String> includes) Creates a newSourceinstance using the specified includes.Creates a newSourceinstance using the specified lang.withModule(String module) Creates a newSourceinstance using the specified module.Creates a newSourceinstance using the specified scope.withStringFiltering(boolean stringFiltering) Creates a newSourceinstance using the specified stringFiltering.withTargetPath(String targetPath) Creates a newSourceinstance using the specified targetPath.withTargetVersion(String targetVersion) Creates a newSourceinstance using the specified targetVersion.Methods inherited from class org.apache.maven.api.model.FileSet
getDirectory, newBuilder, newBuilder, toStringMethods inherited from class org.apache.maven.api.model.PatternSet
getExcludes, getImportedFrom, getIncludes, getLocation, getLocationKeys, getLocationKeyStream, newBuilder, newBuilderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.maven.api.model.InputLocationTracker
getImportedFrom, getLocation
-
Constructor Details
-
Source
Constructor for this class, to be called from its subclasses andSource.Builder.- See Also:
-
-
Method Details
-
getScope
Specifies in which context the source files will be used - typicallymainortest.The main scope is used for specifying a directory containing the source of the project. The generated build system will compile the sources from this directory when the project is built. The path given in the
directoryfield is relative to the project descriptor. The default directory for the default language (Java) is"src/main/java".The test scope is used for specifying a directory containing the unit test source of the project. The generated build system will compile these directories when the project is being tested. The path given in the
directoryfield is relative to the project descriptor. The default directory for the default language (Java) is"src/test/java".If no scope is specified, the default is
main.- Returns:
- a
String
-
getLang
Specifies the language of the source files - typicallyjavaorresources. Resources is used as a generic term for scripting languages (e.g., JavaScript or Python) or markup languages (e.g. properties file, JSON or XML).The java language is used for specifying a directory containing the Java sources of the project. The generated build system will compile the sources from this directory using the Java compiler when the project is built. The path given in the
directoryfield is relative to the project descriptor. The default directory for the main Java sources is"src/main/java".The resources language is used for specifying a directory containing the class-path or module-path resources such as properties files or scripts associated with a project. This directory is meant to be different from the main source directory, in that its contents will be copied to the output directory in most cases (since scripts are interpreted rather than compiled). The default directory for the main resources is
"src/main/resources".If no language is specified, the default is
java.- Returns:
- a
String
-
getModule
Name of the Java module (or other language-specific module) which is built by the sources. This element can be specified in a Maven project containing multiple Java modules. It is generally not needed for non-modular projects, or for modular projects having only one module.If a module name is specified for resources or script files, then this value modifies the directory where the files will be copied. For example, if a Java module name is "foo.biz", then the
foo/bar.propertiesresource file will be copied asfoo.biz/foo/bar.properties.This element can be combined with the
targetVersionelement for specifying sources, scripts, or resources that are specific to both a particular module and a target version.- Returns:
- a
String
-
getTargetVersion
The version of the platform where the code will be executed. In a Java environment, this is the value of the--releasecompiler option. If a Java project contains multiple main sources with different target versions, then a multi-version JAR file will be created with the lowest version taken as the base version. If this element is omitted, then the default target version is the compiler default value, which is usually the version of the Java environment running Maven.If a target version, different from the base version, is specified for resources or script files, then this value modifies the directory where the files will be copied. For example, if
targetVersionis 17, then thefoo/bar.propertiesresource file will be copied asMETA-INF/versions/17/foo/bar.properties.This element can be combined with the
moduleelement for specifying sources, scripts, or resources that are specific to both a particular module and a target version.- Returns:
- a
String
-
getTargetPath
Specifies an explicit target path, overriding the default value. The path is relative to the${project.build.outputDirectory}directory, which is typicallytarget/classesin a Java project.When a target path is explicitly specified, the values of the
moduleandtargetVersionelements are not used for inferring the path (they are still used as compiler options however). It means that for scripts and resources, the files below the path specified bydirectoryare copied to the path specified bytargetPathwith the exact same directory structure. It is user's responsibility to put module and version components in thetargetPathif needed.Note that for Java source files, a directory with the module name may still be generated despite above statement about
modulebeing ignored, because that directory is generated by the Java compiler rather than Maven.- Returns:
- a
String
-
isStringFiltering
public boolean isStringFiltering()Whether resources are filtered to replace tokens with parameterized values. The values are taken from thepropertieselement and from the properties in the files listed in thefilterselement.The default value is
false.- Returns:
- a
boolean
-
isEnabled
public boolean isEnabled()Whether the directory described by this source element should be included in the build. This flag provides an easy way to include or exclude some sources depending, for example, o property values defined in profiles. A use case is including optional resources only when the user confirmed a license agreement.The default value is
true.- Returns:
- a
boolean
-
with
Creates a new builder with this object as the basis. -
withIncludes
Creates a newSourceinstance using the specified includes.- Overrides:
withIncludesin classFileSet- Parameters:
includes- the newCollection<String>to use- Returns:
- a
Sourcewith the specified includes
-
withExcludes
Creates a newSourceinstance using the specified excludes.- Overrides:
withExcludesin classFileSet- Parameters:
excludes- the newCollection<String>to use- Returns:
- a
Sourcewith the specified excludes
-
withDirectory
Creates a newSourceinstance using the specified directory.- Overrides:
withDirectoryin classFileSet- Parameters:
directory- the newStringto use- Returns:
- a
Sourcewith the specified directory
-
withScope
-
withLang
-
withModule
-
withTargetVersion
-
withTargetPath
-
withStringFiltering
-
withEnabled
-
newInstance
-
newInstance
-
newBuilder
Creates a newSourcebuilder instance. Equivalent tonewBuilder(true).- Returns:
- a new
Builder - See Also:
-
newBuilder
Creates a newSourcebuilder instance using default values or not.- Parameters:
withDefaults- the boolean indicating whether default values should be used- Returns:
- a new
Builder
-
newBuilder
Creates a newSourcebuilder instance using the specified object as a basis. Equivalent tonewBuilder(from, false).- Parameters:
from- theSourceinstance to use as a basis- Returns:
- a new
Builder
-
newBuilder
Creates a newSourcebuilder instance using the specified object as a basis.- Parameters:
from- theSourceinstance to use as a basisforceCopy- the boolean indicating if a copy should be forced- Returns:
- a new
Builder
-