EDUCBA

EDUCBA

MENUMENU
  • Explore
    • Lifetime Membership
    • All in One Bundles
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Login
Home Software Development Software Development Tutorials Maven Tutorial Maven Deploy

Maven Deploy

Payal Udhani
Article byPayal Udhani
Priya Pedamkar
Reviewed byPriya Pedamkar

Updated April 12, 2023

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.

ADVERTISEMENT
Popular Course in this category
MAVEN Course Bundle - 10 Courses in 1 | 6 Mock Tests

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

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.

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

We hope that this EDUCBA information on “Maven Deploy” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. Maven Plugins
  2. Maven Repository
  3. What is Maven
  4. Maven Commands
ADVERTISEMENT
GOLANG Course Bundle - 6 Courses in 1
23+ Hours of HD Videos
6 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
iOS DEVELOPER Course Bundle - 61 Courses in 1
147+ Hours of HD Videos
61 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
JAVA SERVLET Course Bundle - 18 Courses in 1 | 6 Mock Tests
56+ Hours of HD Videos
18 Courses
6 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
RED HAT LINUX Course Bundle - 5 Courses in 1
28+ Hours of HD Videos
5 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • 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

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

EDUCBA

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

Let’s Get Started

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

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

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

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

Forgot Password?

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

🚀 Extended Cyber Monday Price Drop! All in One Universal Bundle (3700+ Courses) @ 🎁 90% OFF - Ends in ENROLL NOW