2013-05-21 47 views
0

我有兩個oracle用戶,我正在爲他們創建不同的架構。我的意思是每個模式都有不同的表,類型等 我想創造的遷徙路線Maven插件兩種模式中,第一我有兩個Maven插件,但後來我想也有兩個獨立的配置文件:所有maven flyway插件都與最後一個用戶一起執行

<profiles> 
    <profile> 
     <id>database</id> 
     <build> 
     <plugins> 
      <plugin> 
      <groupId>com.googlecode.flyway</groupId> 
      <artifactId>flyway-maven-plugin</artifactId> 
      <configuration> 
       <url>jdbc:oracle:thin:@devdb2:1521:ZOOMUTF</url> 
       <table>SCHEMA_UPDATES</table> 
       <outOfOrder>true</outOfOrder> 
       <locations> 
       <location>db/callrec</location> 
       </locations> 
       <user>cr_5199_mensik_mvn</user> 
       <password>callrec</password> 
       <serverId>callrec</serverId> 
      </configuration> 
      <executions> 
       <execution> 
       <id>compile</id> 
       <phase>compile</phase> 
       <goals> 
        <goal>migrate</goal> 
       </goals> 
       </execution> 
       <execution> 
       <id>clean</id> 
       <phase>clean</phase> 
       <goals> 
        <goal>clean</goal> 
       </goals> 
       </execution> 
      </executions> 
      </plugin> 
     </plugins> 
     </build> 
    </profile> 

    <profile> 
     <id>database_wbsc</id> 
     <build> 
     <plugins> 

      <plugin> 
      <groupId>com.googlecode.flyway</groupId> 
      <artifactId>flyway-maven-plugin</artifactId> 
      <configuration> 
       <url>jdbc:oracle:thin:@devdb2:1521:ZOOMUTF</url> 
       <table>SCHEMA_UPDATES</table> 
       <outOfOrder>true</outOfOrder> 
       <locations> 
       <location>db/wbsc</location> 
       </locations> 
       <user>sc_5199_mensik_mvn</user> 
       <password>wbsc</password> 
       <serverId>wbsc</serverId> 
      </configuration> 
      <executions> 
       <execution> 
       <id>wbsc_compile</id> 
       <phase>compile</phase> 
       <goals> 
        <goal>migrate</goal> 
       </goals> 
       </execution> 
       <execution> 
       <id>wbsc_clean</id> 
       <phase>clean</phase> 
       <goals> 
        <goal>clean</goal> 
       </goals> 
       </execution> 
      </executions> 
      </plugin> 
     </plugins> 
     </build> 
    </profile> 
</profiles> 

然後我執行:

mvn clean -Pdatabase,database_wbsc 

但結果是隻有第二輪廓被執行兩次:

[INFO] [clean:clean {execution: default-clean}] 
[INFO] [flyway:clean {execution: clean}] 
[INFO] Cleaned schema "sc_5199_mensik_mvn" (execution time 00:00.023s) 
[INFO] [flyway:clean {execution: wbsc_clean}] 
[INFO] Cleaned schema "sc_5199_mensik_mvn" (execution time 00:00.018s) 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 

如果我切換在XML配置文件的順序(未在行家executio n命令),那麼使用第二個用戶。

我該如何執行兩個配置文件,但使用它們的配置?

回答

2

嘗試在執行級別而不是插件級別提供配置。

  <plugin> 
      <executions> 
       <execution> 
        <id>execution1</id> 
        <configuration> 
        </configuration> 
       </execution> 
       <execution> 
        <id>execution2</id> 
        <configuration> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
+0

謝謝,它有助於解決相同配置下執行兩個配置文件的解決方法問題! – Cipous