Maven. Skip plugin execution when running tests

10,303

Solution 1

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!

Solution 2

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
Share:
10,303
htshame
Author by

htshame

I enjoy Java, JavaScript, HTML, CSS and SQL. Love building web-applications from scratch. 6th person ever to proudly earn Liquibase bronze badge 212th person to earn Spring-Boot bronze badge ...and 7728th person to earn Java bronze badge :-) Keen on alpine skiing, playing guitar & piano. Currently creating some cool stuff at Wiley! Also I'm the author, creator and maintainer of my side projects: Ride Alert - simple app to alert users when it's time to leave if they want to get to their destination in time I visited - SPA to mark the regions of Russia where you've been to

Updated on June 27, 2022

Comments

  • htshame
    htshame almost 2 years

    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?

  • htshame
    htshame about 6 years
    yes, sure I've heard about maven profiles. Just wondering if there's an easier way to do this.
  • msa
    msa almost 3 years
    This does not seem to work if the <execution> in the POM has defined <skip>false</skip> in its <configuration> :-(