【问题标题】:Maven exec-plugin pom.xml definition: activate shell interpretation for charactersMaven exec-plugin pom.xml 定义:激活字符的 shell 解释
【发布时间】:2012-04-04 15:22:14
【问题描述】:

我使用 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>

现在,如果我将此代码示例中定义的参数设置为 &lt;argument&gt;-h&lt;/argument&gt;,终端调用 mvn org.codehaus.mojo:exec-maven-plugin:exec -P optimizepng 将按预期工作并打印出 optipng 的帮助。

我发现,星号可能不会被解释为 shell 字符。这可能是它的原因吗?如果是这样,我可以在任何地方应用一个标签来切换 shell 解释吗?

首先关于我的计划的其他信息: 我想使用 optipng 优化 src/main/webapp/images/ 文件夹中的所有 png 文件。我将用作 shell 命令的是optipng src/main/webapp/images/*.png

【问题讨论】:

    标签: java shell plugins maven character


    【解决方案1】:

    好的,现在很快。我想,我可以直接启动 shell,让它解释我想要执行的终端调用。

    <configuration>
        <executable>sh</executable>
        <arguments>
            <argument>-c</argument>
            <argument>optipng src/main/webapp/images/*.png</argument>
        </arguments>
    </configuration>
    

    这个代码示例是我必须修复的,所以它完成了工作。

    【讨论】:

      猜你喜欢
      • 2019-08-01
      • 1970-01-01
      • 2016-01-31
      • 1970-01-01
      • 2021-01-02
      • 2011-12-20
      • 2018-03-03
      • 2014-04-23
      • 1970-01-01
      相关资源
      最近更新 更多