2013-08-22 39 views
0

我是Maven的新手,剛讀完Sonatype指南,對maven提供的函數非常滿意。我創建了一個應用程序分發(.zip)包,我想知道是否有方法將maven用作安裝程序。 我不是說maven會把安裝到本地倉庫,我的意思是通過下面的例子來解釋:是否有Maven插件來安裝該項目?

我有一個文件夾,裏面有一個jar文件,一個.sql腳本,一個/ lib,顯然一個pom.xml文件。 我希望Maven在執行「mvn」命令時爲我安裝這個項目。 所以maven應該: - 將jar文件複製到$ {TOMCAT_HOME} \ webapps目錄中。 - 在postgresql數據庫上執行sql腳本 - 複製c:\ myLibs中的\ lib目錄 - etc等 在此過程中還應該進行一些檢查(例如系統上設置了TOMCAT_HOME?Postgres打開了?等等),並詢問用戶一些參數(例如「安裝將重置數據庫是否要繼續嗎?」或「請插入數據庫密碼:」

是否有一個maven插件可以幫助做到這一點?如果沒有,是否有一個專門用來創建「安裝程序」的應用程序maven?它是一個標準的,廣泛的應用程序嗎? 非常感謝您的幫助!

回答

0

添加到您的POM

<distributionManagement> 
       <repository> 
         <id>sonatype.internal</id> 
         <name>Internal Release Repository</name> 
         <url>http://sonatypeAddress:sonatypePort/context</url> 
       </repository> 
</distributionManagement> 

插件部分:

   <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-scm-plugin</artifactId> 
         <configuration> 
           <tag>${build.tag}</tag> 
           <username>${scm.username}</username> 
           <password>${scm.password}</password> 
         </configuration> 
       </plugin> 
  • antrun plugin - 讓你想要什麼。

     <plugin> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-antrun-plugin</artifactId> 
          <version>1.7</version> 
          <dependencies> 
           ... 
          </dependencies> 
          <executions>      
    
           <execution> 
            <id>install</id> 
            <phase>install</phase> 
            <configuration> 
             <target> 
                    <delete dir="mylocalization" /> 
              <copy file="target/out/my.jar" tofile="mylocalication" /> 
    
              <copy todir="mylocalization/doc"> 
               <fileset dir="target/doc" /> 
              </copy> 
              <copy todir="mylocalization/somethingMore"> 
               <fileset dir="target/more"> 
                <include name="a.txt" /> 
                <include name="b*.txt" /> 
               </fileset> 
              </copy> 
    
    
             </target> 
            </configuration> 
            <goals> 
             <goal>run</goal> 
            </goals> 
           </execution> 
    
          </executions> 
         </plugin> 
    
  • 又見maven-wagon

相關問題