首次调用gradlew
后,脚本会被终止。那是为什么?
#!/usr/bin/env sh
find $PWD -maxdepth 1 -type d | while read d; do
cd $d
echo "cd" $d
if [ -e "pom.xml" ]; then
echo $d " contains pom.xml"
mvn clean
echo "cleaned" $d
fi
if [ -e "gradlew" ]; then
echo $d " contains gradlew"
./gradlew -q clean
echo "cleaned" $d
fi
done
输出:
$ ./clean-all
cd /home/user/code
cd /home/user/code/smstest
/home/user/code/smstest contains gradlew
cleaned /home/bpiech/code/smstest
如果我评论gradle调用,它适用于每个maven项目。
答案 0 :(得分:2)
将while循环更改为for-in循环修复了我的问题。不过,知道它为什么会这样运作会很好。
#!/usr/bin/env sh
for d in $(find $PWD -maxdepth 1 -type d); do
cd $d
echo "cd" $d
if [ -e "pom.xml" ]; then
echo $d "contains pom.xml"
mvn clean
echo "cleaned" $d
fi
if [ -e "gradlew" ]; then
echo $d "contains gradlew"
./gradlew clean
echo "cleaned" $d
fi
done