使用release自動打包發布正式版詳細教程


  昨天寫了個release插件的版本管理,今天就在自動發布過程中遇到了許多坑,只能再寫一篇自動發布詳細教程,紀念我那昨日逝去的青春 (╥ _ ╥`)  

 

  release正常打包發布流程按照如下幾個階段:

  • Check that there are no uncommitted changes in the sources
  • Check that there are no SNAPSHOT dependencies
  • Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
  • Transform the SCM information in the POM to include the final destination of the tag
  • Run the project tests against the modified POMs to confirm everything is in working order
  • Commit the modified POMs
  • Tag the code in the SCM with a version name (this will be prompted for)
  • Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)
  • Commit the modified POMs

 

1. 檢出項目

       由上述流程可知,release打包發布成功的前提條件是於svn庫中代碼完全一致(包括配置文件、target文件夾、.classpath文件等),所以不能直接在eclipse進行build。

       因此我們需要新建一個文件夾,重新檢出項目,專門進行打包發布。

 

2.  開始打包

在platform中打開控制台輸入命令:

  測試命令(以文字型輸出,並未真正發布):

    mvn -DdryRun=true release:prepare-with-pom

        正式命令:

              mvn release:prepare-with-pom

正常應出現:                  

 

 

如果要用默認值,就直接回車。 

 

“你想將1.1.7-SNAPSHOT發布為什么版本?默認1.1.7。”    我要1.1.7,直接回車。

“發布的tag標簽名稱是什么?默認為v1.1.7。”    我還是要默認值,直接回車。

“主干上新的版本是什么?默認為1.1.8-SNAPSHOT。”   哈,release插件會自動幫我更新版本到1.1-SNAPSHOT,很好,直接回車。

  然后屏幕刷阿刷,maven在build我們的項目,並進行了一些svn操作,你可以仔細查看下日志。

 

然而事情有時並不是和你想象的那樣順利!   (╯>㉨<)╯ ミ ┸┸)`ν゚) 

 

你可能會遇到這種情況:

 

解決方案:

    這是platform的子模塊存在快照版本的依賴,應改為正式版。(即沒有-SNAPSHOT的jar版本)

 

或者這種情況:

  運行發布命令直接失敗,顯示release無依賴!!!

 

解決方案:

    檢查配置是否齊全。

 

  platform父級模塊的配置:

<!-- scm配置,具體路徑為待打包代碼分支的根路徑(trunk、branckes/v1.1.x、/tags/v1.1.5等) -->
    <scm>
          <developerConnection>scm:svn:svn://SVN主路徑地址/trunk/</developerConnection>
     </scm> 
   <!-- maven-release-plugin插件配置 -->
    <build>
          <plugins>
              <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-release-plugin</artifactId>
                   <version>2.5.3</version>
                   <configuration>
                     <autoVersionSubmodules>true</autoVersionSubmodules>
                     <tagNameFormat>v@{project.version}</tagNameFormat>
                     <generateReleasePoms>false</generateReleasePoms>
                     <arguments>-DskipTests</arguments>
                </configuration>
              </plugin>
          </plugins>
     </build>

  console、service等子模塊的配置

<!-- maven-release-plugin插件配置 -->
    <build>
          <plugins>
              <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-release-plugin</artifactId> 
                <version>2.5.3</version> 
            </plugin>
          </plugins>
     </build>

 

又或者這種情況:

運行發布命令直接失敗,顯示有與SVN庫代碼不一致。

解決方案:

       更新platform打包發布文件夾。 

 

 

還不是?那么你涼了,趕緊刪庫跑路吧!   ✧*。٩(^㉨^*)و✧*。 

給你個傳送門,快往這里跑!    內有惡犬

 

3.  清除release configuration信息

在發布或測試發布之后,會產生發布配置信息,如果下次再發布就需要將其刪除,保持和SVN庫代碼一致。

    所用命令:

                                     mvn release:clean

4.  清除target文件夾

同上,必須和SVN庫代碼保持一致。

 

所用命令:

                  mvn clean

 


免責聲明!

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



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