Maven插件安装:安装文件错误 [英] maven plugin install:install-file error
问题描述
我使用install:install-file将jar安装到本地存储库.我的pom.xml编写如下:
I use install:install-file to install jar to my local repository.My pom.xml is written as follow:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-paho</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/paho.jar</file>
<groupId>org.eclipse</groupId>
<artifactId>paho</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
您会发现我将其绑定到阶段'generate-resources'.然后,我使用订单mvn eclipse:eclipse
.它工作得很好,罐子已复制到我的本地存储库.但是当我使用订单mvn install:install-file
时,我得到了错误:
You can find that I binding it to phase 'generate-resources'.And then,I use order mvn eclipse:eclipse
.It works very well and the jar was copied to my local repository.But when I use order mvn install:install-file
I got the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project xxx:
The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file are missing or invalid -> [Help 1]
使用mvn compile
[ERROR] Failed to execute goal on project android-engine: Could not resolve dependencies for project com.youku.wireless:android-engine:jar:1.0-SNAPSHOT: Could not find artifact org.eclipse:paho:jar:1.0.0 in spring-milestone (http://maven.springframework.org/milestone) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
推荐答案
由于已将install:install-file
目标绑定到generate-sources
阶段,因此应运行mvn compile
或mvn install
等以使用定义的配置.
Since you have bound install:install-file
goal to the generate-sources
phase, you should run mvn compile
or mvn install
or such to use the defined configurations.
mvn eclipse:eclipse
之所以有效,是因为maven在调用eclipse:eclipse
之前先运行generate-sources
阶段.
mvn eclipse:eclipse
works because maven runs the generate-sources
phase prior to invoking eclipse:eclipse
.
编辑:通过注释,您似乎想在项目中使用本地可用的paho.jar
,方法是先在generate-sources
阶段将其安装到本地仓库中,然后将其用作项目中的dependency
.
From the comments it looks like you want to use the locally available paho.jar
in your project by first installing it to your local repo in the generate-sources
phase and thereafter use it as a dependency
in your project.
这行不通,因为maven在开始执行其生命周期目标之前先检查dependencies
的可用性.
This is not going to work since maven checks for availability of dependencies
before it starts executing its life-cycle goals.
您可以在pom上下文之外使用mvn install:install-file
一次手动安装它.更好的是,您可以将其部署到repository manager
,然后像其他任何依赖项一样对其进行访问.
You could manually install it one-time using mvn install:install-file
outside the context of the pom. Better still you could deploy it to a repository manager
and then access it like any other dependency.
但是,如果您仍然想沿着这条路走,另一种方法是使用提供了jar路径的system
范围指定依赖项.请参考此.
However, if you still want to go down this path, an alternate approach would be to specify the dependency with a system
scope providing the path of the jar. Refer to this.
<project>
...
<dependencies>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>paho</artifactId>
<version>1.0.0/version>
<scope>system</scope>
<systemPath>${basedir}/lib/paho.jar</systemPath>
</dependency>
</dependencies>
...
</project>
这篇关于Maven插件安装:安装文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!