RPM Systemd Maven Plugin

This plugin can be used to generate files for RPM packages and systemd services

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

at.makubi.maven.plugin
ArtifactId

ArtifactId

rpm-systemd-maven-plugin
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

RPM Systemd Maven Plugin
This plugin can be used to generate files for RPM packages and systemd services
Project URL

Project URL

https://github.com/makubi/rpm-systemd-maven-plugin
Source Code Management

Source Code Management

https://github.com/makubi/rpm-systemd-maven-plugin

Download rpm-systemd-maven-plugin

How to add to project

<plugin>
    <groupId>at.makubi.maven.plugin</groupId>
    <artifactId>rpm-systemd-maven-plugin</artifactId>
    <version>1.0.1</version>
</plugin>

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.3.9
org.scala-lang : scala-library jar 2.11.8

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
org.apache.maven : maven-core jar 3.3.9
org.apache.maven : maven-compat jar 3.3.9
commons-io : commons-io jar 2.4

Project Modules

There are no modules declared in this project.

RPM Systemd Maven Plugin

This plugin can be used to generate files for RPM packages and systemd services.

Build Status Maven Central

Usage

The plugin currently supports two goals:

  • generate-systemd-file: This generates a systemd file for the module
  • generate-rpm-postinst-file: This generates a postinst file to set up the target system
<plugin>
    <groupId>at.makubi.maven.plugin</groupId>
    <artifactId>rpm-systemd-maven-plugin</artifactId>
    <version>1.0.1</version>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate-systemd-file</goal>
                <goal>generate-rpm-install-files</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Usage in conjunction with the RPM Maven Plugin

This plugin can be used in conjunction with the RPM Maven Plugin to create a RPM package including the systemd and postinst file.

<plugins>
    <plugin>
        <groupId>at.makubi.maven.plugin</groupId>
        <artifactId>rpm-systemd-maven-plugin</artifactId>
        <executions>
            <execution>
                <phase>generate-resources</phase>
                <goals>
                    <goal>generate-systemd-file</goal>
                    <goal>generate-rpm-postinst-file</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>rpm-maven-plugin</artifactId>
        <configuration>
            <mappings>
                <mapping>
                    <directory>/usr/lib/systemd/system</directory>
                    <sources>
                        <source>
                            <location>${project.build.directory}/rpm-systemd-maven-plugin/${project.artifactId}.service</location>
                        </source>
                    </sources>
                    <directoryIncluded>false</directoryIncluded>
                    <configuration>false</configuration>
                </mapping>
            </mappings>
            <postinstallScriptlet>
                <scriptFile>target/rpm-systemd-maven-plugin/postinst</scriptFile>
                <fileEncoding>utf-8</fileEncoding>
            </postinstallScriptlet>
            ...
        </configuration>
    </plugin>
</plugins>

Override variables

You can override the following variables in the plugin configuration:

javaPath

  • Path to the java binary in the systemd service file
  • Defaults to /usr/bin/java

runnableJarPath

  • Path to the runnable jar of the module in the systemd service file
  • Defaults to /usr/share/${project.artifactId}/${project.build.finalName}.${project.packaging}

workingDirectoryPath

  • Path to the working directory in the systemd service file
  • Used as home directory for the user the module will be executed with
  • Defaults to /var/lib/${project.artifactId}

environmentFilePath

  • Path to the environment file in the systemd service file
  • Created in the postinst file
  • Defaults to /etc/sysconfig/${project.artifactId}

systemdServiceFileName

  • Name of the systemd service file
  • Used in the postinst file to preset the systemd service
  • Defaults to ${project.artifactId}.service

user

  • User to be used for module execution in the systemd service file
  • Used to set permissions for directories
  • Defaults to ${project.artifactId}

group

  • Group to be used for module execution in the systemd service file
  • Used to set permissions for directories
  • Defaults to ${project.artifactId}

additionalDirectories

  • List of additional directories to be created in the postinst file
  • Defaults to an empty list

Example

To override the runnableJarPath and add additional directories, use

<plugins>
    <plugin>
        <groupId>at.makubi.maven.plugin</groupId>
        <artifactId>rpm-systemd-maven-plugin</artifactId>
        <configuration>
            <runnableJarPath>/opt/${project.artifactId}/${project.build.finalName}-jarlotte.jar</runnableJarPath>
            <additionalDirectories>
                <additionalDirectory>
                    <directory>/etc/${project.artifactId}</directory>
                    <user>root</user>
                    <group>root</group>
                </additionalDirectory>
                <additionalDirectory>
                    <directory>/var/log/${project.artifactId}</directory>
                    <user>${project.artifactId}</user>
                    <group>${project.artifactId}</group>
                </additionalDirectory>
            </additionalDirectories>
        </configuration>
        ...
    </plugin>
</plugins>

or

<properties>
    <runnableJarPath>/opt/${project.artifactId}/${project.build.finalName}-jarlotte.jar</runnableJarPath>
</properties>

License

The RPM Systemd Maven Plugin is released under version 2.0 of the Apache License.

Versions

Version
1.0.1