Release Notes – Maven 3.3.1

Overview

The Apache Maven team would like to announce the release of Maven Version 3.3.1. The new Maven Version is available for download.

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central place.

Maven 3 aims to ensure backward compatibility with Maven 2, improve usability, increase performance, allow safe embedding, and pave the way to implement many highly demanded features.

The core release is independent of the plugins available. Further releases of plugins will be made separately. See the PluginList for more information.

We hope you enjoy using Maven! If you have any questions, please consult:

The full list of changes can be found in our issue management system.

The full list of all release notes for all versions can be found on the history page of the Maven project.

Release Notes In Detail

The new Maven 3.3.1 Release is just out. Let us take a deeper look into the new features/improvements:

Toolchains

  • In our days it becomes more and more important to be able to use different JDK to be used by Maven itself and which is used to compile/test your production code. This concept is know under the name Toolchains which is unfortunately not very well-known.

  • The handling of the toolchains.xml file has been adjusted with the handling of settings.xml which means it will be searched within the ${maven.home}/conf/ directory and furthermore within the ${user.home}/.m2/ directory.

  • For a better understanding and as an example of the toolchains.xml file has been added to the Maven distribution.

  • Maven has been improved to read the toolchains.xml file during initialization instead of waiting till maven-toolchains-plugin will read it.

  • Maven has a new option to handle global toolchains file -gt file or --global-toolchains file in the spirit of global settings fileMNG-3891.

Core Extensions

  • Core Extension mechanism has been improved to make it simpler to use.

  • The old way (up to Maven 3.2.5) was to create a jar (must be shaded if you have other dependencies) which contains the extension and put it manually into the ${MAVEN_HOME}/lib/ext directory. This means you had to change the Maven installation. The consequence was that everyone who likes to use this needed to change it's installation and makes the on-boarding for a developer much more inconvenient. The other option was to give the path to the jar on command line via mvn -Dmaven.ext.class.path=extension.jar. This has the drawback giving those options to your Maven build every time you are calling Maven. Not very convenient as well.

  • From now on this can be done much more simpler and in a more Maven like way. So you can define an .mvn/extensions.xml file in the project's top level directory which looks like the following:

<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
  <extension>
    <groupId/>
    <artifactId/>
    <version/>
  </extension>
</extensions>
  • Now you can simply use an extension by defining the usual maven coordinates groupId, artifactId, version as any other artifact. Furthermore all transitive dependencies of those extensions will automatically being downloaded from your repository. So no need to create a shaded artifact anymore.

    An other advantage is that the .mvn/ directory is located in the root of your Maven project and in conseuqence is part of your project which means you will check it in along with your project. So everyone who checks out your project automatically can use the extensions.

    One thing is important that the extensions will be resolved from the pluginRepository. This is important if you have configured the pluginRepository different from the repository.

JVM and Command Line Options

  • Project specific jvm and command line options

  • It's really hard to define a general set of options for calling the maven command line. Usually this will be solved by putting this options to a script but this can now simple being done by defining .mvn/maven.config file which contains the configuration options for the command line. For example things like -T3 -U --fail-at-end. So you only have to call maven just by using mvn clean package instead of mvn -T3 -U --fail-at-end clean package and not to miss the -T3 -U --fail-at-end options. The .mvn/maven.config is located in the .mvn directory which is in the root of a multi module build. This directory is part of the project and will be checked in into your version control. This results in being picked by everybody who checks out the project and no need to remember to call this project via mvn -T3 -U --fail-at-end clean package instead of mvn clean package.

  • In Maven it is not simple to define JVM configuration on a per project base. The existing mechanism based on an environment variable MAVEN_OPTS and the usage of ${user.home}/.mavenrc is an other option with the drawback of not being part of the project.

  • Starting with this release you can define JVM configuration via .mvn/jvm.config file which means you can define the options for your build on a per project base. This file will become part of your project and will be checked in along with your project. So no need anymore for MAVEN_OPTS, .mavenrc files. So for example if you put the following JVM options into the .mvn/jvm.config file

-Xmx2048m -Xms1024m -XX:MaxPermSize=512m -Djava.awt.headless=true
  • you don't need to remember of using this options in MAVEN_OPTS or switching between different configurations.

Plugin Goal Invocation from Command Line

If you call a plugin directly from command line like the following:

mvn exec:java

The configuration which is used here can be defined in your pom by using an execution id default-cli.

<project...>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <id>default-cli</id>
            <configuration>
              <mainClass>com.soebes.test.First</mainClass>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Starting with this Maven release you can now define several configuration for different executions on command like the following:

<project...>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <id>default-cli</id>
            <configuration>
              <mainClass>com.soebes.test.First</mainClass>
            </configuration>
          </execution>
          <execution>
            <id>second-cli</id>
            <configuration>
              <mainClass>com.soebes.test.Second</mainClass>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

So if you like to use the configuration given with the execution id: second-cli this can be done like this:

mvn exec:java@second-cli

So now you can define more than one configuration for command line executions.

The above release notes have originally been written by Karl Heinz Marbaise and migrated afterwards to the Apache Maven project.