【问题标题】:maven-invoker doesn't call install on dependencymaven-invoker 不会根据依赖调用安装
【发布时间】:2013-02-05 12:12:49
【问题描述】:

我在我的 Maven 构建过程中遇到了问题。有一个使用 maven-invoker-plugin 执行不同任务的 pom 文件:

<execution>
<id>createWebstartApps</id>

<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<projectsDirectory>.</projectsDirectory>
<streamLogs>true</streamLogs>
<pomIncludes>
    <pomInclude>pom1.xml</pomInclude>
</pomIncludes>
....

但是当我使用 maven 发布插件“mvn release:prepare”时,安装目标不会在子 pom 依赖项上执行。例如 pom1.xml 有以下依赖:

<dependency>
<groupId>com.qnamic.dis</groupId>
<artifactId>DisAdminToolWithPlugins</artifactId>
<version>${project.parent.version}</version>
<type>pom</type>
<scope>runtime</scope>
.....

但是这个依赖项(在这种情况下是 pom 文件)不会安装在我的本地 maven repo 中,因此找不到:

  [INFO] [INFO] Building: pomWebstartDisAdminTool.xml
[INFO] [INFO] [INFO] Scanning for projects...
[INFO] [INFO] [INFO]
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [INFO] Building RailOpt DIS Admin Tool 4.9.12
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [WARNING] The POM for com.qnamic.dis:DisAdminToolWithPlugins:pom:4.9.12 is missing, no dependency information available
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [INFO] BUILD FAILURE
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [INFO] Total time: 0.203s
[INFO] [INFO] [INFO] Finished at: Tue Feb 05 13:00:04 CET 2013
[INFO] [INFO] [INFO] Final Memory: 4M/15M
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [ERROR] Failed to execute goal on project DisAdminToolWebstart: Could not resolve dependencies for project com.qnamic.dis:DisAdminToolWebstart:pom:4.9.12: Failure to find com.qnamic.dis:DisAdminToolWithPlugins:pom:4.9.12 in http://maven.ad.bls.ch/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of bls-public has elapsed or updates are forced -> [Help 1]

有什么想法吗?

问候

【问题讨论】:

  • 你为什么要使用 maven-invoker 来执行其他在 Maven 中通常不存在的任务。你想达到什么目的?您应该考虑配置 maven-inovker-plugin 的 extraArtifacts。
  • 嗨!我无法回答您的问题,因为这是现有(旧)代码,我只是想让它再次构建。我也认为应该有更好的方法来做到这一点..但我不是专家:-/我也乐于接受新想法

标签: maven build maven-3 maven-release-plugin


【解决方案1】:

尝试在运行前添加安装。例如。

<execution>
  <id>createWebstartApps</id>
  <phase>process-resources</phase>
  <goals>
    <goal>install</goal>
    <goal>run</goal>
  </goals>
...

欲了解更多信息:http://maven.apache.org/plugins/maven-invoker-plugin/install-mojo.html & http://maven.apache.org/plugins/maven-invoker-plugin/usage.html

HTH, 杰米

【讨论】:

  • 我昨天已经试过了。今天又一次,现在它工作了!也许我在配置中也有其他改变......谢谢!
  • Eclipse 现在告诉我以下信息:生命周期配置未涵盖插件执行:org.apache.maven.plugins:maven-invoker-plugin:1.6:install(执行:createWebstartApps,阶段:process-resources )。 Maven 可以工作,但 Eclipse 在这个配置上存在某种问题
  • 对我来说听起来并不完全合乎逻辑。 Eclipse 只是调用 Maven。难道是Eclipse&从命令行调用的版本不一样?
【解决方案2】:

在 pom.xml 旁边添加文件 invoker.properties 并把你的目标放进去,比如:

invoker.goals = clean install

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-15
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    相关资源
    最近更新 更多