Maven ant tasks deploying to public nexus repository instead of the url specified
NickName:Noremac Ask DateTime:2012-12-12T01:48:47

Maven ant tasks deploying to public nexus repository instead of the url specified

I am stumped. I am using ant and maven-ant-tasks to build and deploy snapshot artifacts (non-maven) to a remote nexus repository. The build process specifies the url of the repository. This is the ant target that is run:

<target name="shared_resources_war_deploy" depends="shared_resources_war">
    <artifact:pom id="sharedResourcesPom" file="${resourcesdir}/shared-resources-pom.xml" />
    <echo message="**************************${nexus.url}*************************" />
    <artifact:deploy file="${resourcesdir}/shared-resources.war">
        <remoteRepository url="${nexus.url}">
            <authentication username="${nexusUserName}" password="${nexusUserPassword}" /> 
        </remoteRepository>
        <pom refid="sharedResourcesPom"/>
    </artifact:deploy>
</target>

And results in:

shared_resources_war_deploy:
     [echo] **************************http://${nexusIP}:8081/nexus/content/repositories/snapshots*************************
[artifact:deploy] Deploying to http://${nexusIP}:8081/nexus/content/groups/public
[artifact:deploy] [INFO] Retrieving previous build number from nexus
[artifact:deploy] Uploading: com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172831-28.war to repository nexus at http://${nexusIP}:8081/nexus/content/groups/public
[artifact:deploy] Transferring 2K from nexus
[artifact:deploy] An error has occurred while processing the Maven artifact tasks.
[artifact:deploy]  Diagnosis:
[artifact:deploy]
[artifact:deploy] Error deploying artifact 'com.xactsites:shared-resources:war': Error deploying artifact: Failed to transfer file: http://${nexusIP}:8081/nexus/content/groups/public/com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172831-28.war. Return code is: 400
[artifact:deploy]

BUILD FAILED
C:\Users\11_1_15\build.xml:561: The following error occurred while executing this line:
C:\Users\11_1_15\build.xml:551: Error deploying artifact 'com.xactsites:shared-resources:war': Error deploying artifact: Failed to transfer file: http://${nexusIP}:8081/nexus/content/groups/public/com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172831-28.war. Return code is: 400

For some reason beyond my understanding, maven is trying to deploy to the public repository (not allowed by nexus) instead of the snapshot repository specified (note the nexus.url variable). No where in the build file is the public URL being specified.

To make things more curious, on one machine the same build script is successfully deploying the same artifact with this result:

shared_resources_war_deploy:
     [echo] **************************http://${nexusIP}:8081/nexus/content/repositories/snapshots*************************
[artifact:deploy] Deploying to http://${nexusIP}:8081/nexus/content/repositories/snapshots
[artifact:deploy] [INFO] Retrieving previous build number from remote
[artifact:deploy] Uploading: com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172031-27.war to repository remote at http://${nexusIP}:8081/nexus/content/repositories/snapshots
[artifact:deploy] Transferring 2K from remote
[artifact:deploy] Uploaded 2K
[artifact:deploy] [INFO] Retrieving previous metadata from remote
[artifact:deploy] [INFO] Uploading repository metadata for: 'snapshot com.xactsites:shared-resources:13.1.19-SNAPSHOT'
[artifact:deploy] [INFO] Uploading project information for shared-resources 13.1.19-20121211.172031-27
[artifact:deploy] [INFO] Retrieving previous metadata from remote
[artifact:deploy] [INFO] Uploading repository metadata for: 'artifact com.xactsites:shared-resources'

BUILD SUCCESSFUL

where the URL specified is actually used. In comparing the two machines, both ant (version 1.8.1) and the maven-ant-tasks (2.1.3) are the same version. The nexus logs suggest that the incoming request is different between the two (where one specifies the snapshot repository and the other the public repository) so I want to pin this error on Maven. However, I haven't been able to determine any differences that would cause this.

What's going on?!

