Outdated maven-compiler plugin or what’s better than specifying source and target every time

Every now and then (beside build being platform dependent) you hit compilation problems in Maven, where it’s using outdated compiler plugin and all of a sudden it tells you you are using a Java feature that’s not in… 1.3. Like…

generics are not supported in -source 1.3

So, Internet will try telling you, you need to specify source and target but I say, listen to mvn versions:display-plugin-updates

Limitations!

If you are building Maven PLUGIN read on. For OTHER kinds of projects, see Maven enforcer plugin instead, because below is for plugins mostly.

Adding source and target

Here for completion and reader’s convenience, taken from https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html:

Solving underlying problem?

Underlying problem is, I have Java 8, I don’t want to have such old source and target. I however must, as super POM says so!

Below output is a courtesy of the incredible maven-versions plug-in.

[INFO]
[INFO] All plugins with a version specified are using the latest versions.
[INFO]
[WARNING] The following plugins do not have their version specified:
[WARNING] maven-clean-plugin .......................... (from super-pom) 2.2
[WARNING] maven-compiler-plugin ..................... (from super-pom) 2.0.2
[WARNING] maven-deploy-plugin ......................... (from super-pom) 2.4
[WARNING] maven-install-plugin ........................ (from super-pom) 2.2
[WARNING] maven-resources-plugin ...................... (from super-pom) 2.2
[WARNING] maven-site-plugin .................... (from super-pom) 2.0-beta-4
[WARNING] maven-surefire-plugin ..................... (from super-pom) 2.4.2
[WARNING] maven-war-plugin ............................ (from super-pom) 2.0
[INFO]
[WARNING] Project does not define minimum Maven version, default is: 2.0
[INFO] Plugins require minimum Maven version of: 3.0.3
[INFO] Note: the super-pom from Maven 3.0.5 defines some of the plugin
[INFO] versions and may be influencing the plugins required minimum Maven
[INFO] version.
[INFO]
[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain
[ERROR] <prerequisites>
[ERROR] <maven>3.0.3</maven>
[ERROR] </prerequisites>

Now, take a note at those ERROR lines.

Once you add them to POM, versions output shows immediately raised several plug-ins versions!

<prerequisites>
<maven>3.0.3</maven>
</prerequisites>

Now, off to find a way to make it permanent, per all projects. Profile? Toolchain?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s