Skip to content

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

License

Notifications You must be signed in to change notification settings

makubi/rpm-systemd-maven-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 72.4%
  • Scala 27.6%