I've written a shell-script
to build all projects mentioned in a particular file using a while
loop and gradle clean build
command to do so.
Here is how it looks like:
echo -e "\Building all projects"
filename="projects" #File Containing all projects name to build
workdir=$(pwd)
while read -r line; do
name="$line"
echo -e "\ngradle build repo - $name"
cd $workdir/$name
gradle clean build
done < "$filename"
Here is contents of projects file:
core
dal
dao
web
ui
and here is my directory structure
src
|-script.sh
|-core
| |-build.gradle
| |-gradle.properties
| |-src
| |-otherstuff
|
|-dal
| |-build.gradle
| |-gradle.properties
| |-src
| |-otherstuff
|
|-dao
| |-build.gradle
| |-gradle.properties
| |-src
| |-otherstuff
|
|-same repeats for web and ui
So I expect my script to read file projects
and go into all the mentioned folders
from that file and issue command gradle clean build
in that folder.
Everything works fine and as expected except gradle
command no matter whether build succeeds or fails for the first project (core
) it makes script to break the loop and exit.
So It prints output only for the first project and doesn't work for all other.
However,
If I try to run it in the background it works fine; ie; instead of
gradle clean build
if I issue
gradle clean build &
It works fine; Although output, in that case, is gibberish.
Can anyone please look into this and help me out??
Thanks in advance.