[英]I want to execute a cygwin script from maven's pom.xml
I need to execute a shell script under cygwin, because I'm under Windows. 我需要在cygwin下执行shell脚本,因为我在Windows下。 The shell is executed but the commands arent' recognize ... See below : 外壳程序已执行,但命令无法识别...如下所示:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>openOCD</id>
<phase>validate</phase>
<configuration combine.self="override">
<tasks>
<exec
executable="C:/cygwin/bin/sh.exe"
failonerror="true">
<arg line="${project.basedir}/make.sh" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The make.sh for the moment doesn't seem really complicated : 目前,make.sh似乎并不复杂:
#!/bin/sh
export PATH=C:\cygwin\bin:$PATH
export BLA=C:\blabla
cd $BLA
mkdir testMaven
And maven, via Eclipse for information with the command Run As ...Maven Install : 而maven,通过Eclipse使用Run As ... Maven Install命令获取信息:
[INFO] Executing tasks
main:
[exec] C:bla
[exec] C:\Users\truc\TestSWMavensousKepler\pouet\bla/make.sh: line 6: mkdir: command not found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Do you have any idea ? 你有什么主意吗 ? Thank you :) 谢谢 :)
C:\\cygwin\\bin\\bash make.sh
will run your linux commands you can use that to run your shell script file. C:\\cygwin\\bin\\bash make.sh
将运行您的linux命令,您可以使用它来运行shell脚本文件。 Also tasks tag( <task>
) is now deprecated you should use target( <target>
) instead. 另外,不推荐使用<task>
标签( <task>
),而应该使用target( <target>
)。 Ideally below code should work. 理想情况下,下面的代码应该可以工作。 You can add anything you can add between <target>
and </target>
in a build.xml(this is used ANT). 您可以在build.xml中添加可以在<target>
和</target>
之间添加的任何内容(使用ANT)。
<target>
<exec executable="C:\cygwin\bin\bash">
<arg value="${project.basedir}/make.sh"/>
</target>
Make sure C:\\cygwin\\bin\\bash make.sh
is working fine. 确保C:\\cygwin\\bin\\bash make.sh
运行正常。
I know it's late (1 year after you posted) but I had this same problem and decided to post a quick article on how to fix it. 我知道已经晚了(发布后的第一年),但是我也遇到了同样的问题,因此决定发表一篇有关如何解决它的快速文章。
In short: 1. Create a profile for your dev environment if necessary 2. Use cmd as the executable and supply /C and the script as arguments. 简而言之:1.必要时为您的开发环境创建一个配置文件。2.使用cmd作为可执行文件,并提供/ C和脚本作为参数。
Here's the article if you want: https://medium.com/@jimmysthoughts/happily-coexisting-building-with-exec-maven-plugin-on-both-os-x-and-cygwin-d9fb0c4a02cc 如果需要的话,请参见以下文章: https : //medium.com/@jimmysthoughts/happily-coexisting-building-with-exec-maven-plugin-on-both-os-x-and-cygwin-d9fb0c4a02cc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.