mavenmigrationazure-artifacts

How to migrate Maven packages from Nexus to Azure Artifacts


I'm trying to migrate my build packages from our on-premise Nexus Repository Manager to Azure Artifacts. I have found this Microsoft link explaining how to do it for NuGet (a .NET package manager) with a Powershell script, but there is no such tool for Maven.

I was thinking about retrieving all the build files with a "maven clean compile" and then pointing my pom.xml file to Azure Artifacts and then somehow push them. However, the amount of packages run into the 100k and there are many applications using it. So this feels like a very clunky way of going about it that will take a lot of effort and a lot of room for error.

Does anyone have any advice for me?


Solution

  • It turns out my issue mainly caused by my limited understanding of Artifact repos and the dependency chain of the project. Apparently it Artifact repos do caching of all the upstream repos so that's why there where 100k files in there. In the end there were only two company specific dependencies that needed moving.

    I accomplished the migration following way (applicable for to all Maven migrations):

    Clone the highest dependencies in the chain. (probably contains a name with commons or parent)

    Add Azure Artifacts configuration to ${USER_HOME}/.m2/settings.xml and pom.xml as described here: https://robeco.visualstudio.com/Delivery%20Integration%20Services/_packaging?_a=connect&feed=Maven-feed

    Retrieve dependencies from current repo

    mvn install
    mvn package
    

    Create a release version (without -SNAPSHOT behind it) and push it to Azure Artifacts (else you'll get a Can't release project due to non released dependencies error)

    mvn release:clean
    mvn release:prepare
    mvn release:perform
    

    Now you have something like a robeco-common-version1.0.16 build. Now deploy it to Azure Artifacts

    mvn deploy
    

    You should see something like Uploading to Maven-feed: https://robeco.pkgs.visualstudio.com/....

    Do the same steps for all subsequent company specific dependencies.