2010-02-03 184 views
28

是否可以通過命令行的id來調用maven-exec-plugin(或任何其他插件)的執行?Maven-maven-exec-plugin多個執行配置

比方說,我的pom.xml文件看起來是這樣的:

<project> 
[...] 
    <plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>foo</id> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      <phase></phase> 
      <configuration> 
       <executable>echo</executable> 
       <arguments> 
        <argument>foo</argument> 
       </arguments> 
      </configuration> 
     </execution> 
     <execution> 
      <id>bar</id> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      <phase></phase> 
      <configuration> 
       <executable>echo</executable> 
       <arguments> 
        <argument>bar</argument> 
       </arguments> 
       </configuration> 
      </execution> 
     </executions> 
    </plugin> 
[...] 
</project> 

現在是它可以調用

MVN高管:EXEC

增加了一些魔法運行執行「富」?

對於好奇存在利用可在這裏型材的替代解決方案: http://www.mail-archive.com/[email protected]/msg00151.html

+3

我不能讓插件一起工作標籤中的。但它確實能夠將它放在標籤之外。錯誤是目標org.codehaus.mojo的「The parameters'executable':exec-maven-plugin:1.2.1:exec缺失或無效」 – avanderw 2012-09-21 08:47:26

+0

請注意,在上述「使用配置文件的替代解決方案」中,「'標籤丟失。 – zb226 2015-01-23 07:09:08

回答

15

不,這是不可能的。執行是爲了綁定到生命週期(即它們不是在命令行中調用的)。因此,您必須使用您提供的鏈接中描述的配置文件技巧。

+0

這不完全正確。請參閱[我的答案](http://stackoverflow.com/questions/2192660/maven-maven-exec-plugin-multiple-execution-configurations/7085988#7085988)。 – 2011-08-16 22:44:10

+1

現在可以。見slangois的答案。 – heenenee 2016-01-27 18:18:27

+1

看到下一個答案:它正在工作:-) – BTakacs 2016-02-16 10:21:42

0

我認爲,如果你寫的執行目標:

org.codehaus.mojo:exec-maven-plugin:¿Version?:exec 

它在Eclipse中Maven插件爲我工作。

11

這裏沒有提到的是,從Maven 2.2.0開始,如果你使用give an execution of any plugin the id "default-cli",那麼當你從命令行運行該插件時,會使用該配置。您僅限於每個插件的一次默認執行,但這只是一個開始。