# uploadArchives ignoring user's maven settings

**URL:** https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539
**Category:** Old Forum Archive
**Created:** [November 25, 2013, 6:40pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539 "2013-11-25T18:40:00Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 25, 2013, 6:40pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/1 "2013-11-25T18:40:00Z")

</div>

When using the install task, my /USER\_HOME/.m2/settings.xml configuration is taken into account. However, when I use the uploadArchives task, those same user settings are ignored.

This appears to be caused by this:

org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver (line 75)

```gradle
protected MavenSettingsSupplier mavenSettingsSupplier = new EmptyMavenSettingsSupplier();

```

The install task works because it overrides the mavenSettingsSupplier:

org.gradle.api.publication.maven.internal.ant.BaseMavenInstaller (line 31)

```gradle
mavenSettingsSupplier = new MaybeUserMavenSettingsSupplier();

```

Is there a reason that the AbstractMavenResolver is not using the MaybeUserMavenSettingsSupplier in all cases? It falls back to the EmptyMavenSettingsSupplier, so it seems like it should be safe. It seems like a bug to me.

Here is what my environment looks like:

```gradle
------------------------------------------------------------
Gradle 1.8
------------------------------------------------------------
  Build time:
 2013-09-24 07:32:33 UTC
Build number: none
Revision:
   7970ec3503b4f5767ee1c1c69f8b4186c4763e3d
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.7.0_45 (Oracle Corporation 24.45-b08)
OS:
         Mac OS X 10.8.5 x86_64

```

The same thing is failing on centos linux…

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 25, 2013, 8:24pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/2 "2013-11-25T20:24:00Z")

</div>

In which ways would you expect the Maven settings file to be taken into account? As far as I know, the only thing that’s taken into account is the location of the local Maven repository, which is only necessary when installing to that repository. Apart from that, the idea is to configure everything on Gradle’s side, without having this information polluted with some Maven files that may be lying around on someone’s machine.

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 25, 2013, 8:31pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/3 "2013-11-25T20:31:00Z")

</div>

I think the location of the local maven repo is the only part it should worry about.

That makes perfect sense to me.

The problem is that the uploadArchives does not take that location into account. That is the only part that is missing, and it appears that it works differently for the install task than it does in the uploadArchives task. The install takes does take that location into account.

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 25, 2013, 8:39pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/4 "2013-11-25T20:39:00Z")

</div>

Why would ‘uploadArchives’ need to know about the local Maven repository? Installing into the local Maven repository is the responsibility of the ‘install’ task.

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 25, 2013, 8:58pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/5 "2013-11-25T20:58:00Z")

</div>

I ran

```gradle
gradlew install

```

from a project, and it put the artifacts into my custom maven location. (as defined in the USER\_HOME/.m2/settings.xml)

I then ran

```gradle
gradlew uploadArchives

```

from the same project and it put the artifacts into the standard maven location.

In looking at the code in a debugger, at runtime uploadArchives used the EmptyMavenSettingsSupplier from AbstractMavenResolver, but the install task, used the BaseMavenInstaller.

I don’t think the maven plugin uses the same install task in both cases…

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 26, 2013, 7:15am UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/6 "2013-11-26T07:15:00Z")

</div>

Sounds like you haven’t configured ‘uploadArchives’ correctly. It isn’t meant to be used to install to a local Maven repository.

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 26, 2013, 3:14pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/7 "2013-11-26T15:14:00Z")

</div>

This is the only configuration we have for uploadArchives.

```gradle
uploadArchives {
        repositories.mavenDeployer {
            configuration = configurations.deployerJars
            snapshotRepository(url: "http://OUR_SNAPSHOTS_URL") {
                authentication(userName: project.snapshotRepoUserName, password: project.snapshotRepoPassword)
            }
            repository(url: "http://OUR_RELEASES_URL") {
                authentication(userName: project.releaseRepoUserName, password: project.releaseRepoPassword)
            }
            uniqueVersion = true
        }
    }

```

At one time we did have this:

```gradle
uploadArchives.dependsOn install

```

But I took that out, and it still puts the archives in the default maven location (USER\_HOME/.m2/repository)

