I'm trying to use Ant to upload to a maven (nexus) repo, however am getting errrors. Please see my build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:resolver="antlib:org.apache.maven.resolver.ant">
<path id="maven-ant-tasks.classpath" path="path/to/lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
<fileset dir="path/to/lib/" includes="maven-resolver-ant-tasks-1.4.0-uber.jar"/>
</classpath>
</taskdef>
<property name="nexus_web" value="https://nexus.location.com/repository/location/item" />
<resolver:authentication username="login-username" password="PASSWORD" id="auth"/>
<resolver:remoterepo id="server" url="${nexus_web}">
<resolver:releases enabled="true" checksums="warn"/>
<resolver:authentication refid="auth"/>
</resolver:remoterepo>
<resolver:remoterepos id="all">
<resolver:remoterepo refid="server"/>
</resolver:remoterepos>
<resolver:artifacts id="producedArtifacts">
<resolver:artifact file="path/to/item/build/item/build/item-21-08-8.tar"/>
</resolver:artifacts>
<resolver:pom file="nexus-upload-pom.xml" id="pom"/>
<target name="deploy">
<resolver:deploy artifactsref="producedArtifacts">
<resolver:remoterepo refid="server"/>
</resolver:deploy>
</target>
</project>
and my nexus-upload-pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>testing</groupId>
<artifactId>item</artifactId>
<version>21-08-2</version>
<name>item-name</name>
</project>
When I run this via 'ant deploy'
I get the following error:
deploy:
[resolver:deploy] Using default POM (testing:item:21-08-2)
[resolver:deploy] Uploading https://nexus.location.com/repository/testing-maven/item/testing/item/21-08-2/item-21-08-2.pom
[resolver:deploy] Uploaded https://nexus.location.com/repository/testing-maven/item/testing/item/21-08-2/item-21-08-2.pom (189 B at 0.7 KB/sec)
[resolver:deploy] Uploading https://nexus.location.com/repository/testing-maven/item/testing/item/21-08-2/item-21-08-2.tar
[resolver:deploy] Uploaded https://nexus.location.com/repository/testing-maven/item/testing/item/21-08-2/item-21-08-2.tar (347500 KB at 23231.7 KB/sec)
[resolver:deploy] Downloading https://nexus.location.com/repository/testing-maven/item/testing/item/maven-metadata.xml
[resolver:deploy] Uploading https://nexus.location.com/repository/testing-maven/item/testing/item/maven-metadata.xml
BUILD FAILED
path/to/item/build/nexus-upload.xml:34: Could not deploy artifacts: Failed to deploy metadata: Could not transfer metadata testing:item/maven-metadata.xml from/to dug (https://nexus.location.com/repository/testing-maven/item): status code: 400, reason phrase: Invalid maven-metadata.xml GAV testing, item, null does not match request path item/testing/item/maven-metadata.xml (400)
Total time: 16 seconds
As a kicker: there is no maven-metadata.xml on the sever at that location. I'm trying to work out what is wrong with that section of the upload, is it an issue with what I've got in either of my configuration files (the null is a bit of a giveaway) or am I missing something entirely?
CodePudding user response:
Some reading on the intrawebs has led me to this trail:
https://issues.sonatype.org/browse/NEXUS-19943 https://issues.sonatype.org/browse/NEXUS-26419
With the workaround being:
nexus.maven.metadata.validation.enabled=false
Adding this property to data-dir/etc/nexus.properties And then resetting nexus.