{"id":3551,"date":"2018-06-05T06:31:37","date_gmt":"2018-06-04T22:31:37","guid":{"rendered":"http:\/\/switch.linesno.com\/?p=3551"},"modified":"2018-06-05T06:31:37","modified_gmt":"2018-06-04T22:31:37","slug":"maven%e7%9a%84scm%e6%8f%92%e4%bb%b6%e4%bb%8b%e7%bb%8d%e5%8f%8a%e4%bd%bf%e7%94%a8%e7%a4%ba%e4%be%8b-2","status":"publish","type":"post","link":"http:\/\/switch.linesno.com\/?p=3551","title":{"rendered":"maven\u7684scm\u63d2\u4ef6\u4ecb\u7ecd\u53ca\u4f7f\u7528\u793a\u4f8b"},"content":{"rendered":"<article>\n<div id=\"article_content\" class=\"article_content clearfix csdn-tracking-statistics\" data-pid=\"blog\" data-mod=\"popu_307\" data-dsm=\"post\">\n<div class=\"htmledit_views\">\n<div id=\"nei\" class=\"article_body\">\n<div>\n<p>Maven\u4e2d\u4e3a\u6211\u4eec\u96c6\u6210\u4e86\u8f6f\u4ef6\u914d\u7f6e\u7ba1\u7406\u7684\uff08SCM\uff1aSoftware Configuration Management\uff09\u529f\u80fd\uff0c\u4ed6\u53ef\u4ee5\u652f\u6301\u6211\u4eec\u5e38\u7528SVN\u3001CVS\u7b49\uff0c\u5230\u73b0\u5728\u6211\u4f7f\u7528\u76841.8.1\u7248\u672c\uff0c\u5171\u652f\u630118\u4e2a\u547d\u4ee4\uff1a<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">scm:branch - branch the project\uff08\u521b\u5efa\u9879\u76ee\u7684\u5206\u652f\uff09\r\nscm:validate - validate the scm information in the pom\uff08\u6821\u9a8cSCM\u7684\u914d\u7f6e\u4fe1\u606f\uff09\r\nscm:add - command to add file\uff08\u589e\u52a0\u4e00\u4e2a\u6587\u4ef6\uff09\r\nscm:unedit - command to stop editing the working copy\uff08\u505c\u6b62\u7f16\u8f91\u5f53\u524dCOPY\uff09\r\nscm:export - command to get a fresh exported copy\uff08\u62c9\u4e00\u4e2a\u5168\u65b0\u7684\u5206\u652f\uff09\r\nscm:bootstrap - command to checkout and build a project\uff08checkout\u5e76\u7f16\u8bd1\u5de5\u7a0b\uff09\r\nscm:changelog - command to show the source code revisions\uff08\u663e\u793a\u6e90\u7801\u7248\u672c\uff09\r\nscm:list - command for get the list of project files\uff08\u5217\u51fa\u5de5\u7a0b\u7684\u6587\u4ef6\uff09\r\nscm:checkin - command for commiting changes\uff08\u63d0\u4ea4\u53d8\u66f4\uff09\r\nscm:checkout - command for getting the source code\uff08\u83b7\u53d6\u6e90\u7801\uff09\r\nscm:status - command for showing the scm status of the working copy\uff08\u83b7\u53d6\u672c\u5730\u9879\u76ee\u7684\u72b6\u6001\uff09\r\nscm:update - command for updating the working copy with the latest changes\uff08\u4ece\u670d\u52a1\u5668\u83b7\u53d6\u6700\u65b0\u7684\u7248\u672c\uff09\r\nscm:diff - command for showing the difference of the working copy with the remote one\uff08\u6bd4\u8f83\u672c\u5730\u4e0e\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u5dee\u5f02\uff09\r\nscm:update-subprojects - command for updating all projects in a multi project build\uff08\u66f4\u65b0\u5b50\u9879\u76ee\uff09\r\nscm:edit - command for starting edit on the working copy\uff08\u7f16\u8f91\uff09\r\nscm:tag - command for tagging a certain revision\uff08\u6253\u6807\u7b7e\uff09<\/pre>\n<\/div>\n<\/div>\n<h4><strong>\u5e38\u7528\u547d\u4ee4\u4ecb\u7ecd<\/strong><\/h4>\n<p>\u800c\u6211\u4eec\u5e38\u7528\u53ea\u6709\u4ee5\u4e0b\u8fd9\u4e24\u4e2a\u547d\u4ee4\uff1a<br \/>\nUsage<br \/>\nThe SCM Plugin maps a lot of commands to a variety of scm implementations. But there are only 2 frequently used commands:<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">checkin - \u63d0\u4ea4\u53d8\u66f4\r\nupdate - \u4ece\u670d\u52a1\u5668\u4e0a\u83b7\u53d6\u6700\u65b0\u7684\u7248\u672c<\/pre>\n<\/div>\n<\/div>\n<h4><strong>\u914d\u7f6e\u53ca\u4f7f\u7528<\/strong><\/h4>\n<p>\u5176\u5b83\u7684SCM\u90fd\u6709\u81ea\u5df1\u72ec\u7279\u7684\u547d\u4ee4\u6765\u64cd\u4f5c\u63d0\u4ea4\u53d8\u66f4\u3001\u6216\u4ece\u670d\u52a1\u5668\u4e0a\u83b7\u53d6\u6700\u65b0\u7684\u6e90\u5417\uff0c\u5982SVN\u53caCVS\u7684\u64cd\u4f5c\u5c31\u5f88\u4e0d\u76f8\u540c\uff0c\u4f7f\u7528Maven\u62c5\u4efb\u7684SCM\u673a\u5236\uff0c\u5c31\u53ef\u4ee5\u4f7f\u5f97SCM\u7684\u64cd\u4f5c\u53d8\u5f97\u7edf\u4e00\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2aSVN\u914d\u7f6e\u793a\u4f8b\uff0c\u5c06\u4ee5\u4e0b\u7684\u793a\u4f8b\u914d\u7f6e\u5230pom.xml\u6587\u4ef6\u4e2d<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">&lt;project&gt;\r\n  ...\r\n  &lt;packaging&gt;jar&lt;\/packaging&gt;\r\n  &lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;\r\n  &lt;name&gt;SCM Sample Project&lt;\/name&gt;\r\n  &lt;url&gt;http:\/\/somecompany.com&lt;\/url&gt;\r\n  &lt;scm&gt;\r\n    &lt;connection&gt;scm:svn:http:\/\/somerepository.com\/svn_repo\/trunk&lt;\/connection&gt;\r\n    &lt;developerConnection&gt;scm:svn:https:\/\/somerepository.com\/svn_repo\/trunk&lt;\/developerConnection&gt;\r\n    &lt;url&gt;http:\/\/somerepository.com\/view.cvs&lt;\/url&gt;\r\n  &lt;\/scm&gt;\r\n  ...\r\n&lt;\/project&gt;<\/pre>\n<\/div>\n<\/div>\n<p>\u7167\u8fd9\u6837\u914d\u7f6e\u597d\u7684\uff0c\u73b0\u5728\u6211\u4eec\u8981\u505a\u63d0\u4ea4\u6216\u8005\u66f4\u65b0\uff0c\u5c31\u6309\u5982\u4e0b\u6309\u884c\u547d\u4ee4<br \/>\n\u63d0\u4ea4\uff1a<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">mvn -Dmessage=\"&lt;commit_log_here&gt;\" scm:checkin<\/pre>\n<\/div>\n<\/div>\n<p>\u83b7\u53d6\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">mvn scm:update<\/pre>\n<\/div>\n<\/div>\n<h4><strong>SCM\u652f\u6301\u7684\u8fde\u63a5\u7c7b\u578b<\/strong><\/h4>\n<p>SCM\u652f\u6301\u4e24\u79cd\u8fde\u63a5\u7c7b\u578b\uff1aconnection \u53ca developerConnection\u3002<br \/>\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8fde\u63a5\u7c7b\u578b\u4e3aconnection\u7684\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">&lt;project&gt;\r\n  ...\r\n  &lt;build&gt;\r\n    [...]\r\n    &lt;plugins&gt;\r\n      &lt;plugin&gt;\r\n        &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;maven-scm-plugin&lt;\/artifactId&gt;\r\n        &lt;version&gt;1.8.1&lt;\/version&gt;\r\n        &lt;configuration&gt;\r\n          &lt;connectionType&gt;connection&lt;\/connectionType&gt;\r\n        &lt;\/configuration&gt;\r\n      &lt;\/plugin&gt;\r\n      ...\r\n    &lt;\/plugins\r\n    ...\r\n  &lt;\/build&gt;\r\n  ...\r\n&lt;\/project&gt;<\/pre>\n<\/div>\n<\/div>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8fde\u63a5\u7c7b\u578b\u4e3adeveloperConnection\u7684\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<div>\n<div>\n<pre class=\"prettyprint\">&lt;project&gt;\r\n  ...\r\n  &lt;build&gt;\r\n    ...\r\n    &lt;plugins&gt;\r\n      &lt;plugin&gt;\r\n        &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;maven-scm-plugin&lt;\/artifactId&gt;\r\n        &lt;version&gt;1.8.1&lt;\/version&gt;\r\n        &lt;configuration&gt;\r\n          &lt;connectionType&gt;developerConnection&lt;\/connectionType&gt;\r\n        &lt;\/configuration&gt;\r\n      &lt;\/plugin&gt;\r\n      ...\r\n    &lt;\/plugins\r\n    ...\r\n  &lt;\/build&gt;\r\n  ...\r\n&lt;\/project&gt;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>Maven\u4e2d\u4e3a\u6211\u4eec\u96c6\u6210\u4e86\u8f6f\u4ef6\u914d\u7f6e\u7ba1\u7406\u7684\uff08SCM\uff1aSoftware Configuration Manageme [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-3551","post","type-post","status-publish","format-standard","hentry","category-working-diary"],"_links":{"self":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts\/3551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3551"}],"version-history":[{"count":1,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts\/3551\/revisions"}],"predecessor-version":[{"id":3552,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts\/3551\/revisions\/3552"}],"wp:attachment":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3551"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}