【问题标题】:Maven build error - Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5Maven 构建错误 - 无法执行目标 org.apache.maven.plugins:maven-assembly-plugin:2.5.5
【发布时间】:2015-08-23 22:11:31
【问题描述】:

我正在尝试使用 Maven 构建项目。不幸的是我没有使用maven的经验,所以我有点无助。它很可能是由 riak 子模块引起的。这是带有代码的 github 存储库:YCSB

我的系统:

Apache Maven 3.2.2 (NON-CANONICAL_2015-04-01T06:56:20_mockbuild; 2015-04-01T08:56:20+02:00)
Maven home: /usr/share/maven
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-4.b16.fc21.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.1.5-100.fc21.x86_64", arch: "amd64", family: "unix"

Maven 堆栈跟踪:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project ycsb: Failed to create assembly: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project ycsb: Failed to create assembly: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create assembly: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.
    at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:541)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.apache.maven.plugin.assembly.archive.ArchiveCreationException: Artifact: com.yahoo.ycsb:riak-binding:jar:0.3.1-RC1-SNAPSHOT (included by module) does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.
    at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase.addModuleArtifact(ModuleSetAssemblyPhase.java:337)
    at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase.addModuleBinaries(ModuleSetAssemblyPhase.java:231)
    at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase$1.accept(ModuleSetAssemblyPhase.java:140)
    at org.apache.maven.plugin.assembly.model.Assemblies.forEachModuleSet(Assemblies.java:40)
    at org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase.execute(ModuleSetAssemblyPhase.java:126)
    at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:178)
    at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:484)
    ... 21 more
[ERROR] 
[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/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ycsb

我不知道这意味着什么,所以我猜你是我唯一的希望:D

编辑: 添加 Subodh Joshi 建议的插件后:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project binding-parent: Failed to create assembly: Error creating assembly archive jar-with-dependencies: You must set at least one file.

编辑2: mvn compile 工作正常,但 mvn package 失败并出现上述错误。

【问题讨论】:

    标签: java maven build


    【解决方案1】:

    您必须在您的pom.xml 文件中添加maven-assembly-plugin

     <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <configuration>
            <archive>
              <manifest>
                <mainClass>com.test.MainClassName</mainClass>
              </manifest>
            </archive>
            <descriptorRefs>
              <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
          </configuration>
          <executions>
            <execution>
              <id>make-assembly</id> 
              <phase>package</phase> <!-- packaging phase -->
              <goals>
                <goal>single</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
    

    【讨论】:

    • 哪一个?项目根目录中的那个还是riak模块中的那个?
    • pom.xml 文件中添加此命令后,您是否运行了mvn 命令
    • 我不明白你的意思。
    • 我确实跑了mvn package
    • 在您的 pom 文件中添加此内容后,您是否运行了mvn clean install 或任何其他命令
    【解决方案2】:

    当我尝试使用 Netbeans 12.0 OpenJDK 15 时,我需要导入一些我使用 OracleJDK 8u231 开发的库项目 (.jar) 以进行一些代码测试;结果与问题类似:

     Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-assembly) 
    on project rgbfw-as-core-db: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single 
    failed: An API incompatibility was encountered while executing 
    org.apache.maven.plugins:maven-assembly-plugin:2.6:single: java.lang.ExceptionInInitializerError: null
    

    对我来说,解决方案是在我的库项目(.jar)上更新“maven-compiler-plugin”和“maven-assembly-plugin”的版本,然后再重新运行 Netbeans 的“清理和构建”项目探索者。 当前版本:

    maven-compiler-plugin(3.8.1)

    maven-assembly-plugin(3.3.0)

    【讨论】:

      猜你喜欢
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 2018-11-13
      • 2017-07-20
      • 1970-01-01
      • 2022-08-10
      • 1970-01-01
      相关资源
      最近更新 更多