【问题标题】:maven build fails returns execution is : '127'maven 构建失败返回执行是:'127'
【发布时间】:2017-12-07 17:14:53
【问题描述】:

我正在尝试使用 exec-maven-plugin 重命名工件。 (我不想使用 antrun 插件,因为我在同一阶段和目标中将其用于不同的目的。)

pom.xml 中的插件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
      <execution>
        <id>some-execution</id>
        <phase>package</phase>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>mv "${project.build.directory}/${project.artifactId}-${project.version}-myapp.jar" "${project.build.directory}/${project.artifactId}-${project.version}.app"</executable>
    </configuration>
  </plugin>

它无法重命名工件并给出以下错误:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:exec (some-execution) on project cep: Result of /bin/sh -c cd /home/XYZ/workspace/myapp/solutions/cep && "mv "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT-myapp.jar" "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT.app"" **execution is: '127'**. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:exec (some-execution) on project cep: Result of /bin/sh -c cd /home/XYZ/workspace/myapp/solutions/cep && "mv "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT-myapp.jar" "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT.app"" execution is: '127'.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    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:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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: Result of /bin/sh -c cd /home/XYZ/workspace/myapp/solutions/cep && "mv "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT-myapp.jar" "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT.app"" execution is: '127'.
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:283)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)

调试日志:

[DEBUG] Configuring mojo org.codehaus.mojo:exec-maven-plugin:1.1.1:exec from plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:1.1.1, parent: sun.misc.Launcher$AppClassLoader@762589c3]
[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.1.1:exec' with basic configurator -->
[DEBUG]   (f) basedir = /home/XYZ/workspace/myapp/solutions/cep
[DEBUG]   (f) classpathScope = compile
[DEBUG]   (f) executable = mv "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT-myapp.jar" "/home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT.app"
[DEBUG]   (f) project = MavenProject: com.myco:cep:0.1.0-SNAPSHOT @ /home/XYZ/workspace/myapp/solutions/cep/pom.xml
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@2b46c61f
[DEBUG]   (f) skip = false
[DEBUG] -- end configuration --
[INFO] /bin/sh: 1: mv /home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT-myapp.jar /home/XYZ/workspace/myapp/solutions/cep/target/cep-0.1.0-SNAPSHOT.app: **not found**

从这些日志中,我确定缺少某些内容,但我无法找出是什么。我的操作系统是 ubuntu /bin/sh 可用。 ls 还会列出指定位置的工件。

【问题讨论】:

    标签: maven maven-2 exec-maven-plugin


    【解决方案1】:

    解决了! 我做错了。 &lt;executable&gt; 标签应该只有命令。参数将在&lt;arguments&gt; 下定义。

    请查看更新后的插件定义:

     <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.1.1</version>
      <executions>
        <execution>
                <id>some-execution</id>
                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                <configuration>
                        <executable>mv</executable>
                                <arguments>
                                        <argument>${project.build.directory}/${project.artifactId}-${project.version}-myapp.jar</argument>
                                        <argument>${project.build.directory}/${project.artifactId}-${project.version}.app</argument>
                                </arguments>
                </configuration>
         </execution>
       </executions>
      </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-14
      • 2013-06-12
      • 2016-12-02
      • 2019-05-02
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多