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>

Tags: , ,

3 Responses to “Convention ÷ Configuration”

  1. dan Says:

    Where are all the links? You know that links are the lifeblood of blogging, right? For example, “eclipse”, “Ubuntu” and “OpenJDK” should all point at their respective projects. But, more importantly, “I downloaded the Sun JDK” should go to the set of instructions you used to do that. Same thing for “create a simple Maven project”. How am I s’posed to learn anything from this post? All it says to me is “I’m an idiot; the Eclipse tooltip clearly told me that the project settings should point at Java 1.5, and when I did that it worked”.

    Even your conclusions are unclear. Should I get the m2eclipse to give me a 1.5 project, or do I get a 1.4 project then upgrade it in eclipse?

    What do the providers of maven projects do? You can download starter projects for, say, OSGI Maps, right? Do they come in different flavours of Java (OSGI 5 starter pack, OSGI 6 starter pack,…)? Or does maven/m2 pick up your current java version and download the appropriate project?

  2. dan Says:

    Also, your use of the division sign (÷, or obelus) is inappropriate.

    Yes, when expressing a fraction (such as three-quarters), one would often say “three over four” and write 3/4 (but not 3÷4) to represent ¾.

    Even if we accept the leap from 3/4 to 3÷4, the “over” in “three over four” literally means “on top of” (e.g. one flew over the cuckoo’s nest), because when we write ¾ we put the 3 on top of the 4.

    But in this instance, “over” means “in preference to” not “on top of”,
    and there’s no equivalent symbolic mapping for this relationship. If anything, the closest thing is “greater than”.

    So perhaps you meant “Convention > Configuration”?

  3. dan Says:

    …although greater-than doesn’t really capture the spirit of what we’re trying to express. I mean, it holds up ok for…

    Pen > Sword

    …but what about…

    Rock > Scissors > Paper > Rock

    ?

Leave a Reply