{"id":3659,"date":"2020-02-09T08:10:37","date_gmt":"2020-02-09T08:10:37","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=3659"},"modified":"2020-04-20T17:40:50","modified_gmt":"2020-04-20T17:40:50","slug":"all-about-release-using-mvn-release-plugin","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/all-about-release-using-mvn-release-plugin\/","title":{"rendered":"All about Release using mvn release plugin"},"content":{"rendered":"<p>Used to perform a release of a project with Maven.<\/p>\n<p><strong>Key goals in mvn release Plugin<\/strong><\/p>\n<ol>\n<li>release:clean Clean up after a release preparation.<\/li>\n<li>release:prepare Prepare for a release in SCM(Source Code Management i.e. nexus).<\/li>\n<li>release:rollback Rollback a previous release.<\/li>\n<li>release:perform Perform a release from SCM.<\/li>\n<\/ol>\n<p><strong>Prerequisite<\/strong><br \/>\n<em>Since this plugin releases artifacts(could be JAR&#8217;s, ZIP&#8217;s WAR&#8217;s or TAR&#8217;s) into the repository we need to make sure<br \/>\ncredentials are properly configured in settings.xml in the conf folder, Maven installation directory. Failing to do so would<br \/>\nend up in authorization error while running the goals in the plugin<\/em><\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre>\r\n>>mvn release:clean release:prepare\r\n>>mvn release:perform\r\n<\/pre>\n<p><strong>How it Works<\/strong><\/p>\n<ol>\n<li>Once you run <em>release:clean<\/em> it would clean the old class files just like maven clean<\/li>\n<li>When you run release:prepare it would read the pom.xml in the project. If you don&#8217;t have snapshot version defined you would end up with snapshot not found error since the<br \/>\nplugin assumes snapshot is the one which needs to be released.<\/li>\n<li>Now on running release:prepare will ask for the name of the version and will <strong>change the line snapshot in pom.xml<\/strong>. It also <strong>does a git push of pom.xml<\/strong> in the remote repo<\/li>\n<li>When you run release:perform it will push the jar in the nexus repo so it would be available for other teams.<\/li>\n<li>When you are working on App-Model-0.0.1-SNAPHSOT using mvn:prepare and mvn:perform would put App-Model-0.0.1 in repo at the same time modifying pom.xml in local and git to 0.0.2-SNAPSHOT. So the dependent project needs to be updated likewise<\/li>\n<\/ol>\n<p><strong>Other know issues:<\/strong><br \/>\nSometime the <strong>release:perform<\/strong> fails because it complains tag already exists in repo. In such a case, you need to delete the tags and perform release again.<br \/>\nDuring the release, the list of files that needs to go along release would be tagged to particular version. In some cases, there would be files with the same tag name. In such case, maven-plugin complains the tag already exists. <\/p>\n<p><strong>To get the recent Tag<\/strong> <\/p>\n<pre>\r\n\/\/Recent Tags\r\ngit describe --tags\r\n\r\n\/\/Latest Tags - With --abbrev=0 it should return closest annotated tag\r\ngit describe --abbrev=0\r\n<\/pre>\n<p><strong>To delete the tag<\/strong><br \/>\n<em>git fetch<\/em> is needed to get the remote tags to be displayed in local, kind of refresh<\/p>\n<pre> \r\n\/\/To delete tag locally\r\ngit tag -d TAG_NAME  \r\n\r\ngit fetch\r\n\r\n\/\/To delete tag remote\r\ngit push --delete origin TAG_NAME\r\n<\/pre>\n<p><strong>To get the Latest tags for different commits done across various branches<\/strong><\/p>\n<pre> \r\ngit describe --tags $(git rev-list --tags --max-count=1)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Used to perform a release of a project with Maven. Key goals in mvn release Plugin release:clean Clean up after a release preparation. release:prepare Prepare for a release in SCM(Source Code Management i.e. nexus). release:rollback Rollback a previous release. release:perform Perform a release from SCM. Prerequisite Since this plugin releases artifacts(could be JAR&#8217;s, ZIP&#8217;s WAR&#8217;s&hellip; <a href=\"https:\/\/codethataint.com\/blog\/all-about-release-using-mvn-release-plugin\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[215],"tags":[],"class_list":["post-3659","post","type-post","status-publish","format-standard","hentry","category-maven"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=3659"}],"version-history":[{"count":5,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3659\/revisions"}],"predecessor-version":[{"id":3695,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3659\/revisions\/3695"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=3659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=3659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=3659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}