Skip to content

Instantly share code, notes, and snippets.

@shenie
Created November 26, 2009 05:40
Show Gist options
  • Save shenie/243263 to your computer and use it in GitHub Desktop.
Save shenie/243263 to your computer and use it in GitHub Desktop.
Download sources from maven
#!/bin/bash
prefix="http://mirrors.ibiblio.org/pub/mirrors/maven2"
header="/tmp/$0.header.$$"
find . -name "*.jar" -and ! -name "*sources.jar" | grep -v "siteminder" | \
while read j
do
source_jar=$(echo $j | sed -e's/.jar/-sources.jar/')
if [ ! -e $source_jar ] ; then
echo "Downloading ${source_jar}"
pushd $(dirname $source_jar) >/dev/null 2>&1
curl -D $header -O "${prefix}/${source_jar}" >/dev/null 2>&1
popd >/dev/null 2>&1
error=$(fgrep -c "404 Not Found" $header)
if [ $error -ne 0 ] ; then
echo "It does not exist..."
rm $source_jar 2>/dev/null
fi
fi
done
rm $header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment