How can gradle use repository settings from maven's settings.xml to publish artifacts to a repository?

(Peter Kahn) #1

Problem: Want gradle to build (a custom plugin) and publish it to my internal artifact repository without hard coding credentials in my build.gradle file

Qualifying name for maven-publish-auth plugin
Deploy to Internal Maven Repo without hardcoding credentials
Gradle and maven-publis-auth issue
(Peter Kahn) #2

To do this we need to * have maven settings.xml file configured properly * enable maven-publish * enable maven-publish-auth ** set buildscript dependencies and repositories to fine auth

  • configure maven publish

We enable the two plugins and add auth plugin + repository info to the build script’s environment

apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
  buildscript {
  dependencies {
    classpath ''
      repositories {
    maven {
      url ""

Define the publishing section so we can publish and add in the name + url of a repository from the maven settings.xml

publishing {
    publications {
        mavenJava(MavenPublication) {
  repositories {
  maven {
    name "snapshots"
    url ""


      <password>snap password</password>

Passing the location of the Maven settings.xml file to Maven Publish