We have a need to be able to skip a submodule in certain environments.
The module in question contains integration tests and takes half an hour to run. So we want to include it when building on the CI server, but when developers build locally (and tests get run), we want to skip that module.
Is there a way to do this with a profile setting? I've done some googling and looked at the other questions/answers here and haven't found a good solution.
I suppose one option is to remove that submodule from the parent pom.xml
entirely, and just add another project on our CI server to just build that module.
Suggestions?
It's possible to decide which reactor projects to build by specifying the
-pl
command line argument:It accepts a comma separated list of parameters in one of the following forms:
[groupId]:artifactId
Thus, given the following structure:
You can specify the following command line:
to build everything. Remove elements in the list to build only the modules you please.
EDIT: as blackbuild pointed out, as of Maven 3.2.1 you have a new
-el
flag that excludes projects from the reactor, similarly to what-pl
does:Sure, this can be done using profiles. You can do something like the following in your parent pom.xml.
In your CI, you would run maven with the
ci
profile, i.e.mvn -P ci clean install
there is now (from 1.1.1 version) a 'skip' flag in pit.
So you can do things like :
in your module, and pit will skip
[INFO] --- pitest-maven:1.1.3:mutationCoverage (default-cli) @ module-selenium --- [INFO] Skipping project
The notion of multi-module projects is there to service the needs of codependent segments of a project. Such a client depends on the services which in turn depends on say EJBs or data-access routines. You could group your continuous integration (CI) tests in this manner. I would rationalize that by saying that the CI tests need to be in lock-step with application logic changes.
Suppose your project is structured as:
The
project-root/pom.xml
defines modulesThe
ci/pom.xml
defines profiles such as:This will result in Maven skipping tests in this module except when the profile named
CI
is active. Your CI server must be instructed to executemvn clean package -P CI
. The Maven web site has an in-depth explanation of the profiling mechanism.Maven version 3.2.1 added this feature, you can use the
-pl
switch (shortcut for--projects
list) with the!
to exclude certain submodules.Be careful in bash the character ! is a special character, so you either have to single quote it (like I did) or escape it with the backslash character.
The syntax to exclude multiple module is the same as the inclusion
EDIT Windows does not seem to like the single quotes, but it is necessary in bash ; in Windows, use double quotes (thanks @awilkinson)