title | description | ms.service | ms.topic | ms.assetid | ms.date | monikerRange |
---|---|---|---|---|---|---|
Get started with Maven packages |
Learn how to publish and restore Maven packages with Azure Artifacts. |
azure-devops-artifacts |
quickstart |
C5112218-DA7E-4016-986D-2D0F70DAFA44 |
07/01/2024 |
<= azure-devops |
[!INCLUDE version-lt-eq-azure-devops]
Azure Artifacts enables developers to manage their dependencies from a single feed while providing control over package sharing. With Azure Artifacts feeds, you can publish and restore Maven packages, and set up upstream sources to consume packages from public registries like Maven Central, Google Maven Repository, Gradle Plugins, and JitPack. This article will guide you through setting up your Maven project, connecting to an Azure Artifacts feed, and publishing and restoring your Maven packages.
-
Create an Azure DevOps organization and a project if you haven't already.
-
Open a command prompt window and navigate to your project directory where your pom.xml file is located, and then run the following command to package your project. This command compiles your code, runs tests included, and packages your project into a distributable format (such as a JAR file).
mvn package
-
Run the following command from your project directory to publish your package to your feed:
mvn deploy
-
After successfully deploying your package, it will shortly be available in your feed.
:::image type="content" source="media/get-started-maven/maven-package-published-to-feed-contracted.png" alt-text="A screenshot that shows a Maven package deployed to a feed." lightbox="media/get-started-maven/maven-package-published-to-feed.png":::
Note
If your organization is using a firewall or a proxy server, make sure you allow Azure Artifacts Domain URLs and IP addresses.
-
Navigate to Artifacts in your Azure DevOps project, select your feed from the dropdown menu, and then select the package you wish to install.
-
Navigate to Overview > Maven, then copy the dependency snippet.
-
Open your pom.xml file and paste the snippet inside the
<dependencies>
tag. -
Run the following command from the directory where your pom.xml file is located to restore your packages:
mvn install