how to deploy my artifact on to my nexus?

2019-02-08 02:23发布

问题:

I am using nexus open source as my repository manager for Maven 3.0.3

Maven is able to create artifact *.jar.

Now, I would like to know how I can push the generated artifact *.jar to the nexus repo manager, so that other dependent modules can pull from it.

I referred to this guide.

In settings.xml, I have

    <server>     
            <id>nexus-site</id>
            <username>admin</username>
            <password>xxxx</password>
    </server>

It fails.

How can invoke my deployment from mvn command or how to deploy my artifact on to my nexus?

回答1:

Just try

   mvn deploy

that will deploy your artifact to the nexus repo manager.

Have you configured the distributionManagement section ?



回答2:

And if you want to add it to the snapshot repository, you need the following configuration inside your pom.xml

<distributionManagement>
    <repository>
         <id>internal.repo</id>
         <name>MyCo Internal Repository</name>
         <url>http://Nexus url</url>
    </repository>
    <snapshotRepository>
         <id>Snapshot.repo</id>
         <name>Your Snapshot Repository</name>
         <url>http://Nexus url</url>
    </snapshotRepository>
</distributionManagement>


回答3:

There are two ways to do so.

The first is do it via Nexus web interface, just upload the artifact with necessary project information (groupId, artifactId, version)

The other is using mvn deploy. You need to set distributionManagement for repository to upload to, and user to authenticate as.

The second approach is strongly recommended if you are going it do deployment regularly. It is automated, and you can leverage on other Maven commands like mvn release



回答4:

Repository element should also be specified. Snippet:pom.xml

<distributionManagement>
    <repository>
      <id>internal.repo</id>
      <name>MyCo Internal Repository</name>
      <url>http://Nexus url</url>
    </repository>
  </distributionManagement>