UPDATE:

After sniffing the packets we found that the request from maven was being sent to: /nexus/content/groups/public/com/xactsites/shared-resources/13.1.19.2/shared-resources-13.1.19.2.war HTTP/1.1, confirming that maven is changing the URL before sending the request. So, any efforts to solve this can focus on maven (not nexus).

Copyright Notice:Content Author:「Noremac」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/13825701/maven-ant-tasks-deploying-to-public-nexus-repository-instead-of-the-url-specifie

Answers
Noremac 2012-12-13T00:15:18

After some painful research and a fluke typo by a coworker opened up a new path to explore we found the cause. Essentially, if the M2/M2_HOME environment variables are set as specified here, then the remote repository url is overwritten with that from our settings.xml file and uses the mirror that is set up for nexus (hence using the wrong, read-only URL for deployment).\n\nThis appears to be an issue both within the pom using the <distributionManagement> element as well as using the <remoteRepository> element within the ant file. There is already a bug filed for this. \n\nResolutions:\n\nWe narrowed it down that having the <mirrorOf>*</mirrorOf> set where the '*' causes this issue. Replacing the * with specific repositories (such as 'central') resolves this issue. \n\nJust as well, not setting the M2 environment variables fixes this as well, since it can't get to the settings.xml file to get the URL. Of course, you wouldn't want to go this approach if you rely on some other things in your settings.xml to be present when running the deploy.\n\nuggh, that was a painful bug to track down.",


More about “Maven ant tasks deploying to public nexus repository instead of the url specified” related questions

Maven ant tasks deploying to public nexus repository instead of the url specified

I am stumped. I am using ant and maven-ant-tasks to build and deploy snapshot artifacts (non-maven) to a remote nexus repository. The build process specifies the url of the repository. This is the ...

Show Detail

Deploying jar to Nexus using Maven Ant Task

I am going completely mad here. I am simply trying to upload a jar to a Nexus server using Maven Ant Task but when I run the build.xml file using ant I get the following error Deploying to http://...

Show Detail

Deploying artifacts to nexus failed because of super-pom

I'm trying to deploy artifacts in nexus using ant task. It reads pom.xml from the workspace during deploy. I had not mentioned super-pom anywhere but still it tries to deploy that. Anybody knows wh...

Show Detail

How to deploy jar to nexus using Maven ant task

I am new to maven. How to deploy jar from build.xml to nexus repository. This document is referring to create a pom.xml. http://maven.apache.org/ant-tasks/examples/install-deploy.html What do I ne...

Show Detail

Deploying Ant-generated jar to Nexus using maven-deploy-plugin

I have a multi-module project with war and ear module. In war's pom I'm generating jar using maven-antrun-plugin. Now I'm trying to deploy that jar to my Nexus using maven-deploy-plugin. Here's m...

Show Detail

Using Nexus repository instead of public Maven in Idea Intellij

How can I force Idea Intellij to download from Nexus repository instead of Maven Public repo? Where can I configure that in Idea properties? It's not defined in pom.xml files and I'd prefer not to.

Show Detail

nexus upload with maven-ant-resolver error invalid metadata doesn't match

I'm trying to use Ant to upload to a maven (nexus) repo, however am getting errrors. Please see my build.xml &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns:resol...

Show Detail

maven setup another repository for certain dependency

I have Maven2 project. All dependencies except one are downloaded from public repository http://repo.maven.apache.org/maven2/. But I have 1 dependency which I need to download from internal compa...

Show Detail

Issues with deploying artifacts in Nexus repository

We are in the process of deploying artifacts into the nexus repository and facing issues. Issue we are facing issues with Nexus integration. We have included &lt;distributionManagement&gt; tag i...

Show Detail

Integrate maven with nexus repository

I have installed nexus repository 3.12 in a server machine and apache-maven 3.3.9 in my local computer. I want to configure maven to access repository. I created a repository in nexus as maven_ub ...

Show Detail