4

I'm using rpm-maven-plugin to create an rpm of a tarball containing the WARs from my project. I can create an rpm if I already have a tar file. However, I would like to generate the tar file when I run the rpm goal.

I have a script that creates the tar file. I call the script in the prepare step, however the rpm has already been created when the script executes, thus the tar is not included in my rpm.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>rpm-maven-plugin</artifactId>
    <version>2.1-alpha-4</version>
    <executions>
        <execution>
            <id>generate-rpm</id>
            <goals>
                <goal>rpm</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mappings>
          <mapping>
            <directory>/foo</directory>
            <sources>
                <source>
                    <location>DIRECTORY_FOR_MY_TAR</location>
                </source>
            </sources>
          </mapping>
        </mappings>
        <defineStatements>
           <defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
        </defineStatements>
        <prepareScriptlet>
            <script>./../../../../scripts/rpm/prepare/makeATar.sh</script>
        </prepareScriptlet>
    </configuration>
</plugin>

When I run mvn rpm:rpm the makeATar script creates a tar in DIRECTORY_FOR_MY_TAR, but it isn't included in my rpm. If I run mvn rpm:rpm again my tar will successfully be include in the rpm (since it was put into DIRECTORY_FOR_MY_TAR from the execution of makeATar the last time I ran mvn rpm:rpm).

Boundless
  • 2,444
  • 2
  • 25
  • 40

1 Answers1

3

We also have a similar setup where we build some artifacts and then pack them into an RPM with the rpm-maven-plugin.
To arrange the artifacts before we pack as RPM, we

  • Use the maven-antrun-plugin in the prepare-package phase to arrange all the aritfacts
  • Call the rpm-maven-plugin as part of the package phase

It works very well for us.
You can also bind the rpm-maven-plugin execution to the install phase and use the artifacts that were packages in the package phase.
Or put the RPM packing in a separate maven module and build it after all other modules are already built (and pack their artifacts as planned).

I hope this helps.

Eldad Assis
  • 10,464
  • 11
  • 52
  • 78