EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Maven Tutorial Maven Deploy
Secondary Sidebar
Maven Tutorial
  • Maven Basic and advance
    • What is Maven
    • How to Install Maven
    • Maven Commands
    • Maven GroupId
    • Maven WAR Plugin
    • Maven Build Command
    • Maven Failsafe Plugin
    • Maven Profile
    • IntelliJ Maven
    • Maven Enforcer Plugin
    • Maven Javadoc Plugin
    • Maven WAR Plugin
    • Maven Build Command
    • Maven GroupId
    • Maven Force Update
    • Maven Encrypt Password
    • Maven Environment Variables
    • AssertJ Maven
    • Maven Run Single Test
    • Maven kafka-clients
    • Maven Quickstart Archetype
    • Maven Install Dependencies
    • Maven XMLBeans
    • Maven Local Repository
    • Maven Versions
    • Maven Jar Plugin
    • Maven Assembly Plugin
    • Maven exec plugin
    • Maven Central Repository
    • Maven Surefire
    • Maven Deploy
    • Maven Phases
    • Maven Archetype
    • Maven Skip Test
    • Maven Dependency Scope
    • Maven Shade Plugin
    • Maven Repository Spring
    • Maven Eclipse Plugin
    • Maven Exclude Dependency
    • Maven Life Cycle
    • Maven Repository
    • Maven POM File
    • Maven Plugins
    • What is Maven Plugins
    • Maven Interview Questions
    • Maven Flags
    • Maven Project
    • Maven Settings.XML

Maven Deploy

By Payal UdhaniPayal Udhani

Maven-Deploy

Introduction to Maven Deploy

Apache Maven is a building tool that also helps in performing other project management tasks such as dependency management and documentation. The build lifecycle of the maven is divided into multiple phases. Validate, compile, test, package, verify, install, and deploy. The deploy is the last phase of the maven lifecycle. In this phase, the build is completed and the current project is being copied to the remote repository. This makes the built project available for other projects to add as dependency or developers. In this topic, we are going to learn about Maven Deploy.

The deploy plugin in the maven is used in the deploy phase of the build lifecycle. In this article, we will learn about the maven deploy plugin, where is it used, that are the prerequisites to use it and how it can be done.

Deploy Plugin of Maven

The deployment is usually performed in the environments where integration and release of the projects are done. It is the action to add the project(s), the artifact(s), and all the related information to the remote place where remote repository is located so that it can be used and accessed by other projects and developers.

The repository is not just made of artifacts, it also contains various metadata, hash files like MD5 and SHA1, POM files, etc that need to be updated as well when a new deployment is being done along with copying the expected artifact(s). Maven deploy plugin makes sure that all this task is performed correctly.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,328 ratings)

Prerequisites

If you want to deploy the artifact(s) there are certain things that you need to have before doing so that are as follows –

  • Repository related information such as the location of the repository, the access mechanism, and method of transports like SFTP, SCP, and FTP or any other and the information about the user account that is required sometimes and is optional.
  • Artifact(s) related information that you wish to deploy such as the packaging, artifact id, group id, classifier, and other things.
  • Deployer – This is the actual strategy of methodology that will perform the deployment of the artifact(s).There are many ways in which this can be done such as using the methods that is specified by the system or implementing the wagon transport that helps in making it cross-platform.

All the above prerequisites and information is obtained from the command-line and pom files that are specified or implied. To obtain the credentials of user parsing of settings.xml can also be done.

Goals of deploy plugin

There are two goals defined for the deploy plugin to perform deployment that is as follows –

  • deploy:deploy – It helps in the automatic installation of the artifact and its related information such as pom file, artifacts that are attached to the particular project. All the information that is related to the deployment is stored inside the pom file of the project.
  • deploy:deploy-file – This goal is useful in the installation of a single artifact and its pom. Information about the artifact is obtained from the optionally specified pom file or command-line.

Besides the above two, there is one more goal for which the deploy plugin is helpful that is deploy:help which helps in displaying all the information related to maven deploy plugin for help. This goal can be called by using the following command to display the details of parameters –

mvn deploy:help -Ddetails=true -Dgoal=<goal-name>

For using the deploy plugin of maven the minimum requirements that your system should fulfill include maven 3.0 and JDK 1.7. It does not have any minimum memory or disk space mentioned for the plugin to work properly.

Using the maven-deploy-plugin

We need to specify the version and plugin in the <pluginManagement> tag of the pom.xml file to define the version of the plugin in parent pom and specify the version and plugin in the plugins section of the pom file to use the goals of the plugin by your project or your parent project.

You can do so by using the following snippet in your pom file.

<project>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
</plugins>
</build>
</project>

Syntax –

It is very easy to deploy the project. You just need to fire the following command –

mvn deploy

In most of the cases, the test phase is not required to be performed while deploying and releasing your project as this is the last stage of your project and it is obvious that the project has been tested previously if required. Hence, you can skip the test phase of the maven build lifecycle while deploying by using the command –

mvn clean deploy -Dmaven.test.skip=true

Usage and example of artifact deployment with FTP method

The maven deploy plugin can be used to deploy either files or projects to the remote repository for sharing it with other developers and projects. There are various methods can be used to deploy your artifact to the remote repository by using a maven deploy plugin.

One of the most basic ones is using the FTP to deploy artifacts in the maven project while using the deploy plugin. In this case, you need to mention the FTP server usage in the <distributionManagement> tag of the pom file and to pull in the artifacts you also need to mention it in extension tag of the <build> element inside your pom.xml file in the following way –

<distributionManagement>
<repository>
<id>sample-ftp-educba-repository</id>
<url>ftp://repository.educba.com/samplerepository</url>
</repository>
</distributionManagement>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>

Besides that, you will have to mention user details and id along with configurations for FTP in your settings.xml file. This can be specified in the following way inside the <servers> tag of settings element, you will need to add the following snippet having server tag –

<server>
<id>sample-ftp-educba-repository</id>
<username>your_uname</username>
<password>your_passwd</password>
<configuration>
<endpointChecking>false</endpointChecking>
</configuration>
</server>

Note that the id you mention in the server element inside the settings.xml file and id in your repository tag inside <distributionmanagement> element in pom file needs to be the same.

Conclusion

You can easily deploy a single artifact or multiple artifacts to the remote repository so that other developers and projects can use it with the help of deploy plugin provided in maven projects.

Recommended Articles

This is a guide to Maven Deploy. Here we discuss the Deploy Plugin of Maven with the goals, usage, and example of artifact deployment with the FTP method. You may also look at the following articles to learn more –

  1. Maven Plugins
  2. Maven Repository
  3. What is Maven
  4. Maven Commands
Popular Course in this category
Maven Training (4 Courses, 6 Projects)
  4 Online Courses |  6 Hands-on Project |  26+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more