我有以下插件运行.sh
脚本:EXEC Maven插件:退出代码
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>deploy-bundles</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/deploy.sh</executable>
<successCodes>
<successCode>0</successCode> <-- Not working
</successCodes>
</configuration>
</execution>
</executions>
</plugin>
其拷贝一些文件夹和文件到一定的位置。有用。不过,为了以防万一,我希望有一个错误失败机制。我在.sh
脚本中已经有set -e
命令,但我也想要一个maven解决方案。我听说有一个叫successCodes
的tag,我试着把它合并。但到目前为止没有运气。有人能指出正确的做法吗?
编辑:我.sh
脚本是这样的:
cp ../template/config.properties $component/conf
cp ../../runtime/group1/group1.mw/conf/log4j.xml $component/conf
# if the component is planning, create an additional folder called plans
if [[ $component == *".planning"* ]]
then
mkdir -p $component/plans
# copy all the plans here
cp ../../mission.planning/plans/* $component/plans
fi
情况,预计万一失败,这些文件夹/文件不存在。所以,作为一个测试,我手动更改上面的路径,并期望它失败。它执行失败并告诉我错误(因为我在.sh
脚本中有set -e
命令),但maven报告是“成功”的。
完美答案,谢谢。 –