Maven Install插件:参数文件丢失或无效 [英] Maven Install plugin: parameter file is missing or invalid

查看:207
本文介绍了Maven Install插件:参数文件丢失或无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本地jar,我想在我的项目中使用它。有很多方法可以做到:只需手动安装到本地仓库,使用父pom中的脚本,使用系统范围,使用本地repo声明。

I have a local jar and I want to use it in my project. There are plenty ways to do it: just install manually into local repo, do it with script in parent pom, use system scope, use local repo declaration.

我决定使用Maven Install插件将jar安装到repo中。这是一个配置:

I decided to use Maven Install plugin to install jar into the repo. Here is a configuration:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
            <execution>
                <phase>initialize</phase>
                <goals>
                    <goal>install-file</goal>
                </goals>
                <configuration>
                    <groupId>jacob</groupId>
                    <artifactId>jacob</artifactId>
                    <version>1.0</version>
                    <packaging>jar</packaging>
                    <file>${basedir}\lib\jacob.jar</file>
                </configuration>
            </execution>
        </executions>
    </plugin>

我试图以多种方式运行它:
mvn initialize install:install -file
mvn初始化
mvn install:install-file

I tried to run it in many ways: mvn initialize install:install-file mvn initialize mvn install:install-file

但是我一直有例外:


[错误]无法执行目标
org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file项目MYPROJECTNAME上的
(default-cli):目标
的参数'file'org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file是
遗失或无效 - >

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project MYPROJECTNAME: The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file are missing or invalid ->

我只是想知道为什么它不起作用?看起来我被阶段和目标弄糊涂了..

I just want to find out why it doesn't work? Looks like I am messed with phases and goals..

最后我走了另一条道路:我将它放入我的父POM中,但为什么它与父母一起工作而不是与孩子一起工作?

Finally I went another way: I placed it into my parent POM, but why it works with parent and doesn't work with child?

推荐答案

处理分离jar的最佳方法是开始使用存储库管理器并通过以下方式安装此jar UI进入存储库管理器。从那时起,您可以将其用作通常的依赖关系。让生活变得更轻松。

The best way to deal with a separated jar is to start using a repository manager and install this jar via the UI into the repository manager. From that point you can use as a usual dependency. Makes life easier.

如果您想将它作为构建的一部分安装,您尝试过这意味着您需要像这样调用maven:

If you like to install it as part of the build what you have tried that means you need to call maven like this:

mvn package

你不应混淆调用目标,如 install:install-file ,生命周期部分为 initialize

You should not mix up calling goals without life cylce like install:install-file with life-cycle parts as initialize.

这就是为什么你得到描述的错误信息,导致命令行部分需要您在命令行中未提供的必需参数

That is the reason why you got the described error message, cause the command line part needs required parameters which you didn't gave on command line.

组合如:

mvn install:install-file initialize

让Maven毫无意义(rarly)。你已经将maven-install-plugin绑定到pom中的life-clycle,所以你应该简单地调用life cylce:

Make in Maven no sense (rarly). You have bound the maven-install-plugin to the life-clycle in your pom so you should simply call the life cylce:

mvn initalize

您将获得以下内容:

[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install-file (default) @ test ---
[INFO] Installing /home/mvntest/lib/jdom-1.0.jar to /home/.m2/repository/com/soebes/test/jacob/1.1/jacob-1.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.780s
[INFO] Finished at: Sat Oct 25 12:19:30 CEST 2014
[INFO] Final Memory: 6M/91M
[INFO] ------------------------------------------------------------------------

但是:我不得不说像你那样安装一件神器是不好的做法。最好是使用像 Nexus 这样的存储库管理器, Artifactory Archiva 或如果真的不喜欢存储库管理器(我不明白为什么,但这是一个不同的故事)你可以使用 Stephen Connolly的非maven-jar-maven-plugin

BUT: I have to say that installing an artifact like you did is bad practice. Best is to use a repository manager like Nexus, Artifactory or Archiva or if really don't like repository managers (I don't understand why, but this is a different story) you can use Stephen Connolly's non-maven-jar-maven-plugin

除上述所有内容外,你应该使用更多 - maven-install-plugin的当前版本号为2.5.2 的日期版本

Apart from all the above you should use more up-to-date versions of maven-install-plugin which current version number is 2.5.2

这篇关于Maven Install插件:参数文件丢失或无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