[英]Maven exec-plugin pom.xml definition: activate shell interpretation for characters
I use the Maven plugin exec and have defined it in a profile of my pom.xml like this:我使用 Maven 插件 exec 并在我的 pom.xml 的配置文件中定义它,如下所示:
<profile>
<id>optimizepng</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>optipng</executable>
<arguments>
<argument>src/main/webapp/images/*.png</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Now, if I set the argument that I defined in this code sample to <argument>-h</argument>
, the terminal call mvn org.codehaus.mojo:exec-maven-plugin:exec -P optimizepng
works as expected and prints out the help of optipng.现在,如果我将我在此代码示例中定义的参数设置为
<argument>-h</argument>
,终端调用mvn org.codehaus.mojo:exec-maven-plugin:exec -P optimizepng
按预期工作并打印在optipng的帮助下。
What I figured out is, that the asterisk may not be interpreted as a shell character.我发现星号可能不会被解释为 shell 字符。 Could this be the reason for it?
这可能是它的原因吗? If so, is there a tag that I can apply anywhere to toggle shell interpretation?
如果是这样,是否有我可以在任何地方应用的标签来切换 shell 解释?
Additional info on my plan in the first place: I want to optimize all png files in the src/main/webapp/images/ folder, using optipng.首先关于我的计划的附加信息:我想使用 optipng 优化 src/main/webapp/images/ 文件夹中的所有 png 文件。 What I would use as a shell command is
optipng src/main/webapp/images/*.png
.我将用作 shell 命令的是
optipng src/main/webapp/images/*.png
。
Okay, now that was quick.好的,现在很快了。 I figured out, I could just start the shell instead and let it interpret the terminal call I want to execute.
我想通了,我可以只启动 shell,让它解释我想执行的终端调用。
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>optipng src/main/webapp/images/*.png</argument>
</arguments>
</configuration>
This code sample is what I had to fix, so this does the job.这个代码示例是我必须修复的,所以它完成了工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.