Cannot resolve the SNAPSHOT dependency deployed via Maven deploy-file


#1

Hello,

I have a problem with Nexus dependency resolution. Nexus version is 3.13.

I have a project “A” which is used as a library across different projects. I am trying to create - SNAPSHOT versions to be used for DEV environment - RELEASE versions will be used after code freeze and to deploy other environments.

I deploy the project “A” as a snapshot to a maven hosted repository(jar file, snapshot repository). I tried “deploy plugin” 3.0.0-M1 and 2.8.2 with uniqueVersion=false. But every time a timestamp is added to the artefacts in Nexus(jar and POM files). I have no issue with timestamp but I cannot resolve the project from other projects.

When I use “LATEST” as the version then the following is the response

“The POM for filename:jar:X.Y.Z-SNAPSHOT is missing, no dependency information available”. The POM and JAR is in the repository, but the POM file contains the timestamp suffix as well.

I don’t have any problems with release repository for the same project.

Any idea?


#2

The uniqueVersion=false flag does not work with Maven 3 (this is intentional). You’ll always get timestamped versions via Maven snapshot deploy. Make sure your settings.xml file is configured to use a nexus group repository, that the group repository contains the hosted snapshot repository, and that snapshots are enabled in the settings.xml file:

https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ConfiguringApacheMaven


#3

I tried uniqueVersion=false flag for maven-deploy plugin 2.7 just to give it a try.

I tried all the steps in the link already. I can see my SNAPSHOTS in the Nexus and they are already added in maven-public which is a group and contains the necessary members.

I tried to use both maven deploy and nexus-staging-maven-plugin. The result is the same. I can see the artefacts in Nexus but cannot reference them with their version. One note is that when I try the following I got a response like

“The POM for my-libraryl:jar:20181003-9450157-SNAPSHOT is missing, no dependency information available”. There is a POM but it is already suffixed with timestamp.

<dependency>
<groupId>some groupIDs</groupId>
<artifactId>my-library</artifactId>
<version>LATEST</version>

</dependency>


#4

Don’t use LATEST as a version. Use the snapshot base version, e.g. 1.2.3-SNAPSHOT. Also make sure snapshots are enabled in the settings.xml repository definitions:

      <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>

#5

This is the part from settings.xml. It is exactly as you posted.

<profile>
  <repositories>
    <repository>
      <id>central</id>
      <url>http://central</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

This is how it looks after deploy in Nexus

When I try to get the dependency in another project, the result is “Could not find artifact”. I don’t have any problem with “Releases”, only problem is SNAPSHOTs.

<dependency>
<groupId>my group ID</groupId>
<artifactId>scs-beschluss-datamodel</artifactId>
<version>0.0.30-SNAPSHOT</version>

</dependency>


#6

Maven will cache previous download failures for 24 hours. Try adding the “-U” flag to force it to update this local cache. If this does not work pay particular attention to the URL’s maven is asking for the files from, make sure they look correct.


#7

I forced it as well with -U, didn’t work. The URLs are correct at the end , I can get the dependencies in “Release” repositories.


#8

I found the issue and it is related to the settings.xml. Inside the profile tag, I added another element called “id”.

<profiles>
    <profile>
         <id>nexus</id>
         .....

#9

The fundamental premise of the approach is wrong and going to lead to most of your troubles. Deploy-file is meant to allow you to push a release artifact (from a maven perspective) to the repository that presumably wasn’t built with maven.

You should never use this to deploy a snapshot, if you have an actual snapshot then this means you’re building with Maven and you should just do a mvn deploy and let the maven lifecycle take care of producing all the proper metadata for resolution.

Anything else is swimming against the current.