【问题标题】:How do I force Maven to use maven-install-plugin version 2.5?如何强制 Maven 使用 maven-install-plugin 2.5 版?
【发布时间】:2014-09-29 02:36:07
【问题描述】:

我想使用 maven-install-plugin 将几个 jars 安装到我的本地 maven repo。我的 maven 3.2.1 安装使用这个插件的 2.4 版本,它需要很多参数来指定。如http://maven.apache.org/plugins/maven-install-plugin/usage.html 所述,我想使用需要较少参数的2.5 版。如果我从具有以下 pom.xml 文件的文件夹中运行 mvn install:install-file,则它使用 2.5 版:

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

否则,它仍然使用旧插件。如何强制 Maven 使用 maven-install-plugin 2.5 版(如果我从任何文件夹运行 install-file)?

附: How to install third party source and javadoc JARs? 不包含答案。

【问题讨论】:

  • 你能提供给我们你的完整 pom 吗?
  • 我在我的帖子中添加了来自 pom.xml 的更多 xml 节点。其他 pom 设置是通用的。
  • 在命令mvn groupId:artifactId:version:goal中使用版本。
  • 您必须指定不在&lt;pluginManagement&gt; 标签中的插件。相反,它应该在您的 &lt;build&gt; 标签中。
  • 运行mvn org.apache.maven.plugins:maven-install-plugin:2.5:install-file

标签: maven maven-install-plugin


【解决方案1】:

在 cmets 中回答:

运行 mvn org.apache.maven.plugins:maven-install-plugin:2.5:install-file。 – Aleksandr M 2014 年 8 月 8 日 8:47

澄清:

Aleksandr M 表示这可以使用 maven-install-plugin 的 install-file 目标实现。这要求您使用-file 标志指定要安装的文件。这在 maven documentation 中有更详细的解释。

【讨论】:

    【解决方案2】:

    另一种选择是在项目的pom.xml 中使用 2.5.x 版本声明 maven-install-plugin -

    <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>
    

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多