Here is the entirety of our build.gradle

```gradle
apply plugin: 'project-report'
apply plugin: 'release'
  project.ext {
    defaultSitePublicationLocation = "file://${projectDir}/site"
}
  buildscript {
    //The following repositories are used only to resolve plugins for the build itself.
    repositories {
        mavenCentral()
        maven {
            url 'https://oss.sonatype.org/content/groups/public'
        }
        maven {
            url "http://OUR_SNAPSHOT_URL"
        }
        maven {
            url "http://OUR_RELEASES_URL"
        }
    }
      dependencies {
        classpath(
                [group: 'org.gradle.api.plugins', name: 'gradle-clover-plugin', version: project.cloverPluginVerison],
                [group: 'au.com.ish.gradle', name: 'release', version: project.releasePluginVersion],
        )
          classpath(group:'org.oclc.gradle', name:'gradle-site-plugin', version: project.sitePluginVersion) {
            exclude group: 'xerces', module: 'xercesImpl'
        }
    }
}
  allprojects {
      project.ext {
        sitePublicationLocation = ''
    }
      if(project.mavenSiteLocation) {
        project.sitePublicationLocation = project.mavenSiteLocation
    }
    else {
        project.sitePublicationLocation = project.defaultSitePublicationLocation
    }
      apply plugin: 'site'
    site {
        siteLocation = project.sitePublicationLocation
        dependsOnTasks = ['groovydoc', 'javadoc', 'test', 'pmdMain', 'pmdTest', 'findbugsMain', 'findbugsTest']
    }
      release {
        failOnSnapshotDependencies = true
        scm = 'svn'
        username = project.svnUserName
        password = project.svnPassword
    }
      group = 'org.oclc.instrumentation'
    version = release.projectVersion
}
  subprojects {
    apply plugin: 'java'
    apply plugin: 'maven'
      sourceCompatibility = new BigDecimal(project.javaVersion as String)
    targetCompatibility = new BigDecimal(project.javaVersion as String)
      compileJava {
        sourceCompatibility = project.javaVersion
        targetCompatibility = project.javaVersion
        options.fork = true
        options.forkOptions.executable = "${project.javaJdkHome}/bin/javac"
        options.encoding = "UTF-8"
    }
      apply plugin: 'checkstyle'
    checkstyle {
        toolVersion = project.checkstyleVersion
        configFile = rootProject.file('config/checkstyle/checkstyle.xml')
        configProperties = [
                'checkstyle.cache.file': rootProject.file('build/checkstyle.cache'),
        ]
        sourceSets = [sourceSets.main]
    }
      apply plugin: 'findbugs'
    findbugs {
        ignoreFailures = false
    }
      apply plugin: 'pmd'
    pmd {
        ignoreFailures = false
    }
      apply plugin: 'clover'
    clover {
        licenseLocation = "${rootProject.projectDir}/config/clover/clover.license"
        targetPercentage = '100%'
          report {
            xml = true
        }
    }
      configurations {
        deployerJars
    }
      repositories {
        mavenCentral()
        maven {
            url "http://OUR_SNAPSHOT_URL"
        }
        maven {
            url "http://OUR_RELEASES_URL"
        }
    }
      dependencies {
        clover([group: "com.cenqua.clover", name: "clover", version: project.cloverVersion])
        deployerJars([group: 'org.apache.maven.wagon', name: 'wagon-http', version: project.wagonHttpVersion])
        testCompile(
                [group: 'junit', name: 'junit', version: project.junitVersion],
                [group: 'org.mockito', name: 'mockito-all', version: project.mockitoVersion]
        )
    }
      check.dependsOn cloverGenerateReport
  //
  install.dependsOn check
//
//
  uploadArchives.dependsOn install
      uploadArchives {
        repositories.mavenDeployer {
            configuration = configurations.deployerJars
            snapshotRepository(url: "http://OUR_SNAPSHOT_URL") {
                authentication(userName: project.snapshotRepoUserName, password: project.snapshotRepoPassword)
            }
            repository(url: "http://OUR_RELEASES_URL") {
                authentication(userName: project.releaseRepoUserName, password: project.releaseRepoPassword)
            }
            uniqueVersion = true
        }
    }
      task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }
      task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier = 'javadoc'
        from javadoc.destinationDir
    }
      artifacts {
        archives sourcesJar
        archives javadocJar
    }
      /**
     * Allows clients to see where dependencies are being fetched from.
Useful in debugging dependency problems.
     */
    task showMeCache << {
        configurations.each { config ->
            println "${config.name}--------------------------"
            config.each { println it }
            println "----------------------------------------"
        }
    }
}
  apply plugin: 'idea'
idea.project {
    jdkName = project.javaVersion
}
  /**
 * Allows gradle to packaged as part of the build.
This generates infrastructure files to be committed once.
 * Then the build itself will use (or download) the correct version of gradle.
 */
task wrapper(type: Wrapper) {
    gradleVersion = project.gradleVersion
}

```

