如何在settings.xml中定义maven系统属性?

如何在settings.xml中定义maven系统属性?,maven,Maven,我下面介绍如何使用多个工件线程进行并行工件解析。这个命令似乎给了我想要的结果 mvn-Dmaven.artifact.threads=10依赖项:解析插件 此settings.xml是否会在每次调用mvn时自动设置maven.artifact.threads <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

我下面介绍如何使用多个工件线程进行并行工件解析。这个命令似乎给了我想要的结果

mvn-Dmaven.artifact.threads=10依赖项:解析插件

此settings.xml是否会在每次调用mvn时自动设置
maven.artifact.threads

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

更多依赖线程
maven.artifact.threads
10
真的
更多依赖线程

正如本教程中所述,您可以通过以下方式将其永久化:

export MAVEN_OPTS=-Dmaven.artifact.threads=10

如果您调用该会话,则该会话将是永久的;如果您将tis添加到~/.bash_配置文件,则该会话将是永久的。现在,在每次通话中,maven都会使用这些选项

您可以在settings.xml文件中设置此属性,方法如下:

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

    <activeProfiles>
        <activeProfile>moreDependencyThreads</activeProfile>
    </activeProfiles>
</settings>

更多依赖线程
真的
10
更多依赖线程

是否可以在settings.xml中定义这些选项,而不是在环境变量中定义这些选项?您可以按相反的方式来定义,但我不确定您的请求。为什么要这样做?如果我在settings.xml中定义这个,我可以为我的团队创建一个推荐的settings.xml文件。它可以定义我们的最佳实践。添加或设置环境变量是可以接受的,但不是可移植的。您使用哪个maven版本?无法在
settings.xml
中定义系统属性。您知道默认情况下已经使用了5个线程吗?我没有。我的问题似乎得到了回答。默认设置正常,我无法使用settings.xml更改系统属性。谢谢你的帮助@khmarbaise!这是创建用户属性还是设置系统属性?当我尝试此操作时,
mvn clean install-X
打印出
[DEBUG]使用的属性{java.vendor=Oracle Corporation,sun.java.launcher=sun_STANDARD,env.XPC_SERVICE_NAME=0,sun.management.compiler=HotSpot 64位分层编译器,os.NAME=Mac os X,…,line.separator=,java.vm.NAME=java HotSpot(TM)64位服务器VM,maven.artifact.threads=10,file.encoding=UTF-8,java.specification.version=1.8,…}
,因此它设置了所需的属性值。当使用maven 3.2.5和
-X
选项时,我看不到任何像
[DEBUG]properties used…
:-(