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);