2017-03-07 70 views
2

如何更改插件的版本在命令行沒有更改pom.xml?從命令行覆蓋Maven插件版本?

更具體地說:

我不能編譯Apache四郎提交8dd6a13。原因是buildnumber-maven-plugin版本1.0-beta-4不再可用。 當我修改pom.xml並將插件版本更改爲1.0時,我可以編譯該項目。 我想保持項目不變,只需在命令行運行mvn時設置插件的版本即可。 我感謝任何見解和幫助。

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>buildnumber-maven-plugin</artifactId> 
      <version>1.0-beta-4</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>create</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <doCheck>false</doCheck> 
       <doUpdate>false</doUpdate> 
      </configuration> 
     </plugin> 
+0

也許您正在尋找這樣的:現在

<properties> <buildnumber.version>1.0-beta-4</buildnumber.version> </properties> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>${buildnumber.version}</version> ... <plugin> <plugins> <build> 

你可以運行,例如。 http://stackoverflow.com/questions/4660047/override-maven-plugin-configuration-defined-in-the-pom-pluginmanagement-from-the –

+0

該版本可用於[Maven Central](http:// search。 maven.org/#search|gav|1|g%3A%22org.codehaus.mojo%22%20AND%20a%3A%22buildnumber-maven-plugin%22),導致版本是不可變的,這意味着它們永遠不會被刪除。所以在你的本地設置中一定有問題。 – khmarbaise

回答

3

您可以使用maven屬性來設置默認版本,當您從命令行運行時,您將有可能覆蓋它。在命令行行家

mvn clen install -Dbuildnumber.version=1.0 

沒有設置屬性將使用默認的pom.xml的