【问题标题】:Maven. Skip plugin execution when running tests马文。运行测试时跳过插件执行
【发布时间】:2018-10-01 21:50:29
【问题描述】:

在我的pom.xml 我有frontend-maven-plugin

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.4</version>

    <configuration>
        <nodeVersion>v6.11.0</nodeVersion>
        <npmVersion>3.10.10</npmVersion>
        <workingDirectory>src/main/frontend</workingDirectory>
    </configuration>

    <executions>
        <execution>
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
        </execution>
        <execution>
            <id>npm install</id>
            <goals>
                <goal>npm</goal>
            </goals>
        <execution>
        <execution>
            <id>npm run build</id>
            <goals>
                <goal>npm</goal>
            </goals>

            <configuration>
                <arguments>run build</arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

运行它需要一些时间,并且在我运行测试时不需要这个插件。

我运行mvn test时是否可以不执行插件?

【问题讨论】:

    标签: java spring-boot maven pom.xml frontend-maven-plugin


    【解决方案1】:

    frontend-maven-plugin 现在has specific keys 禁用特定目标的执行。例如,添加系统属性skip.npm 将跳过 npm 执行。运行maven的时候可以这样添加:

    mvn test -Dskip.npm
    

    【讨论】:

    • 如果 POM 中的 &lt;execution&gt; 在其 &lt;configuration&gt; 中定义了 &lt;skip&gt;false&lt;/skip&gt;,这似乎不起作用 :-(
    【解决方案2】:

    您听说过 Maven 配置文件吗? http://maven.apache.org/guides/introduction/introduction-to-profiles.html

    我了解当您想测试一个包时,您不想构建一个更大的包。

    您可以定义一个配置文件来准确选择您想要构建和测试的模块。

    你有一个相关的问题:

    Disable maven plugins when using a specific profile

    如果对您有帮助,请告诉我们!

    【讨论】:

    • 是的,我确实听说过 Maven 配置文件。只是想知道是否有更简单的方法来做到这一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-21
    • 1970-01-01
    相关资源
    最近更新 更多