无法在Windows

时间:2018-03-09 18:51:33

标签: java shell maven

我的项目pom包含gmaven-plugin插件,其中configuaration->properties->script标签下定义了sh脚本位置,当我执行mvn install时,我的Windows机器上出现以下错误。< / p>

java.io.IOException: 
Cannot run program ": CreateProcess error=193, %1 is not a valid Win32 application

请在下面找到相关的插件。

        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                    <configuration>
                        <properties>
                            <script>${basedir}/../tools/testfile.sh</script>
                        </properties>
                        <source>
                            //some code for execution
                        </source>
                    </configuration>
                </execution>
            </executions>
        </plugin>

1 个答案:

答案 0 :(得分:1)

You are trying to execute a shell script on windows machine. The window command does not know how to do that. this is probably creating the issue.

If you would like to test this, just replace shell with a simple .bat file (Window executable).

You can add below into the .bat file and try mvn install

echo Test file executed.
echo I am too lazy to write commands again and again.

EDIT: As OP informed via comment

.bat file is executing successfully from when executing mvn install command but what if you want to execute only .sh file only. Is there any way for it.

Now the option is to execute the .sh on windows. Few option are to install GIT client, which by default installs GIT BASH which is a unix like command prompt.

Once install, just open any .sh file from windows and say open with.. and choose GIT BASH. Click on Always use this program. This step would associate .sh to the git bash program.

Git Bash

Another usual solution to that is use Cygwin