Class ResourcesMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
CopyResourcesMojo,TestResourcesMojo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanBy default files like.gitignore,.cvsignoreetc.The list of additional filter properties files to be used along with System and project properties, which would be used for the filtering.protected LinkedHashSet<String> Set of delimiters for expressions to filter within the resources.protected StringThe character encoding to use when reading and writing filtered resources.protected StringExpressions preceded with this string won't be interpolated.protected booleanWhether to escape backslashes and colons in windows-style paths.private booleanSupport filtering of filenames folders etc.The list of extra filter properties files to be used along with System properties, project properties, and filter properties files specified in the POM build/filters section, which should be used for the filtering during the current mojo execution.protected booleanCopy any empty directories included in the Resources.private List<org.apache.maven.shared.filtering.MavenResourcesFiltering> List of plexus components hint which implementsMavenResourcesFiltering.filterResources(MavenResourcesExecution).protected org.apache.maven.shared.filtering.MavenResourcesFilteringAdditional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)private FileThe output directory into which to copy the resources.private booleanOverwrite existing files even if the destination files are newer.protected org.apache.maven.project.MavenProjectprotected StringThe character encoding to use when reading and writing filtered properties files.private List<org.apache.maven.model.Resource> The list of resources we want to transfer.protected org.apache.maven.execution.MavenSessionprivate booleanYou can skip the execution of the plugin if you need to.private booleanstop searching endToken at the end of lineprotected booleanIf false, don't use the filters specified in the build/filters section of the POM when processing resources in this mojo execution.protected booleanUse default delimiters in addition to custom delimiters, if any.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate PropertiesThis solves https://issues.apache.org/jira/browse/MRESOURCES-99.
BUT:
This should be done different than defining those properties a second time, cause they have already being defined in Maven Model Builder (package org.apache.maven.model.interpolation) via BuildTimestampValueSource.voidexecute()protected voidexecuteUserFilterComponents(org.apache.maven.shared.filtering.MavenResourcesExecution mavenResourcesExecution) List<org.apache.maven.model.Resource> private booleanisFilteringEnabled(Collection<org.apache.maven.model.Resource> theResources) Determines whether filtering has been enabled for any resource.booleanbooleanbooleanisSkip()booleanvoidsetDelimiters(LinkedHashSet<String> delimiters) voidsetFilters(List<String> filters) voidsetIncludeEmptyDirs(boolean includeEmptyDirs) voidsetOutputDirectory(File outputDirectory) voidsetOverwrite(boolean overwrite) voidsetResources(List<org.apache.maven.model.Resource> resources) voidsetUseDefaultDelimiters(boolean useDefaultDelimiters) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
encoding
The character encoding to use when reading and writing filtered resources. -
propertiesEncoding
The character encoding to use when reading and writing filtered properties files. If not specified, it will default to the value of the "encoding" parameter.- Since:
- 3.2.0
-
outputDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", required=true) private File outputDirectoryThe output directory into which to copy the resources. -
resources
@Parameter(defaultValue="${project.resources}", required=true, readonly=true) private List<org.apache.maven.model.Resource> resourcesThe list of resources we want to transfer. -
project
@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject project -
buildFilters
@Parameter(defaultValue="${project.build.filters}", readonly=true) protected List<String> buildFiltersThe list of additional filter properties files to be used along with System and project properties, which would be used for the filtering.- Since:
- 2.4
- See Also:
-
filters
The list of extra filter properties files to be used along with System properties, project properties, and filter properties files specified in the POM build/filters section, which should be used for the filtering during the current mojo execution.
Normally, these will be configured from a plugin's execution section, to provide a different set of filters for a particular execution. For instance, starting in Maven 2.2.0, you have the option of configuring executions with the id's
default-resourcesanddefault-testResourcesto supply different configurations for the two different types of resources. By supplyingextraFiltersconfigurations, you can separate which filters are used for which type of resource. -
useBuildFilters
@Parameter(defaultValue="true") protected boolean useBuildFiltersIf false, don't use the filters specified in the build/filters section of the POM when processing resources in this mojo execution.- Since:
- 2.4
- See Also:
-
mavenResourcesFiltering
@Component(role=org.apache.maven.shared.filtering.MavenResourcesFiltering.class, hint="default") protected org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering -
mavenResourcesFilteringMap
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) protected org.apache.maven.execution.MavenSession session -
escapeString
Expressions preceded with this string won't be interpolated. Anything else preceded with this string will be passed through unchanged. For example\${foo}will be replaced with${foo}but\\${foo}will be replaced with\\value of foo, if this parameter has been set to the backslash.- Since:
- 2.3
-
overwrite
@Parameter(defaultValue="false") private boolean overwriteOverwrite existing files even if the destination files are newer.- Since:
- 2.3
-
includeEmptyDirs
@Parameter(defaultValue="false") protected boolean includeEmptyDirsCopy any empty directories included in the Resources.- Since:
- 2.3
-
nonFilteredFileExtensions
Additional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)- Since:
- 2.3
-
escapeWindowsPaths
@Parameter(defaultValue="true") protected boolean escapeWindowsPathsWhether to escape backslashes and colons in windows-style paths.- Since:
- 2.4
-
delimiters
Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form
beginToken*endToken. If no*is given, the delimiter is assumed to be the same for start and end.So, the default filtering delimiters might be specified as:
<delimiters> <delimiter>${*}</delimiter> <delimiter>@</delimiter> </delimiters>Since the
@delimiter is the same on both ends, we don't need to specify@*@(though we can).- Since:
- 2.4
-
useDefaultDelimiters
@Parameter(defaultValue="true") protected boolean useDefaultDelimitersUse default delimiters in addition to custom delimiters, if any.- Since:
- 2.4
-
addDefaultExcludes
@Parameter(defaultValue="true") protected boolean addDefaultExcludesBy default files like.gitignore,.cvsignoreetc. are excluded which means they will not being copied. If you need them for a particular reason you can do that by settings this tofalse. This means all files like the following will be copied.- Misc: **/*~, **/#*#, **/.#*, **/%*%, **/._*
- CVS: **/CVS, **/CVS/**, **/.cvsignore
- RCS: **/RCS, **/RCS/**
- SCCS: **/SCCS, **/SCCS/**
- VSSercer: **/vssver.scc
- MKS: **/project.pj
- SVN: **/.svn, **/.svn/**
- GNU: **/.arch-ids, **/.arch-ids/**
- Bazaar: **/.bzr, **/.bzr/**
- SurroundSCM: **/.MySCMServerInfo
- Mac: **/.DS_Store
- Serena Dimension: **/.metadata, **/.metadata/**
- Mercurial: **/.hg, **/.hg/**
- Git: **/.git, **/.git/**
- Bitkeeper: **/BitKeeper, **/BitKeeper/**, **/ChangeSet, **/ChangeSet/**
- Darcs: **/_darcs, **/_darcs/**, **/.darcsrepo, **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail
- Since:
- 3.0.0
-
mavenFilteringHints
List of plexus components hint which implements
MavenResourcesFiltering.filterResources(MavenResourcesExecution). They will be executed after the resources copying/filtering.- Since:
- 2.4
-
mavenFilteringComponents
- Since:
- 2.4
-
supportMultiLineFiltering
@Parameter(defaultValue="false") private boolean supportMultiLineFilteringstop searching endToken at the end of line- Since:
- 2.5
-
fileNameFiltering
@Parameter(defaultValue="false") private boolean fileNameFilteringSupport filtering of filenames folders etc.- Since:
- 3.0.0
-
skip
@Parameter(property="maven.resources.skip", defaultValue="false") private boolean skipYou can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on occasion.- Since:
- 3.0.0
-
-
Constructor Details
-
ResourcesMojo
public ResourcesMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
addSeveralSpecialProperties
This solves https://issues.apache.org/jira/browse/MRESOURCES-99.
BUT:
This should be done different than defining those properties a second time, cause they have already being defined in Maven Model Builder (package org.apache.maven.model.interpolation) via BuildTimestampValueSource. But those can't be found in the context which can be got from the maven core.
A solution could be to put those values into the context by Maven core so they are accessible everywhere. (I'm not sure if this is a good idea). Better ideas are always welcome.The problem at the moment is that maven core handles usage of properties and replacements in the model, but does not the resource filtering which needed some of the properties.
- Returns:
- the new instance with those properties.
-
getCombinedFiltersList
- Returns:
- The combined filters.
-
isFilteringEnabled
Determines whether filtering has been enabled for any resource.- Parameters:
theResources- The set of resources to check for filtering, may benull.- Returns:
trueif at least one resource uses filtering,falseotherwise.
-
getResources
- Returns:
resources
-
setResources
- Parameters:
resources- setresources
-
getOutputDirectory
- Returns:
outputDirectory
-
setOutputDirectory
- Parameters:
outputDirectory- the output folder.
-
isOverwrite
public boolean isOverwrite()- Returns:
overwrite
-
setOverwrite
public void setOverwrite(boolean overwrite) - Parameters:
overwrite- true to overwrite false otherwise.
-
isIncludeEmptyDirs
public boolean isIncludeEmptyDirs()- Returns:
includeEmptyDirs
-
setIncludeEmptyDirs
public void setIncludeEmptyDirs(boolean includeEmptyDirs) - Parameters:
includeEmptyDirs- true/false.
-
getFilters
- Returns:
filters
-
setFilters
- Parameters:
filters- The filters to use.
-
getDelimiters
- Returns:
delimiters
-
setDelimiters
- Parameters:
delimiters- The delimiters to use.
-
isUseDefaultDelimiters
public boolean isUseDefaultDelimiters()- Returns:
useDefaultDelimiters
-
setUseDefaultDelimiters
public void setUseDefaultDelimiters(boolean useDefaultDelimiters) - Parameters:
useDefaultDelimiters- true to use${*}
-
isSkip
public boolean isSkip()- Returns:
skip
-