2009-06-26 75 views
4

我試圖執行使用Maven的EXEC我的項目:EXEC目標,我一直試圖在這個片段中進行配置:的Maven Exec插件不讀取配置

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.1.1</version> 
    <configuration> 
     <executable>java</executable> 
     <arguments> 
      <argument>-jar ${staging.dir}/project.jar</argument> 
     </arguments> 
    </configuration> 
    <executions> 
     <execution> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

當我運行mvn exec:exec我得到的輸出:

------------------------------------------------------------------------ 
[ERROR]BUILD ERROR 
------------------------------------------------------------------------ 
One or more required plugin parameters are invalid/missing for 'exec:exec' 

[0] Inside the definition for plugin 'exec-maven-plugin' specify the following: 

<configuration> 
    ... 
    <executable>VALUE</executable> 
</configuration> 

-OR- 

on the command line, specify: '-Dexec.executable=VALUE' 

我試過重組<plugin>我可以想到但是沒有什麼區別?該項目是一個POM不是一個罐子。

任何想法?

回答

1

試着把configuration放在execution之內。

+0

配置元素不屬於此插件的執行元素內部。 – 2009-07-14 13:48:06

6

我看到您的代碼有一個問題。您需要將-jar放入其自己的argument元素中。如果你不知道,你會得到一個錯誤。你的其他代碼已經死了。這是我的一個項目的一個實例。這會在執行mvn package後執行打包在目標目錄中的jar。如果仍然出現相同的錯誤,我會嘗試從本地存儲庫中刪除插件以獲取全新副本。還要確保插件不在pluginsManagement元素中。如果失敗,請發佈您的整個POM。

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.1.1</version> 
    <executions> 
     <execution> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <executable>java</executable> 
     <workingDirectory>/target</workingDirectory>    
     <arguments> 
      <argument>-jar</argument> 
      <argument>${project.build.directory}/${project.build.finalName}.jar</argument> 
     </arguments>   
    </configuration> 
</plugin> 
+0

我遇到同樣的問題,因爲它在`pluginsManagement`而不是`plugins`中。 – Sydney 2011-04-22 20:41:53