How to require a particular Java version for compilation using Maven

Lately we’ve had a few instances at my current client where we’ve had problems with deployment of Java web apps which have been built using the wrong JDK version.  We are using Atlassian Bamboo for continuous integration on our daily builds, but we have not yet set up automated releases using Bamboo.  Thus, we still have developers creating releases on their individual workstations instead of on a dedicated build machine or cluster.  The problem with this is that if an individual developer is not careful with his/her environment set up, they can inadvertently build a release using the wrong JDK version.

I recently discovered that the Maven Enforcer plugin can help prevent this from happening.  Configuring it in your Maven build is really quite easy.  I’ve included an example below that shows how to require that your Java project be built using Java 1.7.

 

This entry was posted in Java and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply