Guillaume Belrose
Guillaume Belrose

Reputation: 2518

How to skip tests when using Maven reactor?

I am working on a Maven multi-modules project. I want to build a given module and skip the unit tests to speed the build process up.

I've tried the following:

mvn reactor:make -Dmake.folders=search -Dgoals=package,-DskipTests

mvn reactor:make -Dmake.folders=search -Dgoals=package -Dmaven.test.skip=True

However, this does not have an effect at all. Any clues?

Upvotes: 3

Views: 9450

Answers (3)

jhericks
jhericks

Reputation: 5971

Your first line looks like the right idea, but instead of -Dgoals you should use -Dmake.goals.

From the reactor plugin examples page:

The reactor plugin launches a second copy of Maven to do its magic. This copy of Maven doesn't necessarily have all of the flags and options that you passed to your first copy of Maven, including the --debug flag, system properties, and -DskipTests.

You can pass additional arguments to the spawned Maven by treating them as goals with -Dmake.goals, like this:

mvn reactor:resume -Dmake.folders=barBusinessLogic -Dmake.goals=install,-DskipTests

In other words, the "goals" are just extra command-line parameters passed to the spawned Maven; they don't necessarily have to be "goals."

If you want to get really fancy, you may prefer to just dry run the reactor plugin in -Dmake.printOnly mode, described above. That will print out the command that the plugin would have used to build, but you can tweak that command line to your heart's content!

Upvotes: 6

nivekastoreth
nivekastoreth

Reputation: 1427

Given the project structure

/
  A/pom.xml
  B/pom.xml
  C/pom.xml
  D/pom.xml
  E/pom.xml
  pom.xml (parent pom file that includes A,B,C,D,E modules)

Similar to your

mvn reactor:make -Dmake.folders=C,D,E -Dgoals=package -Dmaven.test.skip=True

Although I'm not sure if my approach does EXACTLY what the reactor plugin does, but I found the following approach worked well enough for me

mvn -pl=C,D,E -DskipTests=true package

Upvotes: 3

jgifford25
jgifford25

Reputation: 2154

Have you tried including the option -Dmaven.test.skip=true (notice the case) to your command line argument you are running? Like Java, Maven is case sensitive. But generally, you can drop the =true part and that should also cause the tests to be skipped.

Upvotes: 2

Related Questions