0
votes

I have configured a simple maven freestyle project. I was able to successfully build the project but not deploy to Nexus. I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project eqs_utility: Failed to deploy artifacts: Could not find artifact com.companyName.eqs:eqs_utility:jar:1.0.1-20190529.191240-1 in nexus (https://nexus.companyRepo.com/repository/maven-snapshot/) -> [Help 1]

I have tried to change configurations to simplify the project but still nothing. Setting.xml changes.

EDITED I added the following to my POM.xml

    <distributionManagement>
        <repository>
            <uniqueVersion>false</uniqueVersion>
            <id>nexus</id>
            <name>Company Nexus Repository</name>
            <url>https://nexus.mycompany.com/repository/maven-release/</url>
            </repository>    
        <snapshotRepository>
            <uniqueVersion>true</uniqueVersion>
            <id>nexus</id>
            <name>Company Nexus Snapshots</name>
            <url>https://nexus.companyName.com/repository/maven-snapshot/</url>
        </snapshotRepository>
    </distributionManagement>

Then, updated my settings.xml with this

<server>
      <id>nexus</id>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
    </server>


    <!-- Another sample, using keys to authenticate. -->
    <server>
      <id>nexus</id>
      <username>NexusUser</username>
      <password>MyLongTokenValueHere</password>
    </server>
1
Is the repo a snapshot type (name maven-snapshot)? The jar version looks like a release type. I suspect a mismatch. I would have made this an answer if that info was provided.joedragons
@joedragons, Jar version appears to 1.0.1-SNAPSHOT: 1.0.1-20190529.191240-1 version 1.0.1, first upload -1, timestamp 20190529.191240Ian W
@jason-corbett, confused... You marked the response as correct but also edited the question to align with the guidance in the response. Is it working now or not? Same error?Ian W
Its working but we have a different problem now.Jason Corbett
@jason-corbett, perhaps then you could re-edit your question to reflect the original condition and indicate in the comments, or a more clear additional edit, there were also other issues. If a separate S/O question is posted, then a link may be of benefit too. As it stands right now, it's not clear to others how the "correct response" addresses the question.Ian W

1 Answers

1
votes

According to Apache Maven Deploy Plugin setup

You need a section:

  <distributionManagement>
    <repository>
      <id>internal.repo</id>
      <name>MyCo Internal Repository</name>
      <url>Host to Company Repository</url>
    </repository>
  </distributionManagement>

As you're using Nexus, you probably need a section in the pom that aligns with your nexus repositories (one for snapshots and one for release artifacts since you can't combine them in nexus):

<distributionManagement>
   <repository>
      <id>mavenrepository</id>
      <url>http://mavenrepository.companyName.com/nexus/content/repositories/m3</url>
   </repository>
   <snapshotRepository>
      <id>tmavenrepository</id>
      <url>http://mavenrepository.companyName.com/nexus/content/repositories/m3-snapshots</url>
   </snapshotRepository>
</distributionManagement>

Plus of course, in your local settings or other private location

    <server>
      <id>mavenrepository</id>
      <username>maven</username>
      <password>foobar</password>
    </server>

This is described by Sonatype and cleaner by others.