Maven integration (m2e) for Eclipse 3.7.x (Indigo)

Sonatype’s Maven integration for Eclipse (m2e) has been migrated to eclipse.org and is now available from the default update site for Indigo.

This means that you no longer have to add any Sonatype update sites as mentioned on the old (now outdated) m2eclipse site.

In particular, this also means that the old “m2e-extras” update site is obsolete for Eclipse 3.7.x and later. Things like WTP integration or Subclipse integration are now available as “m2e connectors” through Window – Preferences – Maven – Discovery.

All of this is very poorly (or not at all) documented on the new m2e home page and some people had problems with these changes.

Programming principles for Java methods

Topics I want to cover in the future about Java methods:

  • Minimalistic coding style [1] [2] [3] [4]
  • “Fail early” (or “fail fast”) principle [1] [2]
  • “Return early” principle [1] [2] [3]
  • Object creation methods (to allow final)
  • Type generic methods (process a T vs create a T)
  • Functional style: stateless static methods vs interfaces
  • Javadoc: On interface not implementation
  • Method naming guidelines
  • Strategy parameters (often anonymous interface implementations)
  • Exception handling methods (try-catch-finally, throwing exceptions)
  • How to avoid setter/getter madness
  • Method chaining API style (static factory method, builder methods)

JQuery DataTables column filters state saving

The JQuery DataTables plugin supports state saving for column filters. But it does not automatically set the column filter values to the saved values when the user navigates to a page that has saved filter state.

I saw the code suggested here and cleaned it up a little (for example, using the oSettings parameter of the fnInitComplete function).

$(document).ready(function() {

        var oTable = $('#REPLACE_THIS_WITH_TABLE_ID').dataTable({
            "bStateSave": true,
            "fnInitComplete": function(oSettings, json) {
                var cols = oSettings.aoPreSearchCols;
                for (var i = 0; i < cols.length; i++) {
                    var value = cols[i].sSearch;
                    if (value.length > 0) {
                        $("tfoot input")[i].value = value;
                    }
                }
            }
        });

        $("tfoot input").keyup(function () {
            oTable.fnFilter(this.value, $("tfoot input").index(this));
        });
    });

Please note that I completely removed all code that supported initial display texts in the filter fields (because I don’t use that).

Jenkins on minimalistic Debian Virtualbox VM (64bit)

Update 14/Aug/2018: I no longer maintain the package mentioned and the download links below are most likely broken.

A Jenkins build server (LTS release) can now be easily installed on the minimalistic Debian VM:

  1. Download and install Virtualbox
  2. Download debian-stable-amd64-minimal.ova and import it into Virtualbox
  3. Start the “debian-stable-amd64-minimal” VM in Virtualbox
  4. If you are outside Nova Scotia, please review debian-stable-amd64-minimal.txt and adjust locale, timezone and Debian mirror based on your location
  5. Start an ssh session to localhost, port 1111 (using PuTTY, for example)
  6. Log in as user (default password is “user”)
  7. Issue “sudo install.sh jenkins” (default root password is “root”)
  8. Press enter for any questions during installation
  9. Open http://localhost:8888/ in a browser on the host OS for Jenkins web ui

You can go to “Manage Jenkins” – “Configure System” and see that JDK, Ant and Maven entries are already configured for you.

Both OpenJDK 6 and OpenJDK 7 are installed automatically for you in the VM. Please note that openjdk-6 is the Debian stable system default, while openjdk-7 is configured as the default for Jenkins build jobs.

Important: Make sure to change root and user passwords to something secure, as mentioned in debian-stable-amd64-minimal.txt.

Convert Virtualbox VDI for VMware Player

Regarding the VM that I mentioned in my previous post – this way I also got it to work in VMware Player:

  • Install and start Virtualbox (https://www.virtualbox.org/wiki/Downloads)
  • Go to File – Import Appliance (and import the ova file mentioned in my last post)
  • Close Virtualbox
  • Use VBoxManage on the command line to clone the VDI to VMDK, roughly as described here (but do not try to uninstall guest additions):  http://scottlinux.com/2011/06/24/convert-vdi-to-vmdk-virtualbox-to-vmware/
  • Create a new empty Linux/Debian VM in VMware Player
  • Close VMware Player
  • Edit the new vmx file so that it points to the cloned vmdk
  • Then open the VM in VMware player again. Now it should boot into Debian.

Minimalistic Debian VM (64bit)

Update 14/Aug/2018: I no longer maintain the package mentioned and the download links below are most likely broken.

I uploaded a VM image to dev.doepner.net: It is a minimalistic Debian VM that can be used as a base for lean servers. It is in OVA format, exported from Virtualbox 4.1.6. Details are in the corresponding txt file.

You can add the VM to your Virtualbox using “File” – “Import Appliance …”. VMware should also work but might require some compatibility conversion of the ova file.

Recipes for specific Nexus, Jenkins, Wiki, Bugzilla setups will follow … I will publish those as scripts/instructions relative to the minimal base image, rather than maintaining several VMs.

Lightweight Eclipse package for web development

Update 14/Aug/2018: I no longer maintain the package mentioned and the download links below are most likely broken.

I uploaded a lightweight Eclipse package (based on Helios 3.6.1) for web development (includes Maven, SVN and basic Spring integration, JEE / web tools plugins, but no Mylyn or other non-essential stuff) … This is currently only for Windows. It requires a JDK and is completely free / open source software.

See the txt file for quick installation steps.

bash script to recursively sanitize folder and file names

Below is a bash script to recursively sanitize folder and file names. It leaves all numbers, letters, dots, hyphens and underscores untouched, but replaces all other characters with underscores.

#! /bin/bash

sanitize() {
  shopt -s extglob;

  filename=$(basename "$1")
  directory=$(dirname "$1")

  filename_clean="${filename//+([^[:alnum:]_-\.])/_}"

  if (test "$filename" != "$filename_clean")
  then
    mv -v --backup=numbered "$1" "$directory/$filename_clean"
  fi
}

export -f sanitize
find $1 -depth -exec bash -c 'sanitize "$0"' {} \;

My /etc/apt/sources.list (for Debian squeeze)

My sources.list entries:

# local repo (manually downloaded debs, etc.):
deb file:/usr/local/packages ./

# The closest Debian mirror is at Dalhousie University, Halifax:
deb http://mirror.its.dal.ca/debian/ squeeze main contrib non-free
deb http://mirror.its.dal.ca/debian/ squeeze-updates main
deb http://mirror.its.dal.ca/debian/ squeeze-proposed-updates main
# See http://www.debian.org/mirror/list for mirrors closer to you

# Security updates (not mirrored)
deb http://security.debian.org/ squeeze/updates main

# Official backports repo for squeeze (I install the Linux kernel from it)
deb http://backports.debian.org/debian-backports squeeze-backports main

# Debian multimedia, a must-have for mplayer et al.
deb http://mirror.its.dal.ca/debian-multimedia squeeze main non-free

# Repo that provides latest Iceweasel (aka Firefox)
deb http://mozilla.debian.net/ squeeze-backports iceweasel-release