How do I force Maven to use maven-install-plugin version 2.5?

社会主义新天地 提交于 2019-12-21 16:48:11

问题


I want to install few jars to my local maven repo with maven-install-plugin. My maven 3.2.1 installation uses version 2.4 of this plugin which requires a lot of parameters to specify. I would like to use version 2.5 that requires less parameters, as mentioned on http://maven.apache.org/plugins/maven-install-plugin/usage.html. If I run mvn install:install-file from the folder that has a pom.xml file with the following, then it uses version 2.5:

<pluginManagement>
 <plugins>
   <plugin>
       <artifactId>maven-install-plugin</artifactId>
       <version>2.5</version>
   </plugin>
 </plugins>

Otherwise, it still uses the old plugin. How do I force Maven to use maven-install-plugin version 2.5 (if I run install-file from any folder)?

P.S. How to install third party source and javadoc JARs? does not contain the answer.


回答1:


Answered in comments:

Run mvn org.apache.maven.plugins:maven-install-plugin:2.5:install-file. – Aleksandr M Aug 8 '14 at 8:47

Clarification:

Aleksandr M means that this is possible using the install-file goal of the maven-install-plugin. This requires you to specify the file to be installed using the -file flag. This is explained in more detail in the maven documentation.




回答2:


Another alternative is to declare maven-install-plugin with 2.5.x version inside project's pom.xml -

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
            <executions>
                <execution>
                    <id>default-install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>install</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


来源:https://stackoverflow.com/questions/25155639/how-do-i-force-maven-to-use-maven-install-plugin-version-2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!