Maven deployer uses the wrong repository when mirror is configured in Maven settings

I’ve got a really simplified gradle build (1 java file) that I’m using to test the ‘uploadArchives’ task. It’s basically the following:

apply plugin: 'java'
apply plugin: 'maven'
repositories { maven { url "http://someserver/public" } }
uploadArchives {
    repositories {
        mavenDeployer { repository(url: "http://someserver/releases") }

When I run ‘gradle uploadArchives’, the upload url used is the ‘public’ one NOT the ‘releases’ one specified in ‘mavenDeployer’. When I run this as a different user with no environment/cache/settings, it works as expected. I therefore surmise that there’s something in my specific environment that is causing gradle to not honor the setting (which I see as fundamentally flawed, but that’s just me). Is there a way to get gradle to tell me where it’s getting the incorrect repository reference? I’ve blown away my ~/.gradle and $project/.gradle directories, but to no avail; I’ve run gradle with the ‘-p’ and ‘-g’ options also to no avail. I actively use Ant, Maven and Eclipse on a Linux platform – could these be affecting things? Thanks for any input.

Try running gradle with --debug and see if it provides you/us with some clues.

No really helpful messages like ‘using repository url from xyz as maven upload url’ but… after poring through the copious output I found a line stating that it was ‘Loading Maven settings file: …’ and that file had the ‘public’ url listed as a mirror (replaced angle brackets with square ones):


So I guessed that somehow this value was being used in place of my setting. The only reference to that directory was in my M2_HOME environment variable. I unset my M2_HOME environment variable and voila, it all worked.

I still don’t know WHY gradle ignored my stated repository, but, based on the amount of time spent on this issue, I humbly request that there be a mod added to gradle to let the user choose to have the explicit maven repository listed in the .gradle file override any environment settings.

Thanks for looking into this. Certainly looks like a bug to me, or at least something that should be easier to diagnose.

We’re using the native Maven Ant tasks under the covers, so without looking into it further I’m guessing that the mapping is being done in that layer.

I had the same problem. Unsetting the M2_HOME worked.

I’ve made an unexpected observation. I had my settings.xml properly configured, but after disabeling entry by entry, gradle still used the public nexus repo for artifacts. So I doublechecked the logs and found out that I had an second settings.xml in my /conf of maven with some badly configured content. and gradle seems to be using it anyway.

Exactly the same problem for me. Second one (first one was in user’s home folder) with wrong mirror settings have been in maven’s program directory.