user983022
user983022

Reputation: 979

maven rpm plugin needs full path to source location in multi module project

I have a multi module maven project. I am calling the RPM plugin from the parent pom, but unlike the maven assembly plugin, I need to provide the full path to the sources I wish to package into the RPM specified directory.

For example the following location path will not work unless I specify the full path:

<sources>
  <source>
    <location>/src/main/config</location>
  </source>
</sources> 

Regular expressions and wildcards do not work too.

Any suggestions please?

thanks

Upvotes: 0

Views: 5857

Answers (1)

Stefan Ferstl
Stefan Ferstl

Reputation: 5265

The documentation of the source parameter says:

If the path does not start with /, it is taken to be relative to the project's base directory.

So it should work if you remove the leading / from the location parameter.

-- update --

I made a little test with this simple multi-module project:

rpm-test
|-- module1
|   |-- pom.xml
|   |-- src
|       |-- main
|       |   |-- config
|       |   |   |-- mod1-file1.conf
|       |   |   |-- mod1-file2.conf
|-- module2
|   |-- pom.xml
|   |-- src
|       |-- main
|       |   |-- config
|       |   |   |-- mod2-file1.conf
|       |   |   |-- mod2-file2.conf
|-- pom.xml

The configuration of the rpm-maven-plugin in the parent POM looks as follows:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>rpm-maven-plugin</artifactId>
  <version>2.1-alpha-1</version>
  <inherited>false</inherited>
  <configuration>
    <copyright>2012, Me</copyright>
    <group>mygroup</group>
    <mappings>
      <!-- Option 1: Use the base directory and includes -->
      <mapping>
        <directory>/usr/local</directory>
        <sources>
          <source>
            <location>${project.basedir}</location>
            <includes>
              <include>**/src/main/config/**</include>
            </includes>
          </source>
        </sources>
      </mapping>

      <!-- Option 2: List each module separatly -->
      <mapping>
        <directory>/tmp</directory>
        <sources>
          <source>
            <location>${project.basedir}/module1/src/main/config</location>
          </source>
          <source>
            <location>${project.basedir}/module2/src/main/config</location>
          </source>
        </sources>
      </mapping>
    </mappings>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>rpm</goal>
      </goals>
    </execution>
  </executions>
</plugin>

When I query the the content of the generated RPM with rpm -qpl, I get these results:

/tmp
/tmp/mod1-file1.conf
/tmp/mod1-file2.conf
/tmp/mod2-file1.conf
/tmp/mod2-file2.conf
/usr/local/module1/src/main/config/mod1-file1.conf
/usr/local/module1/src/main/config/mod1-file2.conf
/usr/local/module2/src/main/config/mod2-file1.conf
/usr/local/module2/src/main/config/mod2-file2.conf

Upvotes: 2

Related Questions