我有以下插件運行.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報告是「成功」的。
完美答案,謝謝。 –