If you see something wrong in our configuration, I would be happy to change it.

I still think though that I don’t see any reason for org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver to use the EmptyMavenSettingsSupplier, when the MaybeUserMavenSettingsSupplier exists.

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 26, 2013, 3:24pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/8 "2013-11-26T15:24:00Z")

</div>

Are you saying that running ‘gradle uploadArchives’ publishes the artifact to a local directory rather than the configured remote repository? Which Gradle version are you using?

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 26, 2013, 4:23pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/9 "2013-11-26T16:23:00Z")

</div>

uploadArchives correctly is putting the artifacts in the remote repository, but it is ALSO publishing to the local repo, and it is ignoring my override of the local repository from my USER\_HOME/.m2/settings.xml.

Running gradlew install works correctly. It pays attention to my USER\_HOME/.m2/settings.xml.

Using gradle 1.8

```gradle
------------------------------------------------------------
Gradle 1.8
------------------------------------------------------------
Build time:
 2013-09-24 07:32:33 UTC
Build number: none
Revision:
   7970ec3503b4f5767ee1c1c69f8b4186c4763e3d
Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.7.0_45 (Oracle Corporation 24.45-b08)
OS:
         Mac OS X 10.8.5 x86_64

```

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 26, 2013, 4:26pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/10 "2013-11-26T16:26:00Z")

</div>

That’s a bug then. ‘uploadArchives’ should only publish to the configured repository. I’ve heard about this one before. You could have a look in JIRA; perhaps it was already fixed in 1.9.

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 26, 2013, 4:27pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/11 "2013-11-26T16:27:00Z")

</div>

I will try and switch a small project to see if the issue is resolved in 1.9. If it is not, would you like me to open a jira?

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 26, 2013, 4:33pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/12 "2013-11-26T16:33:00Z")

</div>

If you don’t find it in JIRA, let me know, and I’ll open an issue.

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 26, 2013, 5:01pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/13 "2013-11-26T17:01:00Z")

</div>

I have verified that this is still broken in gradle 1.9.

I did a quick search in the jira project, but did not see this exact problem. Would you like me to enter a new jira?

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [November 26, 2013, 5:05pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/14 "2013-11-26T17:05:00Z")

</div>

The right place to report issues is here; only Gradle devs can promote them to JIRA. The issue you are describing was already promoted as GRADLE-2711.

---

<div class="post-metadata">

### Author: ![Jonathan\_Baker](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonathan_baker/32/319_2.png) [@Jonathan\_Baker](https://discuss.gradle.org/u/Jonathan_Baker)
#### Post date: [November 26, 2013, 5:22pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/15 "2013-11-26T17:22:00Z")

</div>

Cool, thank you for your patience.

---

<div class="post-metadata">

### Author: ![Stanford\_Guillory](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@Stanford\_Guillory](https://discuss.gradle.org/u/Stanford_Guillory)
#### Post date: [May 6, 2014, 3:03pm UTC](https://discuss.gradle.org/t/uploadarchives-ignoring-users-maven-settings/7539/16 "2014-05-06T15:03:00Z")

</div>

I agree with what you are saying here, but I am seeing the exact opposite behavior in Gradle 1.10 through 1.12. I have configured a repository in the uploadArchives task of my build.gradle file but the repository in the Maven settings.xml is being used instead. This seems like a bug to me.
