'Configure Maven not to run tests if nothing changed

We have a large application consisting of many modules and full build (with integration tests) takes up to hour. Is there a way to configure maven in the way that it will skip tests on modules (or even classes), where nothing has been changed? Probably some plugin exists for that or this plugin can be written?



Solution 1:[1]

When using the command line:

mvn -q clean package -DskipTests

Solution 2:[2]

What you are looking for can be achieved by using gitflow-incremental-builder plugin, although it has dependency on git.

A maven extension for incremental building of multi-module 
 projects when using feature branches (Git Flow). 
Builds or tests only changed maven modules compared to
 reference branch in Git (e.g. origin/develop) and all their dependents.

Powered by JGit.

Solution 3:[3]

To skip test in the module you can add this in the pom.xml of this module :

<project>
[...]
<build>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.4.2</version>
    <configuration>
      <skipTests>true</skipTests>
    </configuration>
  </plugin>
</plugins>
</build>
[...]

or using a profile in the module pom.xml

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ian2thedv
Solution 2 Kobynet
Solution 3 Inforedaster