java Maven 插件安装:安装文件错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10944543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
maven plugin install:install-file error
提问by plucury
I use install:install-file to install jar to my local repository.My pom.xml is written as follow:
我使用 install:install-file 将 jar 安装到我的本地存储库。我的 pom.xml 编写如下:
<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>
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:
你会发现我将它绑定到阶段 'generate-resources'。然后,我使用 order 。mvn eclipse:eclipse
它工作得很好,jar 被复制到我的本地存储库。但是当我使用 order 时,mvn install:install-file
我得到了错误:
[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]
The error messages when use mvn compile
使用时的错误信息 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
回答by Raghuram
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.
由于您已将install:install-file
目标绑定到generate-sources
阶段,因此您应该运行mvn compile
或mvn install
使用定义的配置。
mvn eclipse:eclipse
works because maven runs the generate-sources
phase prior to invoking eclipse:eclipse
.
mvn eclipse:eclipse
之所以有效,是因为 Mavengenerate-sources
在调用eclipse:eclipse
.
Edit: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.
编辑:从评论看来,您似乎希望paho.jar
通过首先将其安装到generate-sources
阶段中的本地存储库,然后将其用作dependency
项目中的a来使用项目中本地可用的。
This is not going to work since maven checks for availability of dependencies
before it starts executing its life-cycle goals.
这是行不通的,因为 Mavendependencies
在开始执行其生命周期目标之前会检查 的可用性。
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.
您可以mvn install:install-file
在 pom 的上下文之外手动安装它一次。更好的是,您可以将它部署到 arepository manager
然后像任何其他依赖项一样访问它。
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.
但是,如果您仍然想沿着这条路径走下去,另一种方法是使用system
提供 jar 路径的范围来指定依赖项。参考这个。
<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>