简体   繁体   English

Maven Install插件:参数文件丢失或无效

[英]Maven Install plugin: parameter file is missing or invalid

I have a local jar and I want to use it in my project. 我有一个本地jar,我想在我的项目中使用它。 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. 有很多方法可以做到:只需手动安装到本地仓库,使用父pom中的脚本,使用系统范围,使用本地repo声明。

I decided to use Maven Install plugin to install jar into the repo. 我决定使用Maven Install插件将jar安装到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>

I tried to run it in many ways: mvn initialize install:install-file mvn initialize mvn install:install-file 我尝试以多种方式运行它: mvn初始化安装:install-file mvn initialize mvn install:install-file

But all the time I have an exception: 但是我一直有例外:

[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 -> [错误]无法执行目标org.apache.maven.plugins:maven-install-plugin:2.3.1:项目上的install-file(default-cli)MYPROJECTNAME:目标org.apache.maven的参数'file'。插件:maven-install-plugin:2.3.1:安装文件丢失或无效 - >

I just want to find out why it doesn't work? 我只想找出它为什么不起作用? Looks like I am messed with phases and goals.. 看起来我被阶段和目标弄糊涂了..

Finally I went another way: I placed it into my parent POM, but why it works with parent and doesn't work with child? 最后,我采用了另一种方式:我将它放入我的父POM中,但为什么它与父母一起使用并且不能与孩子一起工作?

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. 处理分离jar的最佳方法是开始使用存储库管理器,并通过UI将此jar安装到存储库管理器中。 From that point you can use as a usual dependency. 从那时起,您可以将其用作通常的依赖项。 Makes life easier. 让生活更轻松。

If you like to install it as part of the build what you have tried that means you need to call maven like this: 如果您想将它作为构建的一部分安装,您尝试过这意味着您需要像这样调用maven:

mvn package

You should not mix up calling goals without life cylce like install:install-file with life-cycle parts as initialize . 你不应该将没有生命周期的调用目标混淆,例如install:install-file其中生命周期部分为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. 这就是为什么你得到描述的错误消息,导致命令行部分需要你在命令行上没有给出的必需参数

Combination like: 组合如:

mvn install:install-file initialize

Make in Maven no sense (rarly). 让Maven毫无意义(rarly)。 You have bound the maven-install-plugin to the life-clycle in your pom so you should simply call the life cylce: 你已经将maven-install-plugin绑定到pom中的life-clycle,所以你应该简单地调用life cylce:

mvn initalize

And you will get something like the following: 你会得到类似以下的东西:

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

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 最好是使用像NexusArtifactoryArchiva这样的存储库管理器,或者如果真的不喜欢存储库管理器(我不明白为什么,但这是一个不同的故事)你可以使用Stephen Connolly的非maven-jar-maven-插入

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-plugin版本,当前版本号为2.5.2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 目标 org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file 的参数“文件”丢失或无效 - The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file are missing or invalid Maven 执行器插件丢失或无效的规则 - Maven enforcer plugin missing or invalid rules Maven Jetty插件stopPort和stopKey丢失或无效 - Maven Jetty plugin stopPort and stopKey missing or invalid Maven许可证插件:参数“ organizationName”,…丢失或无效 - Maven License Plugin: The parameters 'organizationName', … are missing or invalid maven插件安装:安装文件错误 - maven plugin install:install-file error 目标 org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file 的参数“url”丢失或无效 - The parameters 'url' for goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file are missing or invalid 无法在项目上执行目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:exec(默认):参数“可执行文件”丢失或无效 - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default) on project ors: The parameter 'executable' is missing or invalid 使用Maven程序集插件检测缺少的包含文件 - Detecting missing included file with Maven assembly plugin maven安装文件“缺少工件” - maven install-file “Missing artifact” 参数&#39;sourceEncoding&#39;rpm -maven-plugin缺失或无效 - The parameters 'sourceEncoding' rpm-maven-plugin are missing or invalid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM