How to clean Maven snapshots deployed on the server? - maven

On the snapshot server, Maven keeps all the generated snapshots. I want to clean all but the latest ones that are deployed on the server.
How can I tell Maven to only keep the N latest snapshot versions and to remove the rest?

I believe this is not controlled by Maven. Instead, it is more to do with the repository manager.
For example, in Nexus, you can setup scheduled task to remove snapshots from hosted repositories.

The best is to use a Repository Manager like Artifactory, Nexus or Archiva which have tasks for such purposes or in case of releases the according SNAPSHOT's will automatically be deleted.

Related

How can I specify in pom.xml a dependency to a project in a repository?

I have a project working on my Spring Tool Suite. Also, I have a project in an innersource repository that I want to use in my project of STS.
For that, I need to specify the dependency in the pom.xml file of my project to establish the dependency with this remote project. But I don't know how to specify this dependency and what information about the remote project I need to put in the pom and where I can find it.
At least I need what information I should write in the pom and I will look wherever for that information.
Thank you so much for your help!
A best practice is to use your own / company wide Maven Repository Manager such as Nexus and define a single repository group.
Use this Maven Repository Manager to share closed source artifacts (hosted repository) and to access Open Source repository such as Maven Central (proxy repository).

Adding external private jar to Openshift Application

I want to deploy a Java & Maven micro services application on OpenShift however I have one small issue. These micro services are dependent on a commons project
containing some common components.
How can i add the jar of the commons project ( private jar, not on public repo) to the class path of the micro services about to be deployed on Openshift?
When building the application locally we used a maven plugin which would move the jar of the commons project into the local maven repository, from where it was easily referenced via a dependency tag in the pom file.
Here are some approaches that I thought about:
use an internal maven repository
create a folder on the root of the project and use it as a local maven repo, declaring it via repository tags in the pom files
deploy a nexus repository on the Openshift cluster
The first approach is not viable since our company does not have an internal maven repository.
We also tried the third approach , however we did not manage to deploy a running nexus repo on Openshift.
The only viable solution left is the second one, however I am a little bit reluctant to implement it since it does seem to be the standard way of doing things. What approach would you reccommend?
create a folder on the root of the project and use it as a local maven repo, declaring it via repository tags in the pom files
This won't be a good approach TBH.
My recommendation would be using a nexus/jfrog etc. repo OpenShift internal or externally (a more recommended approach for enterprises) and get the commons and other libraries from that repo via defining maven dependencies.

how to use command line to deploy a war to gcp

I know we can use the maven plugin to deploy the application to GCP. E.G
mvn appengine:deploy
But for certain reason, I would like to deploy the application not from the source code, but from artifacts repository (like Nexus).
What I want to do is to fetch the war from Nexus and use some command line to deploy the war to GCP. Anyone know how to?
I didn't find a way to do it but if you are interested in such functionality, you can use Cloud Source Repositories, which provides private Git repositories hosted on GCP.
You can use them to deploy in App Engine and even automate the process.
If you need to specifically use Nexus, you could file a feature request for App Engine.

Migrate maven artifacts into Cloudbees repository

Has anyone ever migrated an existing maven repository into Cloudbees repositories?
Currently, I have a self-hosted Sonatype Nexus instance with three custom repositories (snapshots, releases, and 3rd-party libraries not hosted in Maven). I have an existing Cloudbees CI environment, and I'm looking at migrating my maven storage as well.
If anyone has any helpful hints, tips, or an existing migration guide, please point me in the right direction.
Thanks in advance.
The simplest way would be to zip/tar.gz up your existing repository and upload it to the DAV repository in question.
Submit a support request and it can be unpacked on the server (DAV is quite slow for moving lots of files)

How to submit a new maven plugin

Say I have developed a plugin which I don't believe has been developed before. Can I submit this plugin to the maven community or does such a facility exist ? Is there a process required for this ?
If you mean submit your artifact to The Central Repository, here is the complete user guide:
Sonatype OSS Maven Repository Usage Guide
1. Introduction
Sonatype OSSRH (OSS Repository Hosting Service) uses Nexus to provide Maven repository hosting service for open source projects: https://oss.sonatype.org/. You can deploy snapshots, stage releases, and promote your releases so they will be synced to The Central Repository. All you need to do is to sign up a Sonatype JIRA account, create a JIRA ticket and make some POM/settings configuration. This document will guide you step by step for the details.
... ...

Resources