【问题标题】:Maven exec-maven-plugin and maven-resources-plugin not running, not sure whyMaven exec-maven-plugin 和 maven-resources-plugin 没有运行,不知道为什么
【发布时间】:2014-04-19 00:23:40
【问题描述】:

我在 maven pom.xml 文件中添加了几个新插件。

当我发出以下命令时,我无法弄清楚为什么 exec-maven-pluginmaven-resources-plugin 没有运行:mvn install。其他 maven 插件确实按预期执行。

当我运行mvn exec:exec 时,exec-maven-plugin 确实会运行。

我尝试了许多不同的阶段,但无济于事。

我在这里做错了什么,我应该尝试什么?


这是我的 maven 文件的相关部分

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <id>build-spa-bower</id>
                <phase>validate</phase>
                <configuration>
                    <executable>bower</executable>
                    <arguments>install</arguments>
                    <workingDirectory>src/main/spa</workingDirectory>
                </configuration>
            </execution>
            <execution>
                <id>build-spa-grunt</id>
                <phase>validate</phase>
                <configuration>
                    <executable>bower</executable>
                    <arguments>install</arguments>
                    <workingDirectory>src/main/spa</workingDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
                <id>resource-spa</id>
                <phase>compile</phase>
                <configuration>
                    <outputDirectory>${project.groupId}/${project.artifactId}/spa</outputDirectory>
                    <resources>
                        <directory>src/main/spa/dist</directory>
                        <filtering>false</filtering>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <!-- ... -->
</plugins>

编辑:

找到了 exec 插件的答案,但还没有找到资源插件的答案。

exec 插件需要一个目标才能触发

&lt;goals&gt;&lt;goal&gt;exec&lt;/goal&gt;&lt;/goals&gt; 添加到每个&lt;execution&gt; 对我有用。

【问题讨论】:

    标签: maven maven-plugin pom.xml exec-maven-plugin maven-resources-plugin


    【解决方案1】:

    如果您将配置放在&lt;execution/&gt; 中,则需要指定在此执行中需要运行哪些目标。

    对于默认链接到某个阶段的插件,您还可以在&lt;executions/&gt; 之外指定配置,该配置将在该插件的默认阶段使用。

    【讨论】:

    【解决方案2】:

    找到答案:

    exec 插件需要一个目标才能触发。

    &lt;goals&gt;&lt;goal&gt;exec&lt;/goal&gt;&lt;/goals&gt; 添加到每个&lt;execution&gt;

    资源插件问题同样得到修复。

    &lt;goals&gt;&lt;goal&gt;copy-resources&lt;/goal&gt;&lt;/goals&gt; 添加到每个&lt;execution&gt;

    这些对我有用。

    【讨论】:

      【解决方案3】:

      还有

      <phase>prepare-package</phase>
      

      是强制性的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-03
        • 2014-04-23
        • 2012-03-13
        • 2018-06-16
        • 2014-10-10
        • 1970-01-01
        • 1970-01-01
        • 2020-01-01
        相关资源
        最近更新 更多