Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Maven dependency collector implementation to breath-first

At work, we're using Maven to build a relatively large Java project, with a lot of dependencies that need to be downloaded. I don't know much about how Maven works, but when I saw it downloading the dependencies sequentially one-by-one, I thought it to be extremely inefficient, and that there had to be a setting, which allows it to download them in parallel (based on some dependency tree).

I've looked around on the internet, and I've found that since Maven version 3.9.0, there is this option: aether.dependencyCollector.impl = 'bf', which sets the dependency resolver to a 'breath-first' strategy (instead of the default depth-first). (Found here: https://maven.apache.org/resolver/configuration.html) I'm running Maven 3.9.1, so it should work.

On another page, I've found how to use the option (here: https://issues.apache.org/jira/browse/MRESOLVER-324).

I've tried adding the line 'aether.dependencyCollector.impl=bf' into $basedir/.mvn/maven.config, but I'm getting a ParseException:

org.apache.commons.cli.ParseException: Unrecognized maven.config file entries: [aether.dependencyCollector.impl=bf]

I've also tried using it direcly on the command line like so:

mvn clean install -DskipTests -Daether.dependencyCollector.impl=bf

But this also yields the following error:

Unknown lifecycle phase ".dependencyCollector.impl=bf".
You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy.

What am I doing wrong? Any help would be appreciated.

like image 680
Samuel Toman Avatar asked Oct 31 '25 12:10

Samuel Toman


1 Answers

.mvn/maven.config since from Maven 3.9.x should contains each argument in separate line - https://maven.apache.org/configure.html

example of .mvn/maven.config:

-Daether.dependencyCollector.impl=bf

Properties with dots should be wrapped in double quotes (probably only on Windows), so try:

mvn clean install -DskipTests -D"aether.dependencyCollector.impl=bf"
like image 146
Slawomir Jaranowski Avatar answered Nov 02 '25 03:11

Slawomir Jaranowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!