Fork me on GitHub

Mapping Parameters

The parameters described in this page specify the mapping between the files and directories that exist in the project and the files and directories installed when the RPM package is installed on a system. The RPM build program requires one mapping element for each file to be installed. If the mapping element points to a directory the RPM build program will use the specifications of the mapping for every file in the entire tree starting at the specified directory.

The set of parameters which define a single mapping are contained within a mapping tag. The set of all mapping tags are contained within a mappings tag. A minimal mapping configuration looks like:

<plugin>
  ...
  <configuration>
    ...
    <mappings>
      <mapping>
        <directory>/tmp</directory>
      </mapping>
    </mappings>
    ...
  </configuration>
  ...
</plugin>

directory (required)

This is the directory where the files in this mapping will be installed when the package is installed. This value must start with /.

configuration

If present or populated with the value true, the files in this mapping are marked as configuration files. These files get special treatment during package installation to ensure that local changes to the configuration are not lost.

If populated with any value other than false, the value will be used as a modifier to the %config declaration in the spec file. As an example, "<configuration>noreplace</configuration>", would lead to %config(noreplace) being generated in the spec file.

documentation

If given the value true, the file(s) are marked as documentation files. The RPM command installs documentation files into a directory (usually under /usr/share/doc) named the same as the RPM package.

filemode (recommended)

This is UNIX permissions (file mode) to assign to the files when installed. This value consists of three octal digits representing the access for the owner, the group, and the world. Each digit represents the access allowed and is the sum of 4 for read, 2 for write, and 1 for execute. A common value to use is "644" which provides the owner read/write access and read-only access to everyone else. For more information on this subject, read File Security, section 3.4 of the Introduction to Linux maintained by the Linux Documentation Project. If not specified, the files retain the filemode assigned to them when copied to the RPM work area.

If none of the file attributes (filemode, username, and groupname) are populated, the defaults (defaultFileMode, defaultUsername, defaultGroupname, and defaultDirmode) will be used.

dirmode

This is UNIX permissions (file mode) to assign to directories when installed. This value consists of three octal digits representing the access for the owner, the group, and the world. Each digit represents the access allowed and is the sum of 4 for read, 2 for write, and 1 for execute (in the context of directories, 'execute' allows the user to list the contents of the directory). A common value to use is "755" which provides the owner read/write access and read-only access to everyone else. Everyone is allowed to list the contents of the directory. For more information on this subject, read File Security, section 3.4 of the Introduction to Linux maintained by the Linux Documentation Project. If not specified, filemode, will be used instead.

This property is useful if you want files and directories included in a single mapping to have different permissions. The canonical example would be files that are readable (644) and directories that have the executable bit set (755). That way, the directories can be listed, but the files remain non-executable.

If none of the file attributes (dirmode, filemode, username, and groupname) are populated, the defaults (defaultFileMode, defaultUsername, defaultGroupname, and defaultDirmode) will be used.

username (recommended)

This is the UNIX username to assign to the files when installed. If the named user does not exist when the package is installed, the user root will be used. If not specified, the files will be owned by the user used to create the package.

If none of the file attributes (filemode, username, and groupname) are populated, the defaults (defaultFileMode, defaultUsername, defaultGroupname, and defaultDirmode) will be used.

groupname (recommended)

This is the UNIX groupname to assign to the files when installed. If the named group does not exist when the package is installed, the group root will be used. If not specified, the files will be owned by the group used to create the package.

If none of the file attributes (filemode, username, and groupname) are populated, the defaults (defaultFileMode, defaultUsername, defaultGroupname, and defaultDirmode) will be used.

directoryIncluded

If the value is true then the attribute string will be written for the directory if the sources identify all of the files in the directory (that is, no other mapping contributed files to the directory). This is the default behavior.

If the value is false, the files in this mapping will be listed individually in the spec file.

recurseDirectories

Indicates if sub-directories contained in the sources should be explicitly listed in %files. This includes listing the destination if directoryIncluded is true.

artifact

If present, then the project's artifact should be included in this mapping. This file will be installed in the directory specified in the directory parameter. If the project creates more than one artifact and you do not want all of the artifacts installed with this mapping, you need to specify the classifier(s) which should be included with this mapping; this is done by including a "<classifiers>" tag which holds one or more "<classifier>" tags holding a single classifier (use "<classifier></classifier>" for the primary project artifact).

dependency

If present, then some or all of the project's transitive runtime dependencies should be included in this mapping. The dependencies to be included are those which are specified with compile or runtime scope, and all of the dependencies of those artifacts which are similarly defined. These files will be installed in the directory specified in the directory parameter.

If the tag is empty ("<dependency/>"), then all dependencies will be included in the mapping. To limit the dependencies to include in the mapping, you must specify "<includes>", "<excludes>", or both. Each of these elements contains a list of items; for example, the "<includes>" element will have a list of "<include>" items. Each item specifies a single dependency to include or exclude with a string in one of the following two formats:

  • "group:artifact" which specifies the group ID and artifact ID of the dependency; the version and type are taken from the actual dependency definition in the project
  • "group:artifact:versionrange" which extends the above to limit the specification to particular versions of the artifact; note that this will not cause a different version of the dependency to be packaged than what was used to build the project

If no include items are specified, then all dependencies not explicitly excluded are included.

  • "<stripVersion>true</stripVersion>" will strip the version from the name of the dependencies when installed in the RPM package.

sources

The location(s) to find the files to be packaged. If no sources are specified, the directory will be created using the mapping specification but no contents will be selected for packaging; this allows an empty directory to be specified. The content of this parameter is discussed in a separate file.