MarcB
MarcB

Reputation: 559

Maven -T override to force some projects to be single threaded?

I have a project structure like this:

Parent Project
 - A
 - B
 - C
 - D (Parent to D.1-3)
   - D.1
   - D.2 
   - D.3
 -E

ABCE are code projects (OSGi bundles) that also contain unit tests, D.1, D.2, D.3 are integration tests using pax-exam that start using a jUnit runner.

ABCE unit tests can be run in parallel. D.1-3 can not be run in parallel. This is easy, I simply tell surefire in my parent pom to run everything in parallel, and in D's pom I tell surefire to run everything one at a time. D.1-3 have D as parent pom.

Ok, so now I have parallel test execution. I also really want parallel builds.

If I use the -T 5 flag in maven this means run several modules in parallel. When it comes to surefire this means I'll have 5 instances of surefire each running its own tests in parallel. This is also fine.

The problem is that maven may decide to run D.1, D.2, D.3 in parallel, and then those testcases will run in parallel no matter what I tell surefire.

Is there any way to override the -T flag of maven inside the D.pom?

Or any other way to force part of the build to go serialized? Other than moving D.1-3 out of this project and into another that is always run with -T 1.

Upvotes: 2

Views: 3828

Answers (3)

Lyle Z
Lyle Z

Reputation: 1363

To limit the number of threads to one, use:

mvn clean install -T 1

Upvotes: 1

wilson
wilson

Reputation: 163

A potentially easier way would be to override the surefire.forkCount in your module's pom. This way, you have the benefit of parallel builds and parallel test executions with only the particularly problematic module being run serially.

Upvotes: 0

lukasz-wolski
lukasz-wolski

Reputation: 51

have a look at: maven invoker plugin

it allows for launching maven within itself via configuration in a .properties file. Thus, it would be possible to build projects D.x separately with desired -T setting.

Upvotes: 0

Related Questions