How to Use Snapshot of Library in Maven Project
We could not keep waiting for the next release of the Sonatype library to happen, so we learned a workaround for that.
Join the DZone community and get the full member experience.
Join For FreeSo, for today I bring you a real-time problem which I and my teammates faced. One of my teammates contributed to an open-source library, Scanamo, and the contribution which was being made was very crucial for the next release of our project. We could not keep waiting for the next release of the library to happen, so we learned a workaround for that. That is, using a snapshot of a library dependency. Fortunately, the library I'm are talking about, releases its snapshot version after small updates to the code. So, let's find out what was the workaround I learned,
1. Adding OSS Sonatype Repository To Maven Project To Use Snapshot of the Library
Firstly, we need to enable our project to look for a snapshot version of a library that we want to add to our project. To do that, add below snippet to pom.xml
<repositories>
<repository>
<id>oss-sonatype</id>
<name>oss-sonatype</name>
<url> https://oss.sonatype.org/content/repositories/snapshots/ </url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
This way, we have provided a repository to our project to look for library snapshot with the mentioned version.
2. Now, Just Add the Dependency With Relevant Snapshot Version
You can search for it here.
xxxxxxxxxx
<dependency>
<groupId>org.scanamo</groupId>
<artifactId> scanamo-alpakka_2.12 </artifactId>
<version>1.0.0-M10+18-8387f9ae-SNAPSHOT/</version>
</dependency>
Ah...Voila, now just refresh/rebuild your project and you will find the snapshot in the external libraries.
Opinions expressed by DZone contributors are their own.
Comments