2017-07-04 3 views
0

J'essaie de renommer un artefact en utilisant exec-maven-plugin. (Je ne veux pas utiliser le plugin antrun comme je me sers que dans un but différent dans la même phase et l'objectif.)maven build échoue retours l'exécution est: '127'

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

Il ne parvient pas à renommer l'artefact et ci-dessous donne une erreur:

[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 log:

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

De ce journal, je suis sûr que quelque chose est manquant mais je suis incapable de savoir quoi. Mon OS est Ubuntu /bin/sh est disponible. ls répertorie également l'artefact à l'emplacement spécifié.

Répondre

0

Résolu! Je le faisais mal. La balise <executable> est censée avoir la commande uniquement. Les arguments seront définis sous <arguments>.

S'il vous plaît voir la définition du plugin mise à jour:

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