问题
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>
回答1:
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.
来源:https://stackoverflow.com/questions/37417337/regular-expression-not-working-maven-fileset