【发布时间】:2020-12-13 05:11:14
【问题描述】:
我需要预处理 Java Maven 项目中的一些资源文件 (*.xsl)。
我发现exec-maven-plugin 能够执行shell 命令,并认为我可以分两步完成:
- 匹配文件列表并将其写入文件
- 启动一个 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
...
我错过了什么?
【问题讨论】:
标签: java bash shell maven exec-maven-plugin