Maven Exec Plugin not using system path on windows?
How can this not work in windows?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>deploy-dev-ssh</id>
<phase>in开发者_StackOverflow中文版stall</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>echo</executable>
<arguments>
<argument>hello</argument>
</arguments>
</configuration>
</plugin>
I get this when I run it:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (do-this) on project <my_project_name>: Command execution failed. Cannot run program "echo" (in directory "<my_local_path>"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
How can echo not be on the PATH?
The problem here is that echo is a command of the cmd.exe program, it is not a standalone process\application as in Unix. In order to do what you are trying to do here you need to call cmd as the executable with 'echo', '/C' (to tell cmd that you're passing it a command - see 'cmd /?' on your Windows command line.) and 'hello' as arguments.
Like so:
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/C</argument>
<argument>echo</argument>
<argument>hello</argument>
</arguments>
</configuration>
You can also create an echo.bat file in your running directory and set the content to:
@echo %*
This technique is especially handy for simultaneously supporting both Windows and Linux build environments. Maybe "echo" is not a good example, but you may run into cases where the same command exists both on Windows and Linux.
精彩评论