0

I am trying to upload artifacts to my "maven-central" repository in Nexus. I am using the command:

curl -v --user admin:admin123 --upload-file /path/myjar.jar  http://nexus-nexus3.apps.lab.ca/repository/maven-central/com/tp/mycompany/1.0/myjar.jar

I am getting the error:

User-Agent: curl/7.54.0 Accept: / Content-Length: 560414 Expect: 100-continue HTTP/1.1 400 Invalid path for a Maven 2 repository Date: Fri, 09 Mar 2018 15:54:10 GMT Server: Nexus/3.9.0-01 (OSS)

I've tried multiple curl commands from the sonatype docs but to no avail. My question is, is this even possible? The UI only gives me the option to upload to maven-releases and nuget-hosted. How do I get around this?

redhatter
  • 63
  • 2
  • 4
  • 1
    I assume that by default the repository you are calling `maven-central` is a proxy repository which is mirroring Maven Central. And it does not make sense to upload into a proxy repository. You should upload your artifacts to a other repository for example maven-releases which is a so called `hosted` repository... – khmarbaise Mar 09 '18 at 16:08
  • @khmarbaise reason I want to upload to maven-central is because during the maven build some artifacts are downloaded from proxy repo maven-central and some are custom. Thats why i wanted to just place everything into one place. – redhatter Mar 09 '18 at 16:22
  • 1
    You can't upload artifacts to a proxy repository that's written in the Nexus docs. Create a separate hosted repository in Nexus (by default there are already some defined 3rd party for example) and upload them into that... – khmarbaise Mar 09 '18 at 17:46
  • Yes. But when I give my application the URL (/repository/maven-central) for the maven mirror. it looks for like custom jars under that specific path. – redhatter Mar 09 '18 at 23:05
  • 1
    You need to handle your Nexus configuration correct which you obviously didn't. You have repository group which combines the different repositories to a logical one which you use to access (consume) artifacts. – khmarbaise Mar 10 '18 at 15:49

2 Answers2

1

I am not sure if you really want to upload a proprietary jars to the open world through maven-central.

It is very common to specify and use a combination of maven-central and company specific repository hosting proprietary jars. You should be careful about the impact of this.

Coming to uploading an artifact on maven-central...

To upload your artifacts into central-maven, there are pre-requisite given here

Why Do We Have Requirements?

In order to ensure a minimum level of quality of the components available in the Central Repository, we have established a number of requirements your deployment components have to meet. This allows your users to find all the relevant details about the components from the metadata provided in the Central Repository.

Some of the points taken:

  1. Supply Javadoc and Sources
  2. Sign Files with GPG/PGP
  3. Project Name, Description and URL
  4. License Information
  5. Developer Information
  6. SCM Information

Complete Example POM The following complete example shows the XML header and required elements of project and modelVersion as well as example elements and content.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.simpligility.training</groupId>
  <artifactId>ossrh-demo</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>

  <name>ossrh-demo</name>
  <description>A demo for deployment to the Central Repository via OSSRH</description>
  <url>http://github.com/simpligility/ossrh-demo</url>

  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Manfred Moser</name>
      <email>manfred@sonatype.com</email>
      <organization>Sonatype</organization>
      <organizationUrl>http://www.sonatype.com</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/simpligility/ossrh-demo.git</connection>
    <developerConnection>scm:git:ssh://github.com:simpligility/ossrh-demo.git</developerConnection>
    <url>http://github.com/simpligility/ossrh-demo/tree/master</url>
   </scm>

...

</project>
Community
  • 1
  • 1
Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53
  • 1
    you misunderstood my question. I am trying to upload my artifact to maven-central repository in my custom Nexus. – redhatter Mar 09 '18 at 23:07
1

I assume that by default the repository you are calling maven-central is a proxy repository which is mirroring Maven Central. And it does not make sense to upload into a proxy repository. You should upload your artifacts to a other repository for example maven-releases which is a so called hosted repository...

You can't upload artifacts to a proxy repository that's written in the Nexus docs. Create a separate hosted repository in Nexus (by default there are already some defined 3rd party for example) and upload them into that...

You need to handle your Nexus configuration correct which you obviously didn't. You have repository group which combines the different repositories to a logical one which you use to access (consume) artifacts.

To correctly access the nexus group you should have a settings which looks like the following. The given URL is the URL of the repository group which is configured in Nexus to consume the artifacts.

The distributionManagement in Maven should be configured to use two separate repos whereas one is the release repository and the other one the SNAPSHOT repository.

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>
khmarbaise
  • 92,914
  • 28
  • 189
  • 235