@Mojo(name="resources",
defaultPhase=PROCESS_RESOURCES,
requiresProject=true,
threadSafe=true)
public class ResourcesMojo
extends org.apache.maven.plugin.AbstractMojo
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
addDefaultExcludes
By default files like
.gitignore, .cvsignore etc. |
protected java.util.List<java.lang.String> |
buildFilters
The list of additional filter properties files to be used along with System and project properties, which would
be used for the filtering.
|
protected java.util.LinkedHashSet<java.lang.String> |
delimiters
Set of delimiters for expressions to filter within the resources.
|
protected java.lang.String |
encoding
The character encoding scheme to be applied when filtering resources.
|
protected java.lang.String |
escapeString
Expressions preceded with this string won't be interpolated.
|
protected boolean |
escapeWindowsPaths
Whether to escape backslashes and colons in windows-style paths.
|
private boolean |
fileNameFiltering
Support filtering of filenames folders etc.
|
protected java.util.List<java.lang.String> |
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.
|
protected boolean |
includeEmptyDirs
Copy any empty directories included in the Resources.
|
private java.util.List<org.apache.maven.shared.filtering.MavenResourcesFiltering> |
mavenFilteringComponents |
private java.util.List<java.lang.String> |
mavenFilteringHints
List of plexus components hint which implements
MavenResourcesFiltering.filterResources(MavenResourcesExecution). |
protected org.apache.maven.shared.filtering.MavenResourcesFiltering |
mavenResourcesFiltering |
protected java.util.List<java.lang.String> |
nonFilteredFileExtensions
Additional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)
|
private java.io.File |
outputDirectory
The output directory into which to copy the resources.
|
private boolean |
overwrite
Overwrite existing files even if the destination files are newer.
|
private org.codehaus.plexus.PlexusContainer |
plexusContainer |
protected org.apache.maven.project.MavenProject |
project |
private java.util.List<org.apache.maven.model.Resource> |
resources
The list of resources we want to transfer.
|
protected org.apache.maven.execution.MavenSession |
session |
private boolean |
skip
You can skip the execution of the plugin if you need to.
|
private boolean |
supportMultiLineFiltering
stop searching endToken at the end of line
|
protected boolean |
useBuildFilters
If false, don't use the filters specified in the build/filters section of the POM when processing resources in
this mojo execution.
|
protected boolean |
useDefaultDelimiters
Use default delimiters in addition to custom delimiters, if any.
|
| Constructor and Description |
|---|
ResourcesMojo() |
| Modifier and Type | Method and Description |
|---|---|
private java.util.Properties |
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. |
void |
contextualize(org.codehaus.plexus.context.Context context) |
void |
execute() |
protected void |
executeUserFilterComponents(org.apache.maven.shared.filtering.MavenResourcesExecution mavenResourcesExecution) |
protected java.util.List<java.lang.String> |
getCombinedFiltersList() |
java.util.LinkedHashSet<java.lang.String> |
getDelimiters() |
java.util.List<java.lang.String> |
getFilters() |
java.io.File |
getOutputDirectory() |
java.util.List<org.apache.maven.model.Resource> |
getResources() |
private boolean |
isFilteringEnabled(java.util.Collection<org.apache.maven.model.Resource> theResources)
Determines whether filtering has been enabled for any resource.
|
boolean |
isIncludeEmptyDirs() |
boolean |
isOverwrite() |
boolean |
isSkip() |
boolean |
isUseDefaultDelimiters() |
void |
setDelimiters(java.util.LinkedHashSet<java.lang.String> delimiters) |
void |
setFilters(java.util.List<java.lang.String> filters) |
void |
setIncludeEmptyDirs(boolean includeEmptyDirs) |
void |
setOutputDirectory(java.io.File outputDirectory) |
void |
setOverwrite(boolean overwrite) |
void |
setResources(java.util.List<org.apache.maven.model.Resource> resources) |
void |
setUseDefaultDelimiters(boolean useDefaultDelimiters) |
@Parameter(defaultValue="${project.build.sourceEncoding}")
protected java.lang.String encoding
@Parameter(defaultValue="${project.build.outputDirectory}",
required=true)
private java.io.File outputDirectory
@Parameter(defaultValue="${project.resources}",
required=true,
readonly=true)
private java.util.List<org.apache.maven.model.Resource> resources
@Parameter(defaultValue="${project}",
readonly=true,
required=true)
protected org.apache.maven.project.MavenProject project
@Parameter(defaultValue="${project.build.filters}",
readonly=true)
protected java.util.List<java.lang.String> buildFilters
filters@Parameter protected java.util.List<java.lang.String> 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-resources and default-testResources to supply different configurations
for the two different types of resources. By supplying extraFilters configurations, you can separate
which filters are used for which type of resource.
@Parameter(defaultValue="true") protected boolean useBuildFilters
buildFilters,
filters@Component(role=org.apache.maven.shared.filtering.MavenResourcesFiltering.class,
hint="default")
protected org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering
@Parameter(defaultValue="${session}",
readonly=true,
required=true)
protected org.apache.maven.execution.MavenSession session
@Parameter protected java.lang.String escapeString
\${foo} will be replaced with ${foo} but \\${foo}
will be replaced with \\value of foo, if this parameter has been set to the backslash.@Parameter(defaultValue="false") private boolean overwrite
@Parameter(defaultValue="false") protected boolean includeEmptyDirs
@Parameter protected java.util.List<java.lang.String> nonFilteredFileExtensions
@Parameter(defaultValue="true") protected boolean escapeWindowsPaths
@Parameter protected java.util.LinkedHashSet<java.lang.String> 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).
@Parameter(defaultValue="true") protected boolean useDefaultDelimiters
@Parameter(defaultValue="true") protected boolean addDefaultExcludes
.gitignore, .cvsignore etc. are excluded which means they will not being
copied. If you need them for a particular reason you can do that by settings this to false. This means
all files like the following will be copied.
@Parameter private java.util.List<java.lang.String> mavenFilteringHints
List of plexus components hint which implements
MavenResourcesFiltering.filterResources(MavenResourcesExecution). They will be executed after the
resources copying/filtering.
private org.codehaus.plexus.PlexusContainer plexusContainer
private java.util.List<org.apache.maven.shared.filtering.MavenResourcesFiltering> mavenFilteringComponents
@Parameter(defaultValue="false") private boolean supportMultiLineFiltering
@Parameter(defaultValue="false") private boolean fileNameFiltering
@Parameter(property="maven.resources.skip",
defaultValue="false")
private boolean skip
public void contextualize(org.codehaus.plexus.context.Context context)
throws org.codehaus.plexus.context.ContextException
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizableorg.codehaus.plexus.context.ContextExceptionpublic void execute()
throws org.apache.maven.plugin.MojoExecutionException
execute in interface org.apache.maven.plugin.Mojoorg.apache.maven.plugin.MojoExecutionExceptionprivate java.util.Properties addSeveralSpecialProperties()
protected void executeUserFilterComponents(org.apache.maven.shared.filtering.MavenResourcesExecution mavenResourcesExecution)
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.shared.filtering.MavenFilteringException
mavenResourcesExecution - MavenResourcesExecutionorg.apache.maven.plugin.MojoExecutionException - in case of wrong lookup.org.apache.maven.shared.filtering.MavenFilteringException - in case of failure.protected java.util.List<java.lang.String> getCombinedFiltersList()
private boolean isFilteringEnabled(java.util.Collection<org.apache.maven.model.Resource> theResources)
theResources - The set of resources to check for filtering, may be null.true if at least one resource uses filtering, false otherwise.public java.util.List<org.apache.maven.model.Resource> getResources()
resourcespublic void setResources(java.util.List<org.apache.maven.model.Resource> resources)
resources - set resourcespublic java.io.File getOutputDirectory()
outputDirectorypublic void setOutputDirectory(java.io.File outputDirectory)
outputDirectory - the output folder.public boolean isOverwrite()
overwritepublic void setOverwrite(boolean overwrite)
overwrite - true to overwrite false otherwise.public boolean isIncludeEmptyDirs()
includeEmptyDirspublic void setIncludeEmptyDirs(boolean includeEmptyDirs)
includeEmptyDirs - true/false.public java.util.List<java.lang.String> getFilters()
filterspublic void setFilters(java.util.List<java.lang.String> filters)
filters - The filters to use.public java.util.LinkedHashSet<java.lang.String> getDelimiters()
delimiterspublic void setDelimiters(java.util.LinkedHashSet<java.lang.String> delimiters)
delimiters - The delimiters to use.public boolean isUseDefaultDelimiters()
useDefaultDelimiterspublic void setUseDefaultDelimiters(boolean useDefaultDelimiters)
useDefaultDelimiters - true to use ${*}public boolean isSkip()
skip