问题描述
我正在尝试在maven-assembly-plugin
中使用正则表达式,如下所示.有些文件的名称以ABC502开头.我正在尝试仅复制后缀为3或4的rpm.下一个不起作用.rpm名称在下面给出
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
ABC5024-buildnumber.rpm
ABC5024-buildnumber.rpm
ABC5025-buildnumber.rpm
ABC5025-buildnumber.rpm
ABC5026-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>
推荐答案
使用使用正则表达式来包含或排除具有%regex[...]
语法的文件,所有表达式都应由正则表达式组成.当用于匹配文件时,不能将正则表达式部分与普通部分混合在一起.
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.
因此,您需要使用
<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>
这将包括从ABC5023或ABC5024开始的所有RPM文件.
This will include all RPM files starting by ABC5023 or ABC5024.
这篇关于正则表达式不起作用的Maven文件集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!