Optional mapping sections in Maven RPM plugin?
Asked Answered
L

2

8

I have a Maven RPM plugin mapping thus:

<mapping>
  <directory>/etc/myconfig</directory>
  <configuration>true</configuration>
  <sources>
    <source>
      <location>${project.build.directory}</location>
      <includes>
        <include>*.conf</include>
      </includes>
    </source>
  </sources>
</mapping>

However, depending on the packaging process, there may be zero .conf files to put in /etc. When this occurs, RPM plugin says:

[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.2:rpm (default) on project clients: 
Unable to copy files for packaging: You must set at least one file. -> [Help 1]

Is there any way to have a mapping section that is happy with including zero files?

Litigate answered 26/3, 2015 at 10:41 Comment(0)
H
2

The best I've been able to come up with is omitting the <includes> tag, which takes everything from what's specified in <location>.

location

The file or directory to include. If a directory is specified, all files and subdirectories are also included.

You will need to be as specific as possible in the path for these mappings that don't have include patterns specified. I added confs to the location below to avoid pulling in everything else in project.build.directory.

Even if no files are selected, the <directory> will still be created.

<mapping>
  <directory>/etc/myconfig</directory>
  <configuration>true</configuration>
  <sources>
    <source>
      <location>${project.build.directory}/confs</location>   
    </source>
  </sources>
</mapping>
Heimdall answered 15/3, 2016 at 20:44 Comment(3)
any hints for when confs doesn't exist at all?Caracara
The intention is that you create folders to hold all of the files that would have been matched by your pattern. So if you have 10 .conf files and 100 other files in your ${project.build.directory}, then you just move the conf files to a new directory called conf and include that.Heimdall
sure that is clear but what i meant with the above question is that we have some projects which don't have any .conf files in their source so there's nothing to move into ${project.build.directory}/confs. i missed out the point though that it's no problem to have an empty ${project.build.directory}/confs as long as it exists (otherwise plugin run fails). thanksCaracara
C
0

Me too faced the same issue and was trying hard to resolve it. The error message is not so intuitive. It's really hard to address such issue.

error :
[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1-alpha-3x:attached-rpm (generate-rpm) on project XXX_assembly: Unable to copy files for packaging: You must set at least one file. -> [Help 1]

I was using below version of plugin *

<groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                        <version>2.1-alpha-3x</version>

* Below is my Mapping tag from plugin

enter image description here

What this mapping was trying to is copy batch-test-1.0.war from ../batch/target location to target location at ${app.prefix}/batch

Issue was tag was having name of war file which does not exist and incorrect. i have given wrong name of war file so Maven was complaining that it should have something to copy.i corrected it by giving correct name of my war file as below. batch-test-1.0.war

Country answered 29/4, 2020 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.