Skip to content

C++ rpm pom

<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.company.app1</groupId>
  <artifactId>app1-rpm</artifactId>
  <name>App1 RPM</name>
  <packaging>rpm</packaging>
  <description>App1 RPMs</description>

  <parent>
    <groupId>com.company.app1</groupId>
    <artifactId>app1</artifactId>
    <version>3.7.5-SNAPSHOT</version>
  </parent>

  <profiles>
    <profile>
      <id>add-linux-x86-rpm</id>
      <activation>
        <os>
          <family>Linux</family>
          <arch>i386</arch>
        </os>
      </activation>

      <dependencies>
        <dependency>
          <groupId>com.company.app1</groupId>
          <artifactId>app1-i686</artifactId>
          <type>a</type>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>unix-maven-plugin</artifactId>
            <configuration>
              <packages>
                <package>
                  <id>i686-RH${distroVersion}</id>
                  <name>32-bit binary</name>
                  <assembly>
                    <copy-artifact>
                      <artifact>com.company.app1:app1-i686:a</artifact>
                      <toFile>${rpm.path}/bin/app1prod</toFile>
                      <attributes>
                        <user>${rpm.username}</user>
                        <group>${rpm.groupname}</group>
                        <mode>6750</mode>
                      </attributes>
                    </copy-artifact>
                  </assembly>
                </package>
              </packages>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>add-linux-x86_64-rpm</id>
      <activation>
        <os>
          <family>Linux</family>
          <arch>amd64</arch>
        </os>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.company.app1</groupId>
          <artifactId>app1-i686</artifactId>
          <type>a</type>
        </dependency>
        <dependency>
          <groupId>com.company.app1</groupId>
          <artifactId>app1-x86_64</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>unix-maven-plugin</artifactId>
            <configuration>
              <packages>
                <package>
                  <!-- -${os.version} -->
                  <id>i686-RH${distroVersion}</id>
                  <name>32-bit binary</name>
                  <assembly>
                    <copy-artifact>
                      <artifact>com.company.app1:app1-i686:a</artifact>
                      <toFile>${rpm.path}/bin/app1prod</toFile>
                      <attributes>
                        <user>${rpm.username}</user>
                        <group>${rpm.groupname}</group>
                        <mode>6750</mode>
                      </attributes>
                    </copy-artifact>
                  </assembly>
                </package>
                <package>
                  <id>x86_64-RH${distroVersion}</id>
                  <name>64-bit binary</name>
                  <assembly>
                    <copy-artifact>
                      <artifact>com.company.app1:app1-x86_64:a</artifact>
                      <toFile>${rpm.path}/bin/app1prod</toFile>
                      <attributes>
                        <user>${rpm.username}</user>
                        <group>${rpm.groupname}</group>
                        <mode>6750</mode>
                      </attributes>
                    </copy-artifact>
                  </assembly>
                </package>
              </packages>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>update-distroVersion</id>
      <activation>
        <property>
          <name>!distroVersion</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>echo-distroVersion-to-file</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>sh</executable>
                  <arguments>
                    <argument>-c</argument>
                    <argument>
                      (echo -n "distroVersion="; grep -o -e [1-9] /etc/issue | head -n 1) > ${distroVersionFile}
                    </argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>read-distroVersion-property</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  <files>
                    <file>${distroVersionFile}</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>appassembler-maven-plugin</artifactId>
          <version>1.0</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>unix-maven-plugin</artifactId>
          <version>1.0-alpha-3</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.1.1</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <version>1.0-alpha-1</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>unix-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <contact>Erik Drolshammer</contact>
          <contactEmail>someEmail</contactEmail>
          <revision>${rpm.revision}</revision>
          <defaults>
            <fileAttributes>
              <user>${rpm.username}</user>
              <group>${rpm.groupname}</group>
              <mode>0664</mode>
            </fileAttributes>
            <directoryAttributes>
              <user>${rpm.username}</user>
              <group>${rpm.groupname}</group>
              <mode>0775</mode>
            </directoryAttributes>
          </defaults>
          <rpm>
            <softwareGroup>Applications/Engineering</softwareGroup>
          </rpm>
          <assembly>
            <copy-directory>
              <from>src/main/unix/files</from>
              <to>${rpm.path}/</to>
            </copy-directory>

            <mkdirs>
              <paths>
                <path>${rpm.path}/run</path>
                <path>${rpm.path}/logs</path>
              </paths>
            </mkdirs>

            <set-attributes>
              <basedir>${rpm.path}/bin</basedir>
              <fileAttributes>
                <user>${rpm.username}</user>
                <group>${rpm.groupname}</group>
                <mode>6750</mode>
              </fileAttributes>
            </set-attributes>
            <set-attributes>
              <basedir>${rpm.path}/logs</basedir>
              <fileAttributes>
                <group>${rpm.log.groupname}</group>
              </fileAttributes>
            </set-attributes>
          </assembly>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <distributionManagement>
    <site>
      <id>site</id>
      <url>file:///var/www/html/sites/${parent.artifactId}/${parent.version}/${pom.artifactId}</url>
    </site>
  </distributionManagement>

  <properties>
    <rpm.appname>app1</rpm.appname>
    <rpm.username>app1user</rpm.username>
    <rpm.groupname>app1admin</rpm.groupname>
    <rpm.log.groupname>app1admin</rpm.log.groupname>
    <rpm.path>/usr/local/${rpm.appname}</rpm.path>
    <!--<rpm.revision>1</rpm.revision>-->

    <distroVersionFile>target/distroVersion.properties</distroVersionFile>
  </properties>

</project>