2010-09-24 92 views
17

我在我的POM如下:行家antrun插件

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-ant-plugin</artifactId> 
    <version>2.3</version> 
    <configuration> 
     <target> 
      <echo 
      message="hello ant, from Maven!" /> 
      <echo>Maybe this will work?</echo> 
     </target> 
    </configuration> 
</plugin> 

然而,當我運行 'MVN antrun:運行' 我得到這個:

[INFO] Scanning for projects... 
[INFO] Searching repository for plugin with prefix: 'antrun'. 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building myProject 
[INFO] task-segment: [antrun:run] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [antrun:run {execution: default-cli}] 
[INFO] Executing tasks 
[INFO] Executed tasks 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1 second 
[INFO] Finished at: Fri Sep 24 13:33:14 PDT 2010 
[INFO] Final Memory: 16M/28M 
[INFO] ------------------------------------------------------------------------ 

爲什麼回聲的不出現?

TIA

+0

重申一些我錯過的東西 - 確保使用插件的1.5+版本。 – javamonkey79 2011-12-28 00:13:14

回答

28

因爲你應該使用Maven AntRun Plugin如果要執行Ant任務,而不是Maven Ant Plugin(這是用來產生從POM建立的Ant 1.6.2或以上的文件)。修改插件配置如下:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.5</version> 
    <configuration> 
     <target> 
     <echo message="hello ant, from Maven!"/> 
     <echo>Maybe this will work?</echo> 
     </target> 
    </configuration> 
    </plugin> 

和調用antrun:run將工作:

 
$ mvn antrun:run 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Q3790798 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-antrun-plugin:1.5:run (default-cli) @ Q3790798 --- 
[INFO] Executing tasks 

main: 
    [echo] hello ant, from Maven! 
    [echo] Maybe this will work? 
[INFO] Executed tasks 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
... 
+0

哦,男人,多麼可笑的簡單但令人煩惱的錯誤!非常感謝,你就像Jon Skeet for Java:D – javamonkey79 2010-09-24 21:05:46

+0

@ javamonkey79不客氣。兩個插件之間的混淆發生,這是引起我注意的版本之間的不匹配。 – 2010-09-24 21:15:26

2

確保maven-antrun-plugin使用最新版本的不足。

我的項目中一個不相關的物料清單將其鎖定到1.3,並且<echo>被忽略。在刪除BOM並指定了對於antrun的1.7後,回聲起作用。