rpm-maven-plugin postinstallScriptlet示例

时间:2015-06-04 06:41:10

标签: maven maven-plugin rpm

我想在安装后构建rpm并运行2脚本。 我怎样才能通过rpm-maven-plugin实现这一目标。 例如,我的脚本是:

/opt/sss/${component.name}/bin/mkdir.sh
/opt/sss/${component.name}/bin/starter.sh

以下是我目前的pom:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <!-- <version>2.0-beta-3</version> -->
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>rpm</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <group>Applications</group>
                    <release>1</release>
                    <name>${component.name}</name>
                    <version>${project.version}</version>
                    <mappings>
                       <mapping>
                        <directory>/opt/sss/${component.name}/bin</directory>
                            <filemode>775</filemode>
                            <username>root</username>
                            <groupname>super</groupname>
                            <sources>
                                <source>
                                    <location>bin</location>
                                </source>
                            </sources>
                        </mapping>
                    </mappings>
                    <postinstallScriptlet>bin/mkdir.sh</postinstallScriptlet>
                </configuration>
            </plugin>

运行时出现此错误:

[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm (default-rpm) on project installation: Unable to parse configuration of mojo org.codehaus.mojo:rpm-maven-plugin:2.1.3:rpm for parameter postinstallScriptlet: Cannot configure instance of org.codehaus.mojo.rpm.Scriptlet from

2 个答案:

答案 0 :(得分:1)

我找到了1个脚本的解决方案。当我尝试设置2个脚本文件时,我会更新这个答案。

            <postinstallScriptlet>
                <scriptFile>bin/mkdir.sh</scriptFile>
                <fileEncoding>utf-8</fileEncoding>
            </postinstallScriptlet>

答案 1 :(得分:0)

一种简单的方法是将脚本调用封装在单个脚本中。喜欢:

假设您有两个脚本:

  

script1.sh 和   的 script2.sh

编写包装器脚本(wrapper.sh):

#!/bin/bash
script1.sh --some-args
script2.sh --some-args

现在通过maven:

调用postInstallScriptlet
<postinstallScriptlet>
   <scriptFile>......./wrapper.sh</scriptFile>
   <fileEncoding>utf-8</fileEncoding>
</postinstallScriptlet>

这与PostInstallScriptlet无关,但只是一个解决方法。如果有人找到更好的方法来做到这一点,很高兴接受他们的!!

如果您想了解有关高级参数的更多信息,请点击此处:http://www.mojohaus.org/rpm-maven-plugin/adv-params.html