Maven - grab latest upload of artifact - maven

I am trying to install the latest uploaded version of an artifact into my local repository.
For example:
I have a pulsar artifact that was initially uploaded on 12/10. I have recently added to the pulsar artifact and the blob has the updated date 12/17
Blob created Thu Dec 10 2020 10:57:13 GMT-0500 (Eastern Standard Time)
Blob updated Thu Dec 17 2020 12:16:30 GMT-0500 (Eastern Standard Time)
I would like to run a command that will grab the latest blobs for all artifacts in my maven repository in Nexus
Any help would be appreciated!
Thanks

Your local maven repository is throw-away. It's really just a cache of artifacts found in various remote repositories during previous builds.
If you have already built against version 1.0-SNAPSHOT of some artifact, Maven will find that artifact in your local repo, and not attempt to refresh it from the remote.
You can override this with the -U option (--update-snapshots). This will force Maven to re-download snapshot artifacts from your Nexus repo.
mvn -U clean install ...
HTH

Related

Maven site plugin not getting downloaded by intellij

I am building a spring project in Intellij community edition using maven.
I can see the maven-site-plugin folder created in my local m2 repository:
C:\Users\user_name\.m2\repository\org\apache\maven\plugins\maven-site-plugin
Inside, i see only one file named maven-site-plugin-3.3.pom.lastUpdated with the below content:
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Thu Oct 28 17:03:21 IST 2021
#default-central-https\://repo.maven.apache.org/maven2/.lastUpdated=1635420801486
https\://repo.maven.apache.org/maven2/.error=Could not transfer artifact org.apache.maven.plugins\:maven-site-plugin\:pom\:3.3 from/to central (https\://repo.maven.apache.org/maven2)\: Transfer failed for https\://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom
I took a fresh clone of the repo, did a clean build, also tried Intellij's cache invalidate and restart but to no avail..

promotion artifact repository from Snapshot to Release in Nexus

I am trying to promote artifact repository from Snapshot to Release in Nexus using Single artifact uploader in Jenkins . But this is not working for me.
Getting error like :
Could not resolve artifact: Could not find artifact
Snapshots.net.iin:snapshots:jar:0.0.1-SNAPSHOT in stagingrepo.
And I check from configuring the staging suite and got to know that Staging is part of the Nexus Repository Manager Pro.
I am using Nexus version - Nexus Repository Manager OSS 2.14.8-01.
I wanted to promote these snapshot artifacts to Release .So what's the best way to take this forward?

Archiva keeps showing deleted SNAPSHOT version artifacts in Browse

Our Archiva Repository (version 2.2.1) is configured with both a snapshot and a release repositories.
Snapshot repository is configured with 1 retention count, 1 day old, and to delete released snapshots.
And also, the repository-purge consumer is enabled.
The thing is I can see (in the server, in the snapshot repository folder) that the snapshot artifact files are being removed, but when i BROWSE the Archiva, it is still showing that snapshots, and the artifact (although with 0b size)
Versions of the artifact, all repositories
Artifacts for 0.0.1-SNAPSHOT
Is this behavior intended, or something in the purge process is failing and not removing this references?
Is it possible to adjust Archiva to delete this references (apart from manually delete the snapshot versions)?
This is a known issue that has been resolved in the unreleased version of 2.2.4 of Archiva. They will not release a 2.2.4 version, but are working on a 3.0.0 version that contains the fix for the bug. The date for the release has not been confirmed yet, but the fix is available : https://issues.apache.org/jira/browse/MRM-1958

why does maven check for updates when I have specified a version?

I have trouble understanding, why maven has to check for updates each time we build a project.
The pom has specific version mentioned for each dependency. Once those versions are downloaded to the local repo, then maven can use that local copy to build the project. So why does maven have to check for updates when we build the project each time other than just using the local copy?
a side question.
can a maven artifact be changed after releasing it to a repo under a specific version?
As per Maven, an artifact mainly can be of two types - a RELEASE one and a SNAPSHOT one. RELEASE dependency(eg: 1.0.1, 2.3.0 etc) of an artifact is a source of truth. Means 1.0.1 version of a jar (say test.jar) will always be the same always. We will release artifacts to remote repository, whenever the product matures or after a sequence of bug fixes.
On the other hand, a development is on going in a project, then specified its version number as SNAPSHOT(eg: 2.0-SNAPSHOT, 1.1-SNAPSHOT etc).
Say if we specified test-2.0-SNAPSHOT.jar as dependency in our project pom. If we look at the remote repository (Nexus, archiva etc), we can see that it is not saved as version 2.0-SNAPSHOT rather it will be saved artifact version as date-timestamp-buildnumber format, the date-timestamp at which the artifact was built and uploaded to remote repo. (eg: test-2.0-20150105082634.jar)
So when ever the development team does the fix for an issue on a daily basis the updated jar with date timestamp will be in uploaded to the remote repo. So it is necessary for maven to do look up for the latest date timestamp of SNAPSHOT artifacts. Maven does this by maven-metadata.xml file in the artifact directory in the repo.
Hope this clarifies your query. Let me know, if you need any clarifications

How maven decides to reference the latest artifact information

We use mvn deploy:deploy to deploy an artifact to repository manager and a developer could have done just mvn install for the same artifact, so the artifact is present under M2_HOME\.m2\repository
Will the maven runtime retrieve the artifact from the repository manager if it was updated recently than the local repository copy?
Note: We use a maven repository manager based on Apache Archiva.
The answer depends on whether you're talking about a snapshot or a release build.
Release builds have a version that doesn't end with "-SNAPSHOT", and they're final and immutable. Once installed to any repository, Maven will never update them. To your question, that means that if a dev installs a release build locally, it will never be updated from any remote repository.
Snapshot builds are always eligible to be updated from any repository. By default, Maven checks once per day for new snapshot versions, so if someone installs a snapshot locally, that snapshot will exist until Maven does its next check for snapshot updates. Then, if a newer version is in any remote repository it checks, the local one will be overwritten. You can force maven to update snapshot artifacts with the -U command line option.

Resources