Read the blog post, read read. But what if I don’t want to? It doesn’t matter, READ!

After some late night cramming for an exam last week I went to bed with my head still chattering. I told a sleepy Karen about my day at work and how Dan and I kept singing different words to Adam and Joe‘s “Text the Nation” jingle. I gave the example: “Patch the source code, patch patch, but what if it’s not tested? It doesn’t matter, PATCH!” (I hope the sarcasm reads well).

As I noisily clambered into bed, Karen reminded me I still had my glasses on. “But how will I see my dreams?” I replied, to which she instantly quipped “It doesn’t matter, SLEEP!”. Karen got the idea instantly even though she was half asleep and doesn’t really listen to the show. She still managed to come up with something better than any of my attempts.

It’s when these moments of utter genius tumble out of Karen’s mouth that I am reminded how much smarter than me she is.

Convention ÷ Configuration

I’ve long been sold on the concept of Convention Over Configuration. For me it’s a no-brainer, not only am I lazy, but when I am forced to make a decision about something technical, well, let’s just say the number of times I get it wrong is > 0.

Recently I’ve been playing around with Maven, something I should have done years ago. Maven seems pretty sold on the convention idea too and so I just expected a simple project to work “out of the box”.

Unfortunately, when I tried, I hit a problem with my first simple project. As you can see from the “reconstruction” screenshot, I had problem with recognising simple java 5 features.

I was using the latest copy of eclipse, on a fresh install of Ubuntu using OpenJDK. I’ve not developed with OpenJDK and so blamed that at first, it couldn’t possibly be Maven… So, I downloaded the Sun JDK, and as you can guess, I realised it was a Maven thing.

When you create a simple Maven project using the m2eclipse eclipse plugin it defaults to a Java 1.4 compliance level. What kind of sensible convention is that? I like to think there is a good reason for that because I imagine it has cost the community quite a few potential Mavenees.

Once you realise this is the problem, just change the project specific Java compiler settings to whatever makes sense for you.

I’ve not got any research or references to hand, but my gut tells me that the convention should be to use whatever the majority of the programming community agrees is the best version of the best tool for the job. If someone wants to use Maven for a project that needs to support backwards compatibility, then let them do the configuring, not me.

It also defaults to JUnit 3.8.1, another warning sign in my head. Everything else in Maven I have done so far has been a pleasure and m2eclipse looks like a great plugin, I just wish the defaults were not so 2004.

To fix this within the POM you need to add the following:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

</plugins>