Maven RPM 插件:CentOS 6.5 和 5.6 的不同内容

Maven RPM plugin: Different content for CentOS 6.5 and 5.6

我一直在使用 rpm-maven-plugin 生成 RPM 以在 CentOS 6.5 上安装。现在我需要扩展它来打包一个 RPM,其中包含在 CentOS 5.6 上编译的二进制文件。我的开发机器是 OSX,我希望能够在其上测试 CentOS 6.5 和 5.6 的 RPM 生成。这意味着我应该能够将目标 OS 作为命令行参数传递。关于如何做到这一点有什么想法吗?

我查看了插件的文档,似乎我需要使用过滤器,但我找不到任何地方可以找到如何确定 CentOS 5.6 和 6.5 的分类器的值。

谢谢!

我最终创建了两个单独的 maven-rpm-plugin 执行:一个 - 适用于 CentOS 6.5,另一个 - 适用于 CentOS 5.6。我还禁用了在发布过程中将 RPM 自动上传到 Maven 存储库的功能,因为这两个 RPM 具有相同的名称。我通过将 -Dmaven.deploy.skip=true 添加到 maven-release-plugin 部分来禁用上传。

这是我的 pom.xml 的相关摘录(可以用 mvn package 执行):

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <version>2.2.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <arguments>-Dmaven.deploy.skip=true</arguments>
                    <preparationGoals>clean install</preparationGoals>
                    <pushChanges>false</pushChanges>
                    <localCheckout>true</localCheckout>
                    <!--Disable deployment at the end because CentOS 5.6 and 6.5 profile artifacts will collide-->
                    <goals></goals>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>CentOS-5.6</id>
                    <goals>
                        <goal>attached-rpm</goal>
                    </goals>
                    <configuration>
                        <name>${rpmName}</name>
                        <needarch>x86_64</needarch>
                        <workarea>target/rpm/centos-5.6</workarea>
                        <group>CollectD</group>
                        <defaultDirmode>755</defaultDirmode>
                        <defaultFilemode>755</defaultFilemode>
                        <defaultUsername>root</defaultUsername>
                        <defaultGroupname>root</defaultGroupname>
                        <mappings>
                            <!-- Root directory -->
                            <mapping>
                                <directory>${installDir}</directory>
                                <directoryIncluded>true</directoryIncluded>
                                <sources>
                                    <source>
                                        <location>${project.build.directory}/classes/centos-5.6/collectd</location>
                                        <excludes>
                                            <exclude>etc/*</exclude>
                                        </excludes>
                                    </source>
                                </sources>
                            </mapping>
                            <!-- Overwrite configurations with the right file permissions -->
                            <mapping>
                                <directory>${installDir}/etc</directory>
                                <directoryIncluded>false</directoryIncluded>
                                <configuration>true</configuration>
                                <sources>
                                    <source>
                                        <location>${project.build.directory}/classes/centos-5.6/collectd/etc</location>
                                    </source>
                                </sources>
                                <filemode>644</filemode>
                            </mapping>
                            <!-- local output directories for logging and so on -->
                            <mapping>
                                <directory>${installDir}/var/log</directory>
                                <directoryIncluded>true</directoryIncluded>
                            </mapping>
                            <mapping>
                                <directory>${installDir}/var/lib</directory>
                                <directoryIncluded>true</directoryIncluded>
                            </mapping>
                            <mapping>
                                <directory>${installDir}/var/run</directory>
                                <directoryIncluded>true</directoryIncluded>
                            </mapping>
                            <!-- collectd service startup script -->
                            <mapping>
                                <directory>/etc/init.d</directory>
                                <directoryIncluded>false</directoryIncluded>
                                <sources>
                                    <source>
                                        <location>${project.build.directory}/classes/centos-common/init.d/collectd</location>
                                    </source>
                                </sources>
                            </mapping>
                        </mappings>
                    </configuration>
                </execution>
                <execution>
                    <id>CentOS-6.5</id>
                    <goals>
                        <goal>attached-rpm</goal>
                    </goals>

                    <configuration>
                        <name>${rpmName}</name>
                        <needarch>x86_64</needarch>
                        <workarea>target/rpm/centos-6.5</workarea>
                        <group>CollectD</group>
                        <defaultDirmode>755</defaultDirmode>
                        <defaultFilemode>755</defaultFilemode>
                        <defaultUsername>root</defaultUsername>
                        <defaultGroupname>root</defaultGroupname>
                        <mappings>
                            <!-- Root directory -->
                            <mapping>
                                <directory>${installDir}</directory>
                                <directoryIncluded>true</directoryIncluded>
                                <sources>
                                    <source>
                                        <location>${project.build.directory}/classes/centos-6.5/collectd</location>
                                        <excludes>
                                            <exclude>etc/*</exclude>
                                        </excludes>
                                    </source>
                                </sources>
                            </mapping>
                            <!-- Overwrite configurations with the right file permissions -->
                            <mapping>
                                <directory>${installDir}/etc</directory>
                                <directoryIncluded>false</directoryIncluded>
                                <configuration>true</configuration>
                                <sources>
                                    <source>
                                        <location>${project.build.directory}/classes/centos-6.5/collectd/etc</location>
                                    </source>
                                </sources>
                                <filemode>644</filemode>
                            </mapping>
                            <!-- local output directories for logging and so on -->
                            <mapping>
                                <directory>${installDir}/var/log</directory>
                                <directoryIncluded>true</directoryIncluded>
                            </mapping>
                            <mapping>
                                <directory>${installDir}/var/lib</directory>
                                <directoryIncluded>true</directoryIncluded>
                            </mapping>
                            <mapping>
                                <directory>${installDir}/var/run</directory>
                                <directoryIncluded>true</directoryIncluded>
                            </mapping>
                            <!-- collectd service startup script -->
                            <mapping>
                                <directory>/etc/init.d</directory>
                                <directoryIncluded>false</directoryIncluded>
                                <sources>
                                    <source>
                                        <location>${project.build.directory}/classes/centos-common/init.d/collectd</location>
                                    </source>
                                </sources>
                            </mapping>
                        </mappings>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>