The most common way to publish custom jar files as a Maven artifact in Azure DevOps

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

This is how you can publish your custom jar files as Maven artifacts and use them as dependencies in your projects:

  1. Make sure you have an Azure Artifact feed in Azure DevOps or create one if needed:Jaswant_Singh_1-1716177460592.png

     

  2. The command below will generate a Maven artifact. Please upload the pom.xml and jar file to the Azure DevOps Repo if you don't have one ready:                                                                                                    mvn -B archetype:generate -DarchetypeGroupId="org.apache.maven.archetypes" -DgroupId="MyGroup" -DartifactId="myFirstApp"                                                
  3. From the "Connect to feed" in Azure DevOps, select the Maven, and copy the <repository> information:

    Jaswant_Singh_2-1716178057270.png 
  4. Paste <repository> information from the last step, into your pom.xml file twice in <repositories> and <distributionManagement> tagsJaswant_Singh_1-1716178435579.png

     

  5. Create a pipeline in Azure DevOps: Jaswant_Singh_0-1716178289707.png 
  6. You can also use settings.xml file to authenticate the Azure DevOps Maven feed in your pipeline.                                                                                      
  7. Configure the feed permission in case of access related issues Jaswant_Singh_0-1716178860135.png
  8. Select the Packages from your feed in Azure DevOps, and copy the contents of the <dependency> element:Jaswant_Singh_0-1716179131108.png
  9. Paste the <dependency> element content copied in the last step, inside the <dependencies> element of your project pom.xml file.                               
  10. Run "mvn install" from the directory that contains your project pom.xml file.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.