The script is using the following plugins
plugins {
id 'com.jfrog.artifactory' version '3.0.1'
id 'maven'
id 'java'
}
If the code specifies the username and password then the dependencies are resolved and returned from Artifactory. If the script does not specify the credentials, then the following is returned:
---- > > Could not resolve org.apache.commons:commons-lang3:3.3.2. >
Required by: >
com.ooooo.impact.common:Encryption Maven project:1.0-SNAPSHOT >
Could not HEAD ‘http://repo1.xxx.com/artifactory/libs-snapshots/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.pom’. Received status code 401 from server: Unauthorized >
Could not HEAD ‘http://repo1.xxx.com/artifactory/libs-releases/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.pom’. Received status code 401 from server: Unauthorized ----
Is there a way to read the credentials from the .m2/settings.xml file and use the credentials for dependencies?
Gradle doesn’t provide any built-in support for reading Maven settings files. You may want to take a look at this plugin however it doesn’t integrate with the artifactory plugin. However, if you are simply using Artifactory as a Maven repo, you likely don’t need to use the plugin anyway.
Thanks for the suggestion. I updated the build gradle script to:
plugins {
id "net.linguica.maven-settings" version "0.3"
id 'maven'
id 'java'
}
If the settings.xml file is located in the user location ${user.home}/.m2 then the build was successful! thanks Also, if the settings.xml file is in the $M2_HOME/conf then the build was also successful.
I have some questions:
- I have been testing with the --refresh-dependencies option to avoid cached values. Are there other options or test procedures? 2. Does the maven-settings totally replace the artifactory plugin? When would the artifactory plugin be needed? 3. The gradle build script requires that entries for the repositories with the name and url values. Is this true? Is there a way to not have the repository information in the build script?
repositories {
maven {
name "O-Snaps"
url "http://repo1.u.com/artif/libs-snaps"
}
...
}
I confirm that the maven-settings plugin allows the build to access and resolve for dependencies, but does not integrate with the artifactory plugin for the repository credentials.
Could you elaborate on how to access Artifactory as a Maven repo for deploying artifacts? Thanks!