For some reason my stock Ubuntu 13.10 Maven installation uses old plugins. Most blatantly the compiler plugin is version 2.0.2 which defaults to Java 1.3:
$ mvn --show-version compile
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-14-generic", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[...]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project simple: Compilation failure
[ERROR] [...]/simple/src/main/java/org/sonatype/mavenbook/App.java:[11,17] error: generics are not supported in -source 1.3
Compilation fails because of ArrayList<Integer> a = new ArrayList<Integer>();
which uses generics. Now I know I can force maven to use the current compiler plugin (see generics are not supported in -source 1.3) but I would rather solve the root cause than to add every plugin I use to my pom file. If there is no other solution I will add plugin specifications to a parent pom, but I would still be interested by which rational maven chooses plugin versions.
My environment: I have no settings.xml in my local m2 repository, my (stock Ubuntu) /etc/maven/m2.conf
looks like this:
main is org.apache.maven.cli.MavenCli from plexus.core
set maven.home default ${user.home}/m2
[plexus.core]
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar
And my /etc/maven/settings.xml
is essentially empty except for a few comments and empty xml tags. The projects pom is the default generated by mvn archetype:generate -DgroupId=org.sonatype.mavenbook -DartifactId=simple -Dpackage=org.sonatype.mavenbook -Dversion=1.0-SNAPSHOT
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook</groupId>
<artifactId>simple</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>simple</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Any advice?