在Maven中按模式查找文件

时间:2020-08-24 14:32:41

标签: java bash shell maven exec-maven-plugin

我需要预处理Java Maven项目中的某些资源文件(* .xsl)。 我发现exec-maven-plugin能够执行Shell命令,并认为我可以分两个步骤完成操作:

  1. 匹配文件列表并将其写入文件
  2. 启动一个Java程序,该程序对列表中的每个文件进行预处理

但是,我尝试执行的find命令没有任何输出。 POM中的插件配置如下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>inline-xml-entities</id>
            <phase>generate-resources</phase>
            <configuration>
                <executable>find</executable>
                <useMavenLogger>true</useMavenLogger>
                <outputFile>xsl-files.txt</outputFile>
                <arguments>
                    <argument>./src/main/webapp/static/com/atomgraph/</argument>
                    <argument>-type</argument>
                    <argument>f</argument>
                    <argument>-name</argument>
                    <argument>'*.xsl'</argument>
                </arguments>
            </configuration>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我在mvn clean install -X日志中看到命令已执行:

[DEBUG] Executing command line: [find, ./src/main/webapp/static/com/atomgraph/, -type, f, -name, '*.xsl']

xsl-files.txt文件已创建,但为空:/

如果我转到基于项目的目录并手动执行find ./src/main/webapp/static/com/atomgraph/ -type f -name '*.xsl',则会得到预期的.xsl文件列表:

./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/acl/imports/acl.xsl
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/acl/layout.xsl
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl
...

我想念什么?

1 个答案:

答案 0 :(得分:0)

这似乎有效:

https://server.com/api/plate-number/{{plate_value}}/assistance
相关问题