maven的scm插件介紹及使用示例


 

Maven中為我們集成了軟件配置管理的(SCM:Software Configuration Management)功能,他可以支持我們常用SVN、CVS等,到現在我使用的1.8.1版本,共支持18個命令:

scm:branch - branch the project(創建項目的分支)
scm:validate - validate the scm information in the pom(校驗SCM的配置信息)
scm:add - command to add file(增加一個文件)
scm:unedit - command to stop editing the working copy(停止編輯當前COPY)
scm:export - command to get a fresh exported copy(拉一個全新的分支)
scm:bootstrap - command to checkout and build a project(checkout並編譯工程)
scm:changelog - command to show the source code revisions(顯示源碼版本)
scm:list - command for get the list of project files(列出工程的文件)
scm:checkin - command for commiting changes(提交變更)
scm:checkout - command for getting the source code(獲取源碼)
scm:status - command for showing the scm status of the working copy(獲取本地項目的狀態)
scm:update - command for updating the working copy with the latest changes(從服務器獲取最新的版本)
scm:diff - command for showing the difference of the working copy with the remote one(比較本地與遠程服務器的差異)
scm:update-subprojects - command for updating all projects in a multi project build(更新子項目)
scm:edit - command for starting edit on the working copy(編輯)
scm:tag - command for tagging a certain revision(打標簽)

常用命令介紹

而我們常用只有以下這兩個命令:
Usage
The SCM Plugin maps a lot of commands to a variety of scm implementations. But there are only 2 frequently used commands:

checkin - 提交變更
update - 從服務器上獲取最新的版本

配置及使用

其它的SCM都有自己獨特的命令來操作提交變更、或從服務器上獲取最新的源嗎,如SVN及CVS的操作就很不相同,使用Maven擔任的SCM機制,就可以使得SCM的操作變得統一,以下是一個SVN配置示例,將以下的示例配置到pom.xml文件中

<project>
  ...
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>SCM Sample Project</name>
  <url>http://somecompany.com</url>
  <scm>
    <connection>scm:svn:http://somerepository.com/svn_repo/trunk</connection>
    <developerConnection>scm:svn:https://somerepository.com/svn_repo/trunk</developerConnection>
    <url>http://somerepository.com/view.cvs</url>
  </scm>
  ...
</project>

照這樣配置好的,現在我們要做提交或者更新,就按如下按行命令
提交:

mvn -Dmessage="<commit_log_here>" scm:checkin

獲取最新版本:

mvn scm:update

SCM支持的連接類型

SCM支持兩種連接類型:connection 及 developerConnection。
以下是一個連接類型為connection的配置示例:

<project>
  ...
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.8.1</version>
        <configuration>
          <connectionType>connection</connectionType>
        </configuration>
      </plugin>
      ...
    </plugins
    ...
  </build>
  ...
</project>

以下是一個連接類型為developerConnection的配置示例:

<project>
  ...
  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.8.1</version>
        <configuration>
          <connectionType>developerConnection</connectionType>
        </configuration>
      </plugin>
      ...
    </plugins
    ...
  </build>
  ...
</project>

 

再分享一下我老師大神的人工智能教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智能的隊伍中來!https://blog.csdn.net/jiangjunshow


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM