3

I am following advice from the mvn project to use multiple artifact threads for parallel artifact resolution. This command seems to give me the desired result.

mvn -Dmaven.artifact.threads=10 dependency:resolve-plugins

Will this settings.xml automatically set maven.artifact.threads on every call to mvn?

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> <profiles> <profile> <id>moreDependencyThreads</id> <activation> <property> <name>maven.artifact.threads</name> <value>10</value> </property> <activeByDefault>true</activeByDefault> </activation> </profile> </profiles> <activeProfiles> <activeProfile>moreDependencyThreads</activeProfile> </activeProfiles> </settings> 
4
  • Which maven version do you use? Commented May 18, 2016 at 23:20
  • 2
    System Properties can't be defined in settings.xml. Commented May 19, 2016 at 7:56
  • 1
    You know that by default already 5 threads used? Commented May 19, 2016 at 13:54
  • 1
    I did not. It seems that my question is answered. The defaults are OK and I cannot change system properties using settings.xml. Thank you for your help @khmarbaise! Commented May 19, 2016 at 14:14

2 Answers 2

6

You can set this property in your settings.xml file by changing it as follows:

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> <profiles> <profile> <id>moreDependencyThreads</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <maven.artifact.threads>10</maven.artifact.threads> </properties> </profile> </profiles> </settings> 
Sign up to request clarification or add additional context in comments.

4 Comments

Does that create a user property or set a system property? maven.apache.org/settings.html#Properties
When I tried this, mvn clean install -X printed out [DEBUG] properties used {java.vendor=Oracle Corporation, sun.java.launcher=SUN_STANDARD, env.XPC_SERVICE_NAME=0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.name=Mac OS X, ..., line.separator= , java.vm.name=Java HotSpot(TM) 64-Bit Server VM, maven.artifact.threads=10, file.encoding=UTF-8, java.specification.version=1.8, ...}, so it has set the desired property value.
When using Maven 3.2.5 and the -X option I don't see any output like [DEBUG] properties used ... :-(
No need for activeProfiles is there is activeByDefault is true.
2

As it also specified in tutorial, you can make it permanent via:

export MAVEN_OPTS=-Dmaven.artifact.threads=10 

If you call that it will be permanent for that session, if you add tis to your ~/.bash_profile it will be permanent for that user. Now on every call maven will work with these options.

3 Comments

Is it possible to define these options in settings.xml instead of in environment variables?
You can make the reverse of what you want but I am not sure about your request. Why you want to do that?
If I define this in settings.xml I can create a recommended settings.xml file for my team. It can define our best practices. Adding or setting environment variables is acceptable but not as portable.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.