Friday, February 26, 2010

No %%Pages: comment in header!

After being able to print successfully for several months, I got this error message today while printing from my laptop with Fedora 10: "No %%Pages: comment in header!". I have no idea what it means, but after searching around there was a simple fix for me. From the printer properties GUI I noticed that the "Print Test Page" button was disabled. In the policies tab the printer state "enabled" box was unchecked. I checked the box to re-enable the printer, and voila, I was able to print again.

Monday, February 15, 2010

MojoFailureException vs. MojoExecutionException

There are two types of wrapper exceptions commonly used in Maven plugins, the MojoFailureException and MojoExecutionException. It's not obvious which one is the correct one to use, so here is a simple explanation. A MojoExecutionException typically means that an unexpected and unrecoverable error happened while running the plugin. This would be something like a NullPointerException or other RuntimeException that the plugin developer did not expect and/or can not handle. It's basically a plugin crash.

A MojoFailureException means that there was a problem in the build which the plugin detected, and the plugin is now notifying you of that failure. This would be something like a Java source file that couldn't compile. The build can not continue, but the plugin is still working normally.

More information can be found in the Sonatype Maven book.

Wednesday, January 6, 2010

Perl multiline search/replace

Quick perl program to do a multi-line search and replace.

open(INPUT,"<$ARGV[0]") or die;
$/ = "%%\n";

$theFile=<INPUT>;
#print $theFile;
close(INPUT);

#$theFile =~ s# \true\<\/optional\>\n##ig ;
$theFile =~ s# \<\/dependency\># \true\<\/optional\>\n \<\/dependency\>#ig;

open(OUTPUT,">$ARGV[1]") or die;
print(OUTPUT $theFile);
close(OUTPUT);

Thursday, December 3, 2009

Rsync with central Maven repository

For reference here is the rsync command to copy files from the central Maven repository.

rsync -v -t -l -r mirrors.ibiblio.org::maven2/subdir /local/path

Sunday, November 22, 2009

XUbuntu 9.10

I have an old Fujitsu laptop (pentium 3, 256 MB RAM, 20 GB disk) that has gone through a few iterations of various linux distributions. I used XUbuntu 7.04 for a while and it was ok, but it was just too slow. The tricky part is that it has an old Cisco Aironet 360 wireless adapter which only works with a 2.4 kernel (or at least I thought this was the case). I tried out Damn Small Linux, and it's great for what it does, but for my laptop I couldn't get the wireless card or the touchpad working. I tried out various combinations of older versions of Fedora and Ubuntu, but they were always either painfully slow or unable to handle the old wireless card. Fedora 12 was unbearably slow.

I didn't think a recent version of XUbuntu would work, because in the past I was only able to get the wireless working when using a 2.4 kernel. But I'm really glad I gave it a try anyway, because it works! XUbuntu 9.10 was able to find and configure everything on the laptop right away, including my old wireless card. The install process is improved since previous versions, the boot time is faster, and the gnome interface seems more responsive all around.

Big thanks to the XUbuntu guys for all their work on this. Now I have an extra working laptop again!

Friday, July 24, 2009

Ant refid resolution 1.5, 1.6, 1.7

I noticed some behaviour changes in Ant related to refids. In Ant 1.5.x a fileset refid has to be defined before being used. So for example if I define a fileset in target "a" and then call target "b" which uses the refid, the build will fail because target "a" was never run and never set up the refid.

This behaviour changed in Ant 1.6.x, so that Ant tries to be more intelligent and automatically searches for refids that are defined in the build, but not necessarily run. So in the above example, Ant silently succeeds and the refid is found in target "a" even though that target was never actually called. This seems like strange behaviour to me, because it's not well documented and seems like it could produce some tricky bugs. I guess the Ant developers also thought this behaviour was not ideal because in Ant 1.7 the same automatic refid resolution works but now produces a warning. I briefly tried to track down some discussion related to this in the ant developer mailing list archives, but I was unsuccessful in finding anything.

Tuesday, July 14, 2009

Recursive Grepping

I recently had some need to search for certain text within files in a directory. This works with eclipse, but sometimes it can be slow and a bit limited in options. So I turned to good old grep. I wanted to exclude certain directory patterns from the search, but the problem I ran into was that the version of grep packaged with Fedora 10 and available in the yum repository is an older version (2.5.1) and does not include the "--exclude-dir" option. So I had to grab a recent copy of the source. I then did a ./configure, make, make install and I was good to go with version 2.5.4. The last tricky part for me was how to match multiple filename patterns using GLOB. Here is an example of the final command:

grep -R "apache.commons." . --include={*.xml,*.ent} --exclude-dir="output"