maven-2 - Maven : unable to install 3rd party jar

标签 maven-2

尝试将第 3 方 jar 安装到我的存储库 (alfresco-repository.jar) 中。我正在使用以下命令:

mvn install:install-file -DgroupId=alfresco -DartifactId=alfresco -Dversion=3.1 -Dpackaging=jar "-Dfile=C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar" -DgeneratePom=true -e

并且我收到以下异常(-e 用于获取更多信息):

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task '.1': you must specify a valid lifecycle phase, or a goal in
 the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Invalid task '.1': you must specify a va
lid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:plugin
ArtifactId:pluginVersion:goal
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor
(DefaultLifecycleExecutor.java:1830)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListBy
AggregationNeeds(DefaultLifecycleExecutor.java:462)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:175)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

最佳答案

问题在于您在错误的位置使用了双引号 ("),有时甚至根本没有使用。您应该在所有参数值周围使用双引号。例如...

"-Dfile=C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar"

...应该是...

-Dfile="C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar"

...还有...

-Dversion=3.1

...应该是...

-Dversion="3.1"

不同操作系统的不同命令行对第一个版本的处理会不一致,但如果仅用双引号将每个参数的引起来,则每次都会获得所需的行为。您的整个命令应如下所示...

mvn install:install-file -DgroupId="alfresco" -DartifactId="alfresco" -Dversion="3.1" -Dpackaging="jar" -Dfile="C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar" -DgeneratePom="true" -e

我承认并不是所有人都需要这样做,但这是一个好习惯。

关于maven-2 - Maven : unable to install 3rd party jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2470611/

相关文章:

java - Maven - 聚合的 'all' 或 'parent' 项目?

groovy - 如何使用登录凭据丰富 "GrabResolver"

maven-2 - 自定义 maven 组件

gwt - 目标 org.codehaus.mojo :gwt-maven-plugin:2. 5.0:run 的参数 'runTarget' 丢失或无效

java - 使用 FailSafe 和 SureFire 插件并行运行 JUnit 4 测试

java - 我的 Maven 配置有什么问题?

maven-2 - Exec 战前目标存档包

java - Maven 配置文件 - 无需子项目即可构建

java - 马文 : avoid deploying project package-implied artifact during standard build lifecycle

maven-2 - 使用 Maven 将 XSD 包含在 Jar 中?