Thursday, July 12, 2012

Use ${basedir} in Maven.. ALWAYS!

If you come across different outcomes in your maven build depending on whether you invoked the maven command inside project's directory or its parent directory, you are doing it wrong somewhere. The build should be consistent. If that module is part of a big multi-module project, project should behave the same always even it's built in the command line or as a part of a build scheduled in a continuous integration server.

For example if you refer to a directory like <directory>target/site</directory> it will look for the target directory at the location the command was executed. This will make things inconsistent depending on whether you invoked it inside the sub-module or the parent project. But referring to it like <directory>${basedir}/target/site</directory> will make sure the target directory will always be searched in one location, the directory where the pom.xml lies. For some reason, if you want to point to the directory from which the maven command was executed use ${user.dir}

For a full list of Maven properties read Maven Properties Guide or this chapter on Sonatype's book, 'Maven: The Complete Reference'.

TL;DR : Remember ${basedir} always represents the directory containing the pom.xml

XFCE window borders missing

On one bad day if you find your nice, slick xfce desktop environment is all messed up and there are no window decorations or title bar in the application windows.. it can be because your window manager has crashed. You can start it up by the command
xfwm4 --replace
You don't have to do this every time you log in. It should work automatically if you save your session when you log out. If not, you might want to clear out your sessions cache to reset it and solve the problem. To reset your sessions cache, simply delete the .cache/sessions folder in your home directory.
rm -rf ~/.cache/sessions
You can look at the logs in ~/.xession-errors to figure out the exact problem. Read more at this forum post.