3

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?

Sled
  • 18,541
  • 27
  • 119
  • 168
Guillaume Belrose
  • 2,478
  • 4
  • 23
  • 24

3 Answers3

6

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!

jhericks
  • 5,833
  • 6
  • 40
  • 60
3

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
nivekastoreth
  • 1,407
  • 13
  • 19
  • You can use maven.test.skip or skipTests, which ever works for you (if you're only using Surefire and some other suites they should behave identically) – nivekastoreth Nov 29 '10 at 23:39
  • 2
    They don't behave identically. maven.test.skip does not build the tests, skipTests just doesn't execute them. If another module defines a dependency on the test jar (dependencies between the tests of different modules), the module won't compile. – Christoph Oct 19 '11 at 11:05
2

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.

jgifford25
  • 2,164
  • 1
  • 14
  • 17
  • This does not work for me. Here is the line I've tried: mvn reactor:make -Dmake.folders=search -Dgoals=package,-Dmaven.test.skip=true – Guillaume Belrose Nov 23 '10 at 12:42
  • 3
    I'm assuming that the comma between -Dgoals and -Dmaven.test.skip is a typo. If so, have you tried generating the effective pom.xml file. It could be that something in the pom.xml files are overriding your command line test skip. Which is weird, because the command line should override anything in the settings.xml and pom.xml. To generate the effective pom.xml, run this ==> mvn help:effective-pom. Look for the surefire plug-in and see if skipTests is set. – jgifford25 Nov 23 '10 at 14:39