Search code examples
maven

How do I define maven system properties in settings.xml?


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>

Solution

  • 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>