Class ResourcesMojo

java.lang.Object
org.apache.maven.plugins.resources.ResourcesMojo
All Implemented Interfaces:
org.apache.maven.api.plugin.Mojo
Direct Known Subclasses:
CopyResourcesMojo, TestResourcesMojo

@Mojo(name="resources", defaultPhase="process-resources", projectRequired=true) public class ResourcesMojo extends Object implements org.apache.maven.api.plugin.Mojo
Copy resources for the main source code to the main output directory. Always uses the project.build.resources element to specify the resources to copy.
Author:
Michal Maczka, Jason van Zyl, Andreas Hoheneder, William Ferguson
  • Field Details

    • encoding

      @Parameter(defaultValue="${project.build.sourceEncoding}") protected String encoding
      The character encoding to use when reading and writing filtered resources.
    • outputEncoding

      @Parameter(property="maven.resources.outputEncoding") protected String outputEncoding
      The character encoding to use when writing filtered resources. When set, enables encoding conversion during filtering: resources are read with encoding and written with this encoding. Useful to convert legacy EBCDIC or Latin-1 source files to UTF-8 (or vice-versa) as part of the build.

      Common encodings include UTF-8, ISO-8859-1 (Latin-1), US-ASCII, and UTF-16. The full list of supported encodings depends on the JVM implementation; see Charset for details.

      When not set (the default), the same encoding is used for reading and writing, preserving backward compatibility.

      This parameter is ignored when filtering is disabled (i.e. when no resource has <filtering>true</filtering>), because non-filtered files are always copied as raw bytes.

      Since:
      4.0.0-beta-2
    • propertiesEncoding

      @Parameter protected String 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) protected Path outputDirectory
      The output directory into which to copy the resources.

      Note: When setting this parameter, use an execution-specific configuration rather than a global plugin-level configuration, so that the setting does not inadvertently affect the testResources goal. For example:

      
       <executions>
         <execution>
           <id>default-resources</id>
           <configuration>
             <outputDirectory>/custom/output</outputDirectory>
           </configuration>
         </execution>
       </executions>
       

      A plugin-level <configuration> block applies to all goals of the plugin (both resources and testResources), which would override the test output directory and cause test resources to be copied to the wrong location.

    • project

      @Inject protected org.apache.maven.api.Project project
    • buildFilters

      @Parameter(defaultValue="${project.build.filters}", readonly=true) protected List<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.
      Since:
      2.4
      See Also:
    • filters

      @Parameter protected List<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.

    • useBuildFilters

      @Parameter(defaultValue="true") 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.
      Since:
      2.4
      See Also:
    • mavenResourcesFiltering

      @Inject protected org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering
    • mavenResourcesFilteringMap

      @Inject protected Map<String,org.apache.maven.shared.filtering.MavenResourcesFiltering> mavenResourcesFilteringMap
    • session

      @Inject protected org.apache.maven.api.Session session
    • escapeString

      @Parameter protected String 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
    • includeEmptyDirs

      @Parameter(defaultValue="false") protected boolean includeEmptyDirs
      Copy any empty directories included in the Resources.
      Since:
      2.3
    • nonFilteredFileExtensions

      @Parameter protected List<String> nonFilteredFileExtensions
      Additional file extensions to not apply filtering. The following extensions are already excluded from filtering by default: images (jpg, jpeg, gif, bmp, png, ico), Java archives and native libraries (jar, war, ear, aar, rar, jnilib, so, dll, dylib), generic archives (zip, gz, bz2, xz, zst, 7z, tar), executables (exe, bin, class), documents (pdf, doc, docx, xls, xlsx, ppt, pptx), audio/video (mp3, mp4, ogg, wav, avi, mov, flv, swf), fonts (ttf, otf, woff, woff2, eot).
      Since:
      2.3
    • escapeWindowsPaths

      @Parameter(defaultValue="true") protected boolean escapeWindowsPaths
      Whether to escape backslashes and colons in windows-style paths.
      Since:
      2.4
    • delimiters

      @Parameter protected LinkedHashSet<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).

      Since:
      2.4
    • useDefaultDelimiters

      @Parameter(defaultValue="true") protected boolean useDefaultDelimiters
      Use default delimiters in addition to custom delimiters, if any.
      Since:
      2.4
    • addDefaultExcludes

      @Parameter(defaultValue="true") protected boolean addDefaultExcludes
      By default files like .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.
      • 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
  • Constructor Details

    • ResourcesMojo

      public ResourcesMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.api.plugin.MojoException
      Specified by:
      execute in interface org.apache.maven.api.plugin.Mojo
      Throws:
      org.apache.maven.api.plugin.MojoException
    • doExecute

      protected void doExecute() throws org.apache.maven.api.plugin.MojoException
      Throws:
      org.apache.maven.api.plugin.MojoException
    • executeUserFilterComponents

      protected void executeUserFilterComponents(org.apache.maven.shared.filtering.MavenResourcesExecution mavenResourcesExecution) throws org.apache.maven.api.plugin.MojoException, org.apache.maven.shared.filtering.MavenFilteringException
      Parameters:
      mavenResourcesExecution - MavenResourcesExecution
      Throws:
      org.apache.maven.api.plugin.MojoException - in case of wrong lookup.
      org.apache.maven.shared.filtering.MavenFilteringException - in case of failure.
      Since:
      2.5
    • getCombinedFiltersList

      protected List<String> getCombinedFiltersList()
      Returns:
      The combined filters.
    • getResources

      public List<org.apache.maven.shared.filtering.Resource> getResources()
      Returns:
      resources
    • setResources

      public void setResources(List<org.apache.maven.shared.filtering.Resource> resources)
      Parameters:
      resources - set resources
    • getOutputDirectory

      public Path getOutputDirectory()
      Returns:
      outputDirectory
    • setOutputDirectory

      public void setOutputDirectory(Path outputDirectory)
      Parameters:
      outputDirectory - the output folder.
    • getChangeDetection

      public org.apache.maven.shared.filtering.ChangeDetection getChangeDetection()
      Returns:
      changeDetection
    • setChangeDetection

      public void setChangeDetection(org.apache.maven.shared.filtering.ChangeDetection changeDetection)
      Parameters:
      changeDetection - the change detection strategy to use.
    • isOverwrite

      @Deprecated public boolean isOverwrite()
      Deprecated.
      Returns:
      overwrite
    • setOverwrite

      @Deprecated public void setOverwrite(boolean overwrite)
      Deprecated.
      Parameters:
      overwrite - true to overwrite false otherwise.
    • isIncludeEmptyDirs

      public boolean isIncludeEmptyDirs()
      Returns:
      includeEmptyDirs
    • setIncludeEmptyDirs

      public void setIncludeEmptyDirs(boolean includeEmptyDirs)
      Parameters:
      includeEmptyDirs - true/false.
    • getFilters

      public List<String> getFilters()
      Returns:
      filters
    • setFilters

      public void setFilters(List<String> filters)
      Parameters:
      filters - The filters to use.
    • getDelimiters

      public LinkedHashSet<String> getDelimiters()
      Returns:
      delimiters
    • setDelimiters

      public void setDelimiters(LinkedHashSet<String> delimiters)
      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
    • getLog

      protected org.apache.maven.api.plugin.Log getLog()