Skip to content

Configuration

Simon Paulger edited this page Apr 17, 2015 · 9 revisions

The plugin is configured using a handful of global level parameters to apply defaults, and a list of package definitions for building the RPM artefacts.

The package definitions themselves further include a list of rules for matching files in the Maven build output directory to include in chosen installation locations, and the associated ownership, permissions and other metadata to apply to those files upon installation. This is documented further on the Packages page.

A full configuration example is provided below.

Setting the build path

The Maven build path is where Maven creates all the output from the build process. Usually, this is some directory under target and can be obtained using the Maven environment variable ${project.build.outputDirectory}.

The plugin will use the above Maven environment variable to automatically set the build path Maven has used to construct the project, however, if you want to use another path, or you want to use a sub path of the build path, you can override the value set within the configuration.

The build path is purely used for scanning for files to include within the configured RPM packages, and will effect the relative path of each file found when it is included within the RPM for installation.

    ...
    <configuration>
        ...
        <buildPath>${project.build.outputDirectory}/public</buildPath>
        ...
    </configuration>
    ...

Default parameters

As the plugin allows for adding multiple pattern matches across multiple package definitions, repeating file attributes can be tedious. Therefore the plugin allows for setting default file attributes that are used when a more specific file attribute is not set. If a specific file attribute is set for a file pattern match, then those attributes will be used instead.

    ...
    <configuration>
        ...
        <defaultUser>apache</defaultUser>
        <defaultGroup>apache</defaultGroup>
        <defaultFileMode>0644</defaultFileMode>
        <defaultDestination>/var/www/${project.build.name}</defaultDestination>
        ...
    </configuration>
    ...
Owner

The default owner sets the owner of the file. This should be a string and will be a user that exists on the environment in which the RPM will eventually installed upon. If the user does not exist, most systems will default this to root. You could use event scripting to create the user if it does not exist prior to installation of files.

The default value is root.

Group

The default group sets the group of the file. This should be a string and will be a group that exists on the environment in which the RPM will eventually installed upon. If the group does not exist, most systems will default this to root. You could use event scripting to create the group if it does not exist prior to installation of files.

The default value is root.

Mode

The default mode sets the file permissions (srwx) of the file. This should be in the form of an octal. For example, 0644 applies rx-r--r-- permissions to a file.

The default value is 0644.

Destination

This is the default base destination of a file, relative to the build path. For example, if the build path were target/public/index.php, then the destination of /var/www/myapp would install index.php as /var/www/myapp/public/index.php.

The default value is / or , depending on the operating system.

Checking for missed files

By default, the plugin will scan the build path for files not matched by any packages within the configuration. I.e. files that were not matched and thus not included in any RPM packages. If it finds any, it will flag these in error and stop the build.

To prevent this, you can either ignore the files, or disable the checking entirely.

Ignoring files

Missed files can be ignored by applying a set of exclusion globs to the configuration that informs the plugin that you know of their existence but still do not want them to be included in any RPM package.

Doing this benefits the build by preventing the error whilst still performing the missed files check for any potentially future files that you might add that may no be be selected for inclusion in any RPM packages.

To ignore files, add the following configuration to the XML, specifying pattern matches for the files you wish to ignore.

    ...
    <configuration>
        ...
        <excludes>
            <source>**/*.bak</source>
            <source>**/*.bat</source>
        </excludes>
        ...
    </configuration>
    ...
Disable checking

If you simply don't want to perform checking for non matched files when packaging, you can disable the check entirely.

    ...
    <configuration>
        ...
        <performCheckingForExtraFiles>false</performCheckingForExtraFiles>
        ...
    </configuration>
    ...

Complete configuration example

The XML below is an example of all options for configuring the plugin. Note that some options are optional and can be ignored to assume a sane default value.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.example</groupId>
    <artifactId>my-project</artifactId>
    <version>1.0</version>
    <packaging>rpm</packaging>
    
    <build>
        <plugins>
            <plugin>
                <groupId>uk.co.codezen</groupId>
                <artifactId>redlinerpm-maven-plugin</artifactId>
                <version>1.0</version>
                <extensions>true</extensions>
             
                <configuration>
                    <buildPath>target</buildPath>

                    <defaultUser>apache</defaultUser>
                    <defaultGroup>apache</defaultGroup>
                    <defaultFileMode>0644</defaultFileMode>
                    <defaultDestination>/var/www/${project.name}</defaultDestination>
                    
                    <performCheckingForExtraFiles>true</performCheckingForExtraFiles>
         
                    <excludes>
                        <source>**/*.bak</source>
                    </excludes>
             
                    <packages>
                        <package>
                            <finalName>my-project.rpm</finalName>
                            <name>my-project</name>
                            <version>1.0</version>
                            <release>1</release>
                            
                            <url>http://www.example.com</url>
                            <group>Application/Productivity</group>
                            <license>Apache 2.0</license>
                            
                            <summary>Summary of project</summary>
                            <description>Description of project</description>
                            
                            <architecture>i386</architecture>
                            </operatingSystem>LINUX</operatingSystem>
                            
                            <buildHostName>localhost</buildHostName>
                            <packager>Simon</packager>
                            
                            <signingKey>sign.key</signingKey>
                            <signingKeyId>key</signingKeyId>
                            <signingKeyPassPhrase>secret</signingKeyPassPhrase>
                            
                            <prefixes>
                                <prefix>/</prefix>
                                <prefix>/usr</prefix>
                                <prefix>/usr/local</prefix>
                            </prefixes>
                            
                            <dependencies>
                                <dependency>
                                    <name>php</name>
                                    <version>(5.6,]</version>
                                </dependency>
                            </dependencies>
                            
                            <conflicts>
                                <conflict>
                                    <name>my-sister-project</name>
                                    <version>1.0</version>
                                </conflict>
                            </conflicts>
                            
                            <obsoletes>
                                <obsolete>
                                    <name>my-older-project</name>
                                    <version>1.0</version>
                                </obsolete>
                            </obsoletes>
                        
                            <rules>
                                <rule>
                                    <includes>
                                        <include>**/*.ini</include>
                                    </includes>
             
                                    <directives>
                                        <directive>config</directive>
                                        <directive>noreplace</directive>
                                    </directives>
                                </rule>
             
                                <rule>
                                    <includes>
                                        <include>**/*</include>
                                    </includes>
             
                                    <excludes>
                                        <exclude>**/*.bak</exclude>
                                        <exclude>**/*.ini</exclude>
                                        <exclude>cache/*.php</exclude>
                                    </excludes>
                                </rule>
                            </rules>
                        </package>
                    </packages>
                </configuration>
            </plugin>
        </plugins>
    </build>
 </project>