Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven can't resolve a SNAPSHOT dependency

I just deployed a Maven multi module project to Nexus with a SNAPSHOT version.

The deployed artifacts are present in the Nexus snapshot repository and I can download them directly through the Nexus interface.

However, when I add those artifacts as dependencies to another project, Maven is not able to resolve them.

I get the following error:

Downloading: http://<nexus-url>/nexus/content/groups/public/<groupId>/<artifactId>/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<nexus-url>/nexus/content/groups/public/<groupId>/<artifactId>/1.0-SNAPSHOT/maven-metadata.xml (835 B at 15.1 KB/sec)
Downloading: http://<nexus-url>/nexus/content/groups/public/<groupId>/<artifactId>/1.0-SNAPSHOT/<artifactId>-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.056s
[INFO] Finished at: Tue Mar 25 17:49:23 IST 2014
[INFO] Final Memory: 11M/234M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project my-project: Co
uld not resolve dependencies for project com.example:my-project:jar:2.0-SNAPSHOT: Could not find artifact <groupId>:<artifactId>:jar:1.0-SNAPSHOT in nexus (http://<nexus-url>/nexus/content/groups/public) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException

Note that Maven doesn't try to download the file maven-metadata.xml.

Thanks, Mickael


EDIT: Maven DOES download the file maven-metadata.xml. Using -U doesn't help.

It seems that Maven tries to download the artifact without translating SNAPSHOT to an appropriate to timestamp.

like image 349
manash Avatar asked Mar 25 '14 15:03

manash


People also ask

What is snapshot dependency in Maven?

A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.

What is groupId in Maven dependency?

groupId uniquely identifies your project across all projects. A group ID should follow Java's package name rules. This means it starts with a reversed domain name you control. For example, org.apache.maven , org.apache.commons.

How often maven should check for a newer snapshot artifact in the remote repository?

Artifacts with a newer timestamp take precedence no matter where they come from. With the default settings "remote timestamps" are checked only once every 24 hrs.

What is snapshot artifact?

Snapshot artifacts are artifacts generated during the development of a software project. A Snapshot artifact has both a version number such as “1.3.


1 Answers

Perhaps you need to run the build with -U, which means "force update of dependencies even if you already have resolved them in the last 24 hours".

Without it, maven will only attempt to resolve those snapshots dependencies once a day, which you might have already done, and so you're getting a "cached" response about it not being there.

like image 53
chad Avatar answered Oct 18 '22 16:10

chad