2017-07-04 44 views
0

我想使用exec-maven-plugin重命名工件。 (我不想用,因爲我使用了在同相和目標不同的目的antrun插件。)maven構建失敗返回執行是:'127'

插件在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: [email protected]] 
[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 = [email protected] 
[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也列出指定位置的工件。

回答

0

解決了! 我做錯了。 <executable>標籤應該只有命令。參數將在<arguments>下定義。

請查看更新的插件定義:

<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>