Search code examples
mavenmaven-2maven-3maven-pluginmaven-extension

What'll change about maven extensions according to this line in apache doc?


I found this note in the Maven's documentation:

You can add elements to this classloader by extensions. These are loaded into the same place as ${maven.home}/lib and hence are available to the Maven core and all plugins for the current project and subsequent projects (in future, we plan to remove it from subsequent projects).

I couldn't understand what they mean by "subsequent projects" here. As far as I understand, extensions are enhancements to lifecycle phases of Maven and are not project specific. So it makes sense to work for all the Maven projects.

Question: Can anyone explain what this statement means "in future, we plan to remove it from subsequent projects"


Solution

  • First an extensions can be extensions of a life cycle but not need to. You can implement an extensions also as an EventSpy for example.

    This documentation is related to the Core Classloader which is available within such extensions and makes it also possible to enhance it via an extensions. This classloader contains those files from ${maven.home}/lib which is not a good idea and not necessary. It would be better having only the Maven Plugin API there and it's instances which are currently used and not more...

    There existing some extensions like Wagon which are using to make a transport in special cases possible which could be project specific.

    Starting with Maven 3.3.1 the core extensions mechanism has been improved to make loading project specific extensions more simpler which means they are located into ${maven.projectBasedir}/.mvn/extensions.xml file and also being loading from an repository. Before 3.3.1 you need to do that manually via mvn -Dmaven.ext.class.path=extension.jar.