最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Download from authenticated private repository without settings.xml file - Stack Overflow

programmeradmin6浏览0评论

I would like to download dependencies from a private repository which requires authentication without having to bake the settings.xml in the code base, or in the host.

We need to download some dependencies from a private repository, this is the pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0"
         xmlns:xsi=";
         xsi:schemaLocation=".0.0 .0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>question</artifactId>
    <version>4.1</version>
    <packaging>jar</packaging>

    <properties>
        [...]

    </properties>

    <build>
        <plugins>
            [...]
            <plugin>
              
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>private-repository-release</id>
            <url>;/url>
        </repository>
    </distributionManagement>

</project>

Since we need to authenticate from this private repository, we are relying on this setting.xml file:

<settings xmlns=".0.0" xmlns:xsi=";
          xsi:schemaLocation=".2.0 .2.0.xsd">
    <servers>
        <server>
            <id>private-repository-release</id>
            <username>someusername</username>
            <password>somepassword</password>
        </server>
    </servers>
</settings>

(This question is not about how to securely pass in the username password, or substitute them via the environment variable to the file, or if the settings.xml file should be checked in, or where should the setting.xml file sit, but how to get rid of the file entirely.)

As of now, we either have this settings.xml file baked inside the host in the ~/.m2

or

We check in the settings.xml file in the code base and run a command like mvn clean install -s settings.xml

Is there a way to avoid having to rely on the settings.xml file?

I tried removing the settings.xml file, and run a command like:

mvn clean install -Dservers.server.username=someusername -Dservers.server.password=somepassword

Is there a way we can pass the information of the settings.xml via arguments of the mvn command?

发布评论

评论列表(0)

  1. 暂无评论