Importing a snapshot version of a dependency into Maven repository - maven

I am having trouble importing dependencies for my Grails project into the company Nexus repository. The Grails plugin I would like to use is events-push (https://github.com/smaldini/grails-events-push). The latest released version of the plugin is 1.0.M7. It uses a very old version of Atmosphere library. The GutHub repository contains a more up-to-date version of events-push plugin, 1.0.0.BUILD-SNAPSHOT. I built the Grails plugin from the local clone of the repository and got it to work in my dev environment.
To deploy it on the intranet (in the production environment) I need to import all the plugin dependencies into the company Nexus repository. This is where I run into trouble. The project depends on a SNAPSHOT version of events-push plugin, which in turn depends on SNAPSHOT version of other Grails plugins and Java libraries (according to dependency report).
Nexus supports two types of repositories, Release and Snapshot. I can add artifacts to a Release repository (through the browser UI or in a batch mode using curl), but the artifact must not be a snapshot. I can change the repository to be a Snapshot repository, but then I lose the ability to add artifact to it through the browser or curl command.
How do I make these SNAPSHOT artifacts available to the Grails project through Maven?

Change them to a release version and deploy them to the release repository.

Related

Apache Maven - Downgrading to previous snapshot dependency version is not working

I have a maven project which is injected with a SNAPSHOT dependency 2.0.0-SNAPSHOT which is there in artifactory. Now dependency project's pom version is updated to 2.0.1-SNAPSHOT and it was built (from a jenkins job) and this snapshot is also there in artifactory. So now artifactory has both the versions 2.0.0-SNAPSHOT and 2.0.1-SNAPSHOT and on local m2 repository also both versions are there.
Main project updated the SNAPSHOT dependency to 2.0.1-SNAPSHOT and it is able to see the new changes in 2.0.1-SNAPSHOT.
Now code changes are made in 2.0.0-SNAPSHOT and it was build and updated in artifactory but now when main project reverted back to 2.0.0-SNAPSHOT and built with -U (force update snapshots), it is not able to see new change done in 2.0.0-SNAPSHOT.
Can anyone suggest what could be wrong here ?

How do I prevent/delete old packages in gitlab maven repository

I have a java project built with gradle, that publishes to a GitLab maven repository. The gitlab maven documentation claims the following:
When you publish a package with the same name or version as an existing package,
the existing package is overwritten.
But this does not happen. The repository is filling up with old versions of the same package. How can I prevent this from happening and/or delete the old package versions in the repository?

Sbt do not update snapshot in Local maven repo

I have a project that is based on maven, and in which I am integrating some libraries that I am developing in Scala using SBT.
Currently the SBT project (in which I am developing the Lib) has a snapshot version.
While the snapshot jar is well updated in Ivy correctly it is not the case in Maven when I use PublishM2. I have to delete the previous one to get to have the new version that I would publish with PublishM2.
Is there a way to ensure that my PublishM2 update the local Maven repository properly (meaning with a new snapshot)?
Try the following sbt command:
sbt publishLocal publishM2
It should publish artifact into local Maven repository.

Releasing Open Source Artifacts to Nexus/Maven Central via Travis CI

I am actually searching for an solution on how to automatically release artifacts for my open source projects to maven central/our company nexus. I am using Maven/Gradle and Travis CI to build the artifacts.
Ideally i just change the version of my maven gradle module to an release version, travis recognizes that and deploys the resulting artifact to nexus/maven central.
Has anyone ideas how to do that without building releases locally.

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