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

hts*_*ame 3 maven-plugin pom.xml maven

在我的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>
Run Code Online (Sandbox Code Playgroud)

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

运行时是否可能不执行插件mvn test

mvm*_*vmn 7

现在,frontend-maven-plugin 具有特定的键来禁用特定目标的执行。例如,添加系统属性skip.npm将跳过npm执行。您可以通过以下方式在运行Maven时添加它:

mvn test -Dskip.npm
Run Code Online (Sandbox Code Playgroud)


Luc*_*Luc 2

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

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

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

你有一个相关的问题:

使用特定配置文件时禁用 Maven 插件

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