2016-04-18 49 views
1

Mavenプラグインを実行する順序に問題があります。 Iは、宣言順にプラグインを実行したいと思います:タスク1、タスク2、タスク3Mavenプラグインの実行順

しかしmvn initializeを実行した後、実際の順序は、タスクがある:私は実行順序を期待

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>test</groupId> 
    <artifactId>test</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>task-1</id> 
         <goals> 
          <goal>run</goal> 
         </goals> 
         <phase>initialize</phase> 
         <configuration> 
          <target> 
          </target> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>task-2</id> 
         <goals> 
          <goal>exec</goal> 
         </goals> 
         <phase>initialize</phase> 
        </execution> 
       </executions> 
       <configuration> 
        <executable>cmd</executable> 
        <arguments> 
         <argument>/c</argument> 
         <argument>rem</argument> 
        </arguments> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>task-3</id> 
         <goals> 
          <goal>run</goal> 
         </goals> 
         <phase>initialize</phase> 
         <configuration> 
          <target> 
          </target> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

-1、タスク-3、タスク-2:

[INFO] --- maven-antrun-plugin:1.3:run (task-1) @ test --- 
[INFO] Executing tasks 
[INFO] Executed tasks 
[INFO] 
[INFO] --- maven-antrun-plugin:1.3:run (task-3) @ test --- 
[INFO] Executing tasks 
[INFO] Executed tasks 
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:exec (task-2) @ test --- 

必要な順番でプラグインを実行するにはどうすればよいですか?

答えて

3

Mavenが複製プラグイン、つまりmaven-antrun-pluginについて警告することが予想されます。 Mavenは重複したプラグインを持つことができないので、結果として、タスク3の実行ブロックが最初のMaven-Antrun-Pluginにマージされます。 これで、Mavenはすべてのプラグインをトップダウンし、検証フェーズにバインドされた実行ブロックを探します。 結果を説明します。 この場合、注文を管理するオプションはありますか?いいえ、同じフェーズではありません。

+0

ありがとうございます。はい、「プラグインの重複宣言」警告がありました。さらに、これはMaven実行モデルの大きな制限です... – snorbi

関連する問題