Simplest Enterprise Continuous Integration Solutions

Saturday, March 9, 2013

Enterprise Linux: RPM Maven pom.xml example

<?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">
   <groupId>com.qxc.rpm.demo</groupId>
   <artifactId>qxc-rpm-demo</artifactId>
   <modelVersion>4.0.0</modelVersion>
   <version>1.0</version>
   <packaging>jar</packaging>

   <!-- global definition -->
   <organization>
      <name>http://www.qxconsultant.com</name>
      <url>http://www.qxconsultant.com</url>
   </organization>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.temp.build.dir>${basedir}/target/temp</project.temp.build.dir>
      <maven.build.timestamp.format>HHmmss</maven.build.timestamp.format>
      <rpm.group>qxc/applications</rpm.group>
      <rpm.packager>info@qxconsutlant.com</rpm.packager>
      <rpm.prefix>/opt/qxc</rpm.prefix>
      <rpm.release>${maven.build.timestamp}</rpm.release>
      <rpm.version>${project.version}</rpm.version>
      <rpm.license>Academic Free License</rpm.license>
      <rpm.scriptlets.path>src/main/scriptlets</rpm.scriptlets.path>
      <rpm.changelog.path>src</rpm.changelog.path>
      <install.path>${rpm.prefix}/${project.artifactId}</install.path>
      <install.user>root</install.user>
      <install.group>root</install.group>
      <!-- local definition -->
      <local.filemode>644</local.filemode>
      <local.executable.filemode>755</local.executable.filemode>
   </properties>

   <!-- local definition -->
   <description>This is a sample RPM generated by RPM Maven Plugin</description>

   <build>
      <plugins>
         <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
               <execution>
                  <id>copy-resources</id>
                  <phase>validate</phase>
                  <goals>
                     <goal>copy-resources</goal>
                  </goals>
                  <configuration>
                     <outputDirectory>${project.temp.build.dir}</outputDirectory>
                     <resources>
                        <resource>
                           <directory>src/main</directory>
                           <filtering>true</filtering>
                        </resource>
                     </resources>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <version>2.1-alpha-4</version>
            <extensions>true</extensions>
            <configuration>
               <license>${rpm.license}</license>
               <group>${rpm.group}</group>
               <packager>${rpm.packager}</packager>
               <prefix>${rpm.prefix}</prefix>
               <changelogFile>${rpm.changelog.path}/changelog</changelogFile>
               <autoProvides>false</autoProvides>
               <autoRequires>false</autoRequires>
               <requires combine.children="append">
               </requires>
               <conflicts>
               </conflicts>
               <preinstallScriptlet>
                  <scriptFile>${rpm.scriptlets.path}/pre.sh</scriptFile>
               </preinstallScriptlet>
               <postinstallScriptlet>
                  <scriptFile>${rpm.scriptlets.path}/post.sh</scriptFile>
               </postinstallScriptlet>
               <preremoveScriptlet>
                  <scriptFile>${rpm.scriptlets.path}/preun.sh</scriptFile>
               </preremoveScriptlet>
               <mappings>
                  <mapping>
                     <directory>${install.path}</directory>
                     <username>${install.user}</username>
                     <groupname>${install.group}</groupname>
                     <filemode>${local.executable.filemode}</filemode>
                     <sources>
                        <source>
                           <location>${project.temp.build.dir}</location>
                           <excludes>
                              <exclude>scriptlets/</exclude>
                              <exclude>changelog</exclude>
                           </excludes>
                           <includes>
                              <include>scripts/</include>
                           </includes>
                        </source>
                     </sources>
                  </mapping>
                  <mapping>
                     <directory>${install.path}/conf</directory>
                     <username>${install.user}</username>
                     <groupname>${install.group}</groupname>
                     <configuration>true</configuration>
                     <filemode>${local.filemode}</filemode>
                     <sources>
                        <source>
                           <location>${project.temp.build.dir}/conf</location>
                        </source>
                     </sources>
                  </mapping>
               </mappings>
            </configuration>
            <executions>
               <execution>
                  <goals>
                     <goal>rpm</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>