2012-07-13 38 views
3

我怎麼能「放」的命令行參數從pom.xml中被執行。 比如我有:如何將maven命令行「放」到pom.xml中?

mvn clean install -Dmyparameter 

而且我希望它從pom.xml的,而不是從命令行執行。

+0

http://maven.40175.n5.nabble.com/Overriding-properties-from-command-line-arguments-td3345432.html – aProgrammer 2012-07-13 06:42:04

+0

您正在使用哪個IDE? – aProgrammer 2012-07-13 06:44:47

+0

你想在你的POM中定義[屬性](http://maven.apache.org/pom.html#Properties)? – Raghuram 2012-07-13 07:42:42

回答

4

這取決於您需要使用哪個階段的參數。它可以通過更改配置參數在插件上完成。

<pluginManagement> 
    <plugin> 
     ...... 
     ...... 
     <artifactId>maven-release-plugin</artifactId> 
     <configuration> 
      <arguments>-Dmaven.test.skip=true -D[other arguments that u need to include]</arguments> 
     </configuration> 
     ...... 
     ...... 
</plugin> </pluginManagement> 

同樣的方式在肯定火的插件ü可以跳過測試等!

4

你可以嘗試用maven-EXEC-插件:

mvn clean install exec:exec -Dexecutable=<absolute path to binary> 

此外,它可以綁定到生命週期的某些階段生成的中間被執行(不經EXEC顯式調用:EXEC)並在配置文件中進行了定義,如果屬性存在可以選擇運行:

<profiles> 
    <profile> 
    <id>exec</id> 
    <activation> 
     <property> 
     <name>executable</name> 
     </property> 
    </activation> 
    <plugins> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>exec-maven-plugin</artifactId> 
     <version>1.2.1</version> 
     <executions> 
      <execution> 
      <id>exec</id> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      <phase>package</phase> 
      </execution> 
     </executions> 
     <configuration> 
      <executable>${executable}</executable> 
     </configuration> 
     </plugin> 
    </plugins> 
    </profile> 
</profiles> 
相關問題