行家。 运行 测试时跳过插件执行

Maven. Skip plugin execution when running tests

在我的 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时是否可以不执行插件?

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

我明白当你想测试一个包时,你不想构建一个更大的包。

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

你有一个相关的问题:

Disable maven plugins when using a specific profile

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

frontend-maven-plugin 现在 has specific keys 禁止执行特定目标。例如,添加 system 属性 skip.npm 将跳过 npm 执行。您可以在 运行 maven 中以这种方式添加它:

mvn test -Dskip.npm