mavenexec-maven-pluginpscp

Maven - exec-maven-plugin - CreateProcess error=2, The system cannot find the file specified


I am using this code to upload a JAR file to a Server right after the Install phase:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
      <execution>
        <id>server-deployment</id>
        <phase>install</phase>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>D:\my-folder\pscp.exe -r -i D:\my-folder-conf\user.ppk D:\my-folder-jar\file-1.1.0.jar ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/file-1.1.0.jar</executable>
    </configuration>
  </plugin>

The command:

D:\my-folder\pscp.exe -r -i D:\my-folder-conf\user.ppk D:\my-folder-jar\file-1.1.0.jar ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/file-1.1.0.jar

Works from Windows Console normally and the file is uploaded, but when I execute the very same command with the exec-maven-plugin, it fails with the message: CreateProcess error=2, The system cannot find the file specified. If I am providing full paths and extensions to all files, how does this happen? Is there any solution for this=

Solution:

I ended up using the approach of @xerx593, thanks for your help, here bellow is the final solution:

<configuration>
  <executable>D:\my-folder\pscp.exe</executable>
  <arguments>
    <argument>-r</argument>        
    <argument>-i</argument>      
    <argument>D:\my-folder-conf\user.ppk</argument>       
    <argument>${project.build.directory}/${project.build.finalName}.jar</argument> 
    <argument>ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/${project.build.finalName}.jar</argument>  
  </arguments>
</configuration>

Solution

  • Please try:

        <configuration>
          <executable>D:\my-folder\pscp.exe</executable>
          <arguments>
            <argument>-r</argument>        
            <argument>-i</argument>      
            <argument>D:\my-folder-conf\user.ppk</argument>       
            <argument>D:\my-folder-jar\file-1.1.0.jar</argument> 
            <argument>ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/file-1.1.0.jar</argument>  
          </arguments>
        </configuration>
    

    ...as documented (& shown) instead.