我在Mac 10.6.6上使用Maven 3.0.3。我有一个JAR项目,当我运行命令"mvn clean install:install“时,我得到了错误,
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-cli) on project StarTeamCollisionUtil: The packaging for this project did not assign a file to the build artifact -> [Help 1]这意味着什么,我如何才能修复它?下面是我的pom.xml。让我知道有哪些其他信息会有帮助,我会编辑这篇文章。谢谢,-戴夫
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myco.starteam.util</groupId>
<artifactId>StarTeamCollisionUtil</artifactId>
<packaging>jar</packaging>
<name>StarTeam Collision Util</name>
<description>
The StarTeam Collision Utility provides developers and release engineers alike the ability to
compare files attached to a set of CRs to see if conflicts exist in the change set.
</description>
<version>1.0-SNAPSHOT</version>
<url>http://cm-build.myco.com:8080/hudson/view/Tools/job/StarTeamCollisionUtil - TRUNK/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>myco-sonatype-nexus-snapshots</id>
<name>MyCo Sonatype-Nexus Snapshots</name>
<url>http://sonatype.myco.com/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>starteam</groupId>
<artifactId>starteam</artifactId>
<version>1.1.0</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${basedir}/lib/starteam110.jar</systemPath>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-3</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<linksource>true</linksource>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.3.1</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<report>dependencies</report>
<report>dependency-management</report>
<report>cim</report>
<report>issue-tracking</report>
<report>license</report>
<report>scm</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>sonatype-nexus</id>
<url>http://sonatype.myco.com/nexus/content/repositories/snapshots/</url>
</repository>
</distributionManagement>
<scm>
<url>https://starteam.cmass.myco.com/BorlandStarTeam/BorlandStarTeam.jsp</url>
</scm>
<issueManagement>
<system>StarTeam</system>
<url>https://starteam.cmass.myco.com/BorlandStarTeam/BorlandStarTeam.jsp</url>
</issueManagement>
<ciManagement>
<system>Hudson</system>
<url>http://cm-build.myco.com:8080/hudson/</url>
</ciManagement>
</project>发布于 2011-06-11 04:27:48
我不知道这是不是答案,但它可能会引导你走向正确的方向……
命令install:install实际上是maven-install-plugin上的一个目标。这与install maven生命周期阶段不同。
Maven lifecycle phases是构建中的步骤,某些插件可以将自己绑定到该构建中。当您调用单个生命周期阶段时,来自不同插件的许多不同目标可能会执行。
归根结底就是命令...
mvn clean install不同于...
mvn clean install:install前者将在安装之前的每个周期中运行所有目标(如编译、打包、测试等)。后者甚至不会编译或打包你的代码,它只会运行一个目标。这是有意义的,看一下异常;它谈到了:
StarTeamCollisionUtil:此项目的打包未将文件分配给生成项目
试一试前者,你的错误可能就会消失!
发布于 2016-07-01 22:38:44
TL;DR要解决此问题,请在之前调用打包插件,例如,对于jar打包,请使用maven-jar-plugin,如下所示:
mvn jar:jar install:install或
mvn jar:jar deploy:deploy 如果你真的需要部署。
如果你的多模块项目有不同的包(ear/war/jar/),这种方法将不起作用--更糟糕的是,错误的工件会被安装/部署!在这种情况下,使用reactor选项仅构建可部署的模块(例如war)。
说明
在某些情况下,您实际上希望直接运行install:install或deploy:deploy目标(即,从maven-deploy-plugin、deploy目标,而不是Maven deploy phase),并且最终会运行令人讨厌的The packaging for this project did not assign a file to the build artifact。
一个典型的例子就是CI工作( Jenkins或竹子工作,例如)在不同的步骤中,你想要执行/关注不同的方面:
mvn clean install,执行测试和测试覆盖率mvn sonar:sonar加上进一步的optionsmvn deploy,因为它将再次执行前面的阶段(以及编译、测试等)。你希望你的构建是有效的,但是fast.是的,你可以加快这最后一步,至少跳过测试(编译和执行,通过-Dmaven.test.skip=true)或使用特定的配置文件(跳过尽可能多的插件),但简单地运行mvn deploy:deploy会更容易和清晰。
但它将失败,并显示上面的错误,因为还指定了by the plugin FAQ
打包阶段的所有
都收集并放置在上下文中。通过这种机制,Maven可以确保
maven-install-plugin和maven-deploy-plugin正在复制/上传相同的文件集。因此,当您只执行deploy:deploy时,就不会在上下文中放入任何文件,也就没有什么要部署的。
实际上,deploy:deploy需要一些由先前阶段(或先前的插件/目标执行)放置在构建上下文中的运行时信息。
它还被报告为一个潜在的错误: Maven : deploy:deploy不适用于仅将工件部署到远程存储库
但后来被拒绝了,认为这不是问题。
maven-deploy-plugin的deployAtEnd配置选项在某些情况下也不会有帮助,因为我们有中间作业步骤要执行:
每个项目是应该在其自己的部署阶段部署,还是在多模块构建结束时部署。如果设置为
true且构建失败,则不会部署任何反应器项目。(实验性)
那么,如何修复它呢?
只需在类似的第三步/最后一步中运行以下命令:
mvn jar:jar deploy:deploymaven-jar-plugin不会在构建过程中重新创建任何jar,这要归功于它的forceCreation选项默认设置为false:
需要jar插件来构建新的JAR,即使所有内容似乎都没有更改。默认情况下,此插件查看输出jar是否存在以及输入是否未更改。如果这些条件成立,插件将跳过jar的创建。
但它将很好地填充我们的构建上下文,并使deploy:deploy满意。没有要跳过的测试,没有要添加的配置文件。这正是您需要的:速度。
补充说明:如果您正在使用build-helper-maven-plugin、buildnumber-maven-plugin或任何其他类似的插件来生成稍后由maven-jar-plugin使用的元数据(例如,清单文件的条目),那么您很可能有链接到validate阶段的执行,并且您仍然希望在jar:jar构建步骤中使用它们(同时保持快速执行)。在这种情况下,调用validate phase的开销几乎是无害的,如下所示:
mvn validate jar:jar deploy:deploy另一个额外的注意事项:如果您没有安装,而是war打包,那么在安装/部署之前使用war:war。
Gotcha如上所述,检查多模块项目中的行为。
发布于 2012-02-16 05:55:48
我也有同样的问题。我收到的错误消息不完整。但在我的例子中,我添加了带源代码的生成jar。通过将以下代码放在pom.xml中:
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>因此,在部署阶段,我执行source:jar sources,它会生成包含源代码的jar。并在构建成功后结束部署
https://stackoverflow.com/questions/6308162
复制相似问题