2012-06-29 64 views
0

我有一個爲JBoss AS 7.1.x創建一些WAR和EAR文件的maven(多模塊)項目。從Maven antrun插件運行貨物

爲了一個目的,我需要將一個生成的一個模塊的EAR文件部署到一個新的JBoss實例並運行它,調用一些REST Web服務調用並阻止JBoss。然後我需要打包寫入數據庫的這些調用的結果。

目前,我正在嘗試使用CARGO和maven ant run插件來執行此任務。

不幸的是,我不能讓三個人(maven,ant run和CARGO)一起玩。我沒有在貨物的螞蟻例子中使用的uberjar。我如何配置ant運行任務,以便貨物ant任務可以創建,啓動和部署我的JBoss?理想情況下,由maven2-plugin在另一個階段解壓縮和配置一個?

或者,有沒有更好的方法來實現我創建數據庫的目標?

我無法真正使用集成測試階段,因爲它在之後的包階段執行。所以,我打算在使用ant run的編譯階段完成所有工作。

再次澄清:

我需要執行以下操作:啓動JBoss;部署一個WAR;等到WAR的啓動完成;部署EAR文件;等到EAR初始化它的數據庫;在EAR實施的過程中調用一些Web服務;停止JBoss;打包數據庫。

所有這些步驟都必須是嚴格連續。

+0

爲什麼不使用cargo2 maven插件而不是Antrun? – khmarbaise

+0

我需要執行以下操作:啓動JBoss;部署一個WAR; *等待,直到WAR的啓動完成;部署EAR文件;等到EAR初始化它的數據庫;在EAR實施的過程中調用一些Web服務;停止JBoss;打包數據庫。我怎麼用cargo2-maven插件做這件事? – Frank

回答

1

The following part gives you an impression how to do that。你必須改變細節。在特定情況下,我使用Tomcat。這將下載Tomcat歸檔解壓縮並在本地安裝Tomcat ...

<plugin> 
    <groupId>org.codehaus.cargo</groupId> 
    <artifactId>cargo-maven2-plugin</artifactId> 
    <configuration> 
     <wait>false</wait> 
     <container> 
     <containerId>tomcat${tomcat.major}x</containerId> 
     <zipUrlInstaller> 
      <url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url> 
      <extractDir>${project.build.directory}/extract/</extractDir> 
      <downloadDir>${project.build.directory}/download/</downloadDir> 
     </zipUrlInstaller> 
     <output>${project.build.directory}/tomcat${tomcat.major}x.log</output> 
     <log>${project.build.directory}/cargo.log</log> 
     </container> 
     <configuration> 
     <home>${project.build.directory}/tomcat-${tomcat.version}/container</home> 
     <properties> 
      <cargo.logging>high</cargo.logging> 
      <cargo.servlet.port>9080</cargo.servlet.port> 
      <cargo.tomcat.ajp.port>9008</cargo.tomcat.ajp.port> 
     </properties> 
     </configuration> 
    </configuration> 
    <executions> 
     <execution> 
     <id>start-container</id> 
     <phase>pre-integration-test</phase> 
     <goals> 
      <goal>start</goal> 
      <goal>deploy</goal> 
     </goals> 
     <configuration> 
      <deployer> 
      <deployables> 
       <deployable> 
       <groupId>${project.groupId}</groupId> 
       <artifactId>mod-war</artifactId> 
       <type>war</type> 
       <pingURL>http://localhost:9080/mod-war</pingURL> 
       <pingTimeout>30000</pingTimeout> 
       <properties> 
        <context>mod-war</context> 
       </properties> 
       </deployable> 
      </deployables> 
      </deployer> 
     </configuration> 
     </execution> 
     <execution> 
     <id>stop-container</id> 
     <phase>post-integration-test</phase> 
     <goals> 
      <goal>stop</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 
+0

幫了很大忙。現在我只需要弄清楚現在就可以對多個部署進行排序,以及編譯階段的所有功能。 – Frank

+0

在編譯階段?那沒有意義。我會在集成測試階段這樣做,並創建一個可以通過配置文件激活的單獨模塊。 – khmarbaise

+0

我需要在包裝之前的某個階段做到這一點。你推薦哪一個?集成測試絕對不起作用,或者它呢? – Frank