I would like to use rpm-maven-plugin to package my maven project to rpm file. After maven install (mvn clean install
) the rpm is created in target/rpm/rpm-build/RPMS/noarch/
.
How can I start the application?
If I try to install rpm with yum localinstall {name}.rpm
I get a hint that nothing is todo:
:
I've created a text file after install to understand the routine.
In my eyes the generated spec-file looks strange, because the tmp-buildroot/ is empty:
%define __jar_repack 0
Name: rpm-build
Version: 0.5.0
Release: SNAPSHOT20160809082044
Summary: rpm-build
License: (c) 2016 Nobody
Vendor: Nobody
URL: http://www.Nobody.com
Group: Development
Packager: Nobody
autoprov: yes
autoreq: yes
BuildArch: noarch
BuildRoot: /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/buildroot
%description
test example: RPM Package.
%install
if [ -d $RPM_BUILD_ROOT ];
then
mv /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/tmp-buildroot/* $RPM_BUILD_ROOT
else
mv /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/tmp-buildroot $RPM_BUILD_ROOT
fi
%files
"/opt/app//lib/"
%config "/opt/app//conf"
%dir "/opt/app//logs"
%pre
echo "installing now"
%post
#!/usr/bin/env bash
touch file.txt
Which parameter is missing in my pom?
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nobody</artifactId>
<groupId>com.nobody.nobody</groupId>
<version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rpm-build</artifactId>
<inceptionYear>2016</inceptionYear>
<organization>
<name>nobody</name>
<url>http://www.nobody.com</url>
</organization>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<app.home>/opt/app/</app.home>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.5</version>
<executions>
<execution>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<group>Development</group>
<description>example: RPM Package.</description>
<mappings>
<mapping>
<directory>${app.home}/lib/</directory>
<dependency/>
<artifact/>
</mapping>
<mapping>
<directory>${app.home}/conf</directory>
<configuration>true</configuration>
<sources>
<source>
<location>${project.build.outputDirectory}/app.properties</location>
<destination>app.sample.properties</destination>
</source>
</sources>
</mapping>
<mapping>
<directory>${app.home}/logs</directory>
</mapping>
</mappings>
<preinstallScriptlet>
<script>echo "installing now"</script>
</preinstallScriptlet>
<postinstallScriptlet>
<scriptFile>src/main/scripts/postinstall.sh</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</postinstallScriptlet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptor>src/assembly/dep.xml</descriptor>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This is my project structure:
Currently sending my application just a System.out.println
message.
My goal is to create a linux daemon, I hope it is possible with the postinstall script.
I hope someone has a hint for me. Thanks.