[英]How to extract the artifactId from all pom.xml files using in a multimodule project (using shell script)?
[英]Finding pom.xml in current directory using shell script
我正在尝试在当前目录的子目录中构建所有Maven项目。 我的Shell脚本说找到pom文件,而不管文件是否存在。 我不确定自己做错了什么。 有人可以帮忙。
我的shell脚本是
#!/bin/bash
#############################################################
#Simple script to build all project in the current directory
#############################################################
dirlist=$(find $1 -mindepth 1 -maxdepth 1 -type d)
for dir in $dirlist
do
(
cd $dir
echo "############################################################################"
echo "inside directory: " $dir
echo "############################################################################"
git checkout development
git pull
if find . -maxdepth 1 -type f -name "pom.xml" # <- this is always true#
then
echo "========== Pom file exists to going for building ========= "
mvn clean install -DskipTests=true
fi
)
done
即使未找到任何内容, find
的退出状态也为0。 例如,对于非空目录的-delete
之类的情况,它为非零,但不是找不到任何东西。
$ ls
file1.txt
$ find -name 'file2.txt'
$ echo $?
0
您可以只检查条件是否存在:
if [[ -e 'pom.xml' ]]; then
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.