Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optional mapping sections in Maven RPM plugin?

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?

like image 358
Bittrance Avatar asked Mar 26 '15 10:03

Bittrance


1 Answers

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>
like image 119
haventchecked Avatar answered Nov 02 '22 04:11

haventchecked