简体   繁体   中英

artifactory-maven-plugin: How to resolve dependencies from private Artifactory without settings.xml

How can I configure the artifactory-maven-plugin to resolve dependencies from our private Artifactory server?

The official documentation explains on how to publish: https://www.jfrog.com/confluence/display/RTF/Maven+Artifactory+Plugin#MavenArtifactoryPlugin-Usage

Usually, dependency resolving works by adding servers to my .m2/settings.xml and specifying credentials there. However, in a cloud Docker build environment, it is difficult to place the settings.xml inside the container. It would be much easier if the plugin could be configured accordingly.

The Gradle Artifactory Plugin has explicit documentation about this (see dependencies resolution): https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin#GradleArtifactoryPlugin-UsingtheArtifactoryPluginDSL

Turns out the Maven plugin also has a resolver configuration option. But it is not documented anywhere. This does not work (Maven still won't try to download dependencies from Artifactory):

<plugin>
                <groupId>org.jfrog.buildinfo</groupId>
                <artifactId>artifactory-maven-plugin</artifactId>
                <version>2.6.1</version>
                <inherited>false</inherited>
                <configuration>
                    <resolver>
                        <contextUrl>${artifactory.context.url}</contextUrl>
                        <username>${artifactory.username}</username>
                        <password>${artifactory.password}</password>
                        <repoKey>libs-local</repoKey>
                    </resolver>
                </configuration>
</plugin>

You can configure Maven to resolve artifacts through Artifactory you need to modify the settings.xml. You can generate one automatically, or modify it manually.

jfrog docs has provided steps to do this ,

In the Artifact Repository Browser of the Artifacts module, select Set Me Up. In the Set Me Up dialog, set Maven in the Tool field and click "Generate Maven Settings". You can now specify the repositories you want to configure for Maven.

Check here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM