openrewrite / openrewrite/rewrite
Enable Maven parallelism via `.mvn/maven.config` file
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What problem are you trying to solve?
The vast majority of Maven builds I've encountered are single-threaded - quite a waste of processing power in today's multi-core world. While not every multi-module Maven build will be compatible with parallelism, those that are are typically provide CLI arguments on every invocation like -T 1C or --threads 0.5C.
There is no way to provide a parallelism setting in a pom.xml file.
I recently discovered that Maven 3.3.1+ has a facility to persist default CLI arguments in a file called .mvn/maven.config (docs). (thanks @bdemers)
What precondition(s) should be checked before applying this recipe?
- Maven version is 3.3.1+
- For MVP, does
.mvn/maven.configfile already exist? - For future releases, parameterize the parallelism factor in the recipe. Defaulting to
1C(one thread per CPU core) is a reasonable default. - For future releases, parse
.mvn/maven.configif exists already and add/edit-Tor--threadsargument. - Expanding beyond that, maybe provide a general-purpose Maven CLI argument persistence recipe.
Describe the situation before applying the recipe
.mvn/maven.config does not exist
Describe the situation after applying the recipe
.mvn/maven.config is created with contents:
-T 1C
Have you considered any alternatives or workarounds?
Not really. Other than a bespoke shell script to invoke Maven, .mvn/maven.config is the only method I know of to "natively" provide CLI argument defaults.
Any additional context
If I were a consumer of this recipe, I'd want to ensure that enabling parallelism doesn't break my build and that the results before/after are the same. I'm not sure how this could be verified.
Are you interested in contributing this recipe to OpenRewrite?
Absolutely.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's Maven configuration documentation and the described before/after state: no .mvn/maven.config versus a file containing -T 1C. Identify the existing OpenRewrite recipe entry point and test conventions for creating Maven project files. Done means the recipe applies only under the stated Maven precondition and produces the requested configuration without silently expanding into the future parsing and parameterization work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100