5

I am trying use regular expression in maven-assembly-plugin which is shown below. There are files with the names starts with ABC502. I am trying to copy only the rpms with the 3 or 4 in suffix. Below one is not working. rpm names are given below

ABC5023-buildnumber.rpm

ABC5024-buildnumber.rpm

ABC5025-buildnumber.rpm

ABC5026-buildnumber.rpm

<fileSet>
    <directory>${project.build.directory}/tar_content/stackcontents/</directory>
    <outputDirectory>scripts/data/rpms/</outputDirectory>
    <includes>
        <include>%regex[ABC502(3|4)]-*.rpm</include>
    </includes>
    <fileMode>0755</fileMode>
    <directoryMode>0755</directoryMode>
</fileSet>
2
  • Can you show your full assembly descriptor? Apart from that in the descriptor there is no support for regex as far as i know? (Or can you give the link for the reference to that?)...
    – khmarbaise
    Commented May 24, 2016 at 15:41
  • @khmarbaise It is indeed possible to use a regex maven.apache.org/plugins/maven-assembly-plugin/….
    – Tunaki
    Commented May 24, 2016 at 17:21

1 Answer 1

7

When you use a regular expression to include or exclude files with the %regex[...] syntax, all of the expression should be composed of the regular expression. You cannot mix a regular expression part with a normal part when it is used to match files.

Therefore, you need to use

<fileSet>
    <directory>${project.build.directory}/tar_content/stackcontents/</directory>
    <outputDirectory>scripts/data/rpms/</outputDirectory>
    <includes>
        <include>%regex[ABC502(3|4)-.*?\.rpm]</include>
    </includes>
    <fileMode>0755</fileMode>
    <directoryMode>0755</directoryMode>
</fileSet>

This will include all RPM files starting by ABC5023 or ABC5024.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.