Install this theme
Parallelizing execution with xargs on Unix-like operating systems

In my current project i have to build multiple Java projects with Ant

xargs command line utility can accelerate the build process, by starting the necessary build scripts in parallel threads.

Below is a simple shell script build-all.sh, that finds all build.xml files within “build” subfolders and starts Ant for each of them with the specified command line parameters.

if [ -z "$1" ]
 then
   echo -e "Usage: build-all.sh "
   exit -1
fi

find */build -name 'build.xml' -print0 | xargs -0 -n 1 -P 10 ant "$@" -f
 
Blog comments powered by Disqus