Get started with Maven packages and Azure Artifacts
TFS 2018
This quickstart will guide you through setting up your Maven project to connect to Azure Artifacts feeds and publish and download your Maven packages.
Prerequisites
- An Azure DevOps organization. Create an organization, if you don't have one already.
- Install Apache Maven.
- An Azure Artifacts feed. Create a feed if you don't have one already.
Set up authentication
Select Packages, and then select Connect to Feed.
Select Maven.
If this is the first time using Azure Artifacts with Maven, select Get the tools to download and install Maven.
Follow the instructions in the Project setup to set up your pom.xml and settings.xml files. If your settings.xml file is shared within your team, you can use Maven to encrypt your passwords.
Tip
If you are using Maven task, set the mavenAuthenticateFeed
argument to true to automatically authenticate with your Maven feed.
Publish artifacts
If you don't have a Maven package yet, you can create one by running the following command:
mvn -B archetype:generate -DarchetypeGroupId="org.apache.maven.archetypes" -DgroupId="MyGroup" -DartifactId="myFirstApp"
If you get the following error: You must specify a valid lifecycle phase or a goal (..), follow the steps below to add a goal to your configuration:
Right click on your project, select Run as > Maven Build. Enter package in the Goals text box, and then select Run.
Navigate to the path of your pom.xml file and run the following commands to build and deploy your Maven artifact:
mvn build mvn deploy
If you get the following error: Unknown lifecycle phase "build"(...) when you run mvn build
, you can use Eclipse IDE to build your maven project as follows:
Right click on your project.
Select Run as, and then select Maven Build....
Write package in the Goals text box.
Select Run.
If you want to publish a third-party artifact, you can use the deploy:deploy-file mojo. This can be used with or without a POM file to deploy your packages.
mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="MyFeedName" -Durl="MyFeedURL" -DgroupId="MyGroup" -DartifactId="myFirstApp" -Dversion="jarFileVersion" -Dfile="jarFileLocalPath"
Note
If your organization is using a firewall or a proxy server, make sure you allow Azure Artifacts Domain URLs and IP addresses.
Install artifacts
Select Packages, and then select the package you want to install and copy the
<dependency>
snippet.Open your pom.xml file and paste your code inside the
<dependencies>
tag.Run
mvn install
from the same path as your pom.xml file.