正则表达式不起作用的Maven文件集 [英] Regular expression not working Maven fileset

查看:246
本文介绍了正则表达式不起作用的Maven文件集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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

ABC5023-buildnumber.rpm

ABC5023-buildnumber.rpm

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>

推荐答案

使用

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文件集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