Wednesday, November 25, 2009

Download sources jar from maven

We use Maven, when Maven downloads dependencies it doesn't download sources, which I rely on when learn and debug programs....
I was expecting, for what seem a simple thing to me, a flag that I can add in maven's settings files or an option to pass to mvn command.... but I couldn't find the solution (or anything close to it). Don't get me wrong, there are solutions out there, but I just feel it is too much hassle for the task.

So I wrote a little script that go thru my repo and downloads any jar that doesn't have its respective sources :p

#!/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

Monday, November 23, 2009

ImageMagick and JPEG on OSX

I am not a fan of port or fink so I always install ImageMagick from source.
Recently I came across a problem where ImageMagick fails to identify JPEG's.
The error looks something like this
identify: no decode delegate for this image format

After some digging around it appears I need to install libjpeg and reinstall ImageMagick for JPEG support.
So I downloaded jpegsrc.v7.tar.gz and just run thru the standard configure, make & make install then reinstalled ImageMagick.
After the installation you should be able to see JPEG as one of the supported format via the command "identify -list format".
It should contain something like this.
JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)