【发布时间】:2013-01-26 10:10:56
【问题描述】:
我需要在 Linux 和 MS-Windows 平台上运行一个外部脚本。
- 我是否使用了正确的插件
exec-maven-plugin? - 有没有更合适的插件?
-
我应该在
<executable>....</executable>中输入什么文件名?<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>compile-jni</id> <phase>compile</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>./compile-jni</executable> <workingDirectory>${basedir}/src/main/cpp</workingDirectory> </configuration> </execution> </executions> </plugin>
我对两个平台 Linux/MS-Windows 使用相同的 Makefile
我的脚本compile-jni.bat:
call "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
bash -c "make"
我的脚本compile-jni.sh:
#!/bin/sh
make
更新:
两位同事提出了替代方案:
使用变量
script.extension将<executable>./compile-jni${script.extension}</executable>更改为pom.xml并在命令行中附加变量mvn compile -Dscript.extention=.bat-
或者在调用maven之前设置Visual Studio环境变量:
call "C:\%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 mvn compile #(the same script 'bash -c "make"' works on both platforms)
但是在这两种解决方案上,Eclipse 用户可能会被卡住……我仍在寻找一种自动且优雅的解决方案……
【问题讨论】:
标签: shell maven batch-file pom.xml exec-maven-plugin