Reputation: 194
As stated in Maven's documentation,
at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with.
I know that I can change this for individual projects, but I do not understand why the choice was made to ignore the JDK. Surely it would be more intuitive to detect the version and use it for the source setting?
Upvotes: 1
Views: 182
Reputation: 455
Java annotations and generics were introduced in version 1.5. Setting the levels any lower would break a very large portion of the Java code that has been written. Although there were features introduced in versions 1.6 and 1.7, they weren't used as widely as generics and annotations. However, there are a number of J2EE artifacts that require 1.6. The vast bulk of the code works with 1.5, so that was viewed as a reasonable default.
Upvotes: 0
Reputation: 638
There are several things to consider here.
The phrase "at present" suggests that the logic for choosing the default may be improved or enhanced in the future. But I won't hold my breath.
Choosing (or worse, changing) default values is always a tricky business, for exactly the reason Rob pointed out. Do you appease the complainers and cause everyone else a great deal of trouble? Or do you let sleeping dogs lie and keep an outdated default? Neither choice is ideal, so "do nothing" wins out - the lesser of two evils. The risks of making a change outweigh the benefits.
What khmarbaise probably meant is that there is no relationship between Maven's default value and the JDK you are using. Either it's correct or it isn't, and there's nothing that Maven can do about it in either case. For all Maven knows, you might have five different JDK's on your machine. It has no way to know which ones you are using, and for which projects.
Update the default to 1.8 and you're likely to have just as many folks that can't use the default as before you changed it. (Assuming there would be less is a reasonable assumption, but it's still an assumption.) No matter what the default value is, someone, somewhere is going to have to use a custom setting. So why worry about which group of folks is which? A default is about convenience; nothing more.
The goal is to provide consistent behavior. Changing the default (whether often or no) goes against that goal. Knowing that Maven is providing that consistency is likely worth enduring complaints from people who can't be bothered to add a couple lines of XML to customize their project's JDK level.
Upvotes: 2
Reputation: 6487
To make configuration easier, they picked a reasonable default setting. This allows any project that wants to use that default setting to not include that configuration. They picked what they thought would be the most common value and made that the default.
Now, many years have passed. Almost nobody wants to use that default value anymore. Now we all have to explicitly set the value.
Why not default to the JDK version? Because then upgrading the JDK would likely break existing projects.
Why not change the default value to be what most current projects use? Because that will likely break any existing project that uses the default.
Upvotes: 3