我的 Maven 构建过程中遇到问题。有一个 pom 文件使用 maven-invoker-plugin 来执行不同的任务:
<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 存储库中,因此找不到:
[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]
有什么想法吗?
问候
尝试在运行前添加安装。例如。
<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/用法.html
HTH, 杰米
在 pom.xml 旁边添加文件 invoker.properties 并将您的目标放入其中,例如:
invoker.goals = clean install
如果无法解析的依赖项是内部依赖项,即项目中的另一个模块,那么您可以通过将
<extraArtifacts>
配置添加到 pom.xml
中的调用程序插件配置来解决此问题。
例如,这是我的一个开源项目之一:
<extraArtifacts>
<extraArtifact>com.github.rvesse:airline:${airline.version}:jar:tests</extraArtifact>
<extraArtifact>com.github.rvesse:airline-examples:${airline.version}:jar</extraArtifact>
</extraArtifacts>
其中
airline.version
恰好是我根据 project.version
设置的属性
这告诉调用者插件
install
将这些依赖项放入本地集成测试存储库,确保它们可用于您的集成测试。