Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven. Skip plugin execution when running tests

In my pom.xml I have 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>

It takes some time to run it and don't need this plugin when I run tests.

Is it possible to not execute the plugin when I run mvn test?

like image 343
htshame Avatar asked Apr 21 '18 09:04

htshame


People also ask

Why tests are skipped Maven surefire plugin?

When the Surefire plugin reaches the test goal, it will skip the unit tests if the maven. test. skip properties is set to true . Another way to configure Maven to skip unit tests is to add this configuration to your project's pom.

What is Maven test Skip?

test. skip=true to skip the entire unit test. By default, when building project, Maven will run the entire unit tests automatically. If any unit tests is failed, it will force Maven to abort the building process. In real life, you may STILL need to build your project even some of the cases are failed.

How can you override skipTests parameter in command line?

Skipping by default by initializing the skipTests element value to true in properties and then overriding it through the command line by mentioning the value of -DskipTests in the maven phase/build execution command.


2 Answers

The frontend-maven-plugin now has specific keys to disable execution of particular goals. For example, adding system property skip.npm will skip npm execution. You can add it when running maven this way:

mvn test -Dskip.npm
like image 124
mvmn Avatar answered Sep 26 '22 14:09

mvmn


did you heard about maven profile? http://maven.apache.org/guides/introduction/introduction-to-profiles.html

I understand that when you want to test a package, you don't want to build a bigger one.

You could define a profile that choose exactly what module you want to build and test.

You have a related question there:

Disable maven plugins when using a specific profile

Let us know if it helped you!

like image 45
Luc Avatar answered Sep 22 '22 14:09

Luc