You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2018/08/04 07:26:46 UTC

[maven-studies] branch maven-extention-demo updated: describe and compare 4 methods to configure extensions

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch maven-extention-demo
in repository https://gitbox.apache.org/repos/asf/maven-studies.git


The following commit(s) were added to refs/heads/maven-extention-demo by this push:
     new 2c893d3  describe and compare 4 methods to configure extensions
2c893d3 is described below

commit 2c893d33e1723f12798cfcc09185645b0f15d02d
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Aug 4 09:26:26 2018 +0200

    describe and compare 4 methods to configure extensions
---
 src/it/-Dmaven.ext.class.path/pom.xml |  6 ++----
 src/it/mvnExtensions/pom.xml          |  6 ++----
 src/it/pomExtension/pom.xml           |  6 ++----
 src/site/apt/index.apt                | 31 +++++++++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/src/it/-Dmaven.ext.class.path/pom.xml b/src/it/-Dmaven.ext.class.path/pom.xml
index a99bd86..63f8032 100755
--- a/src/it/-Dmaven.ext.class.path/pom.xml
+++ b/src/it/-Dmaven.ext.class.path/pom.xml
@@ -19,10 +19,8 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<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/maven-v4_0_0.xsd">
+<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>
 
diff --git a/src/it/mvnExtensions/pom.xml b/src/it/mvnExtensions/pom.xml
index 9f78ada..f4903f2 100755
--- a/src/it/mvnExtensions/pom.xml
+++ b/src/it/mvnExtensions/pom.xml
@@ -19,10 +19,8 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<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/maven-v4_0_0.xsd">
+<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>
 
diff --git a/src/it/pomExtension/pom.xml b/src/it/pomExtension/pom.xml
index aa7bb88..15ff2af 100755
--- a/src/it/pomExtension/pom.xml
+++ b/src/it/pomExtension/pom.xml
@@ -19,10 +19,8 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<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/maven-v4_0_0.xsd">
+<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>
 
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index f53078c..68d5131 100644
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -35,6 +35,37 @@ Maven Extension Demo Study
 
   []
 
+* Configuring Maven Extensions
+
+  A Maven extension is a library that goes into
+  {{{/guides/mini/guide-maven-classloading.html#Core_Classloader}Maven Core classloader}}.
+
+  There are multiple methods available to declare a library as an  extension:
+
+  [[1]] classical POM's {{{/ref/current/maven-model/maven.html#class_build}<<<project.build.extensions.extension>>>}} or
+    {{{/ref/current/maven-model/maven.html#class_plugin}<<<project.build.plugins.plugin.extensions>>>}} (since Maven 2),
+
+  [[2]] put jars in Maven <<<$\{maven.home\}/lib>>> (since Maven 2) or <<<$\{maven.home\}/lib/ext>>> (since Maven 3),
+
+  [[3]] use <<<-Dmaven.ext.class.path=[path to files]>>> (since Maven 3.0.2,
+    see {{{https://issues.apache.org/jira/browse/MNG-4936}MNG-4936}}),
+
+  [[4]] configure in {{{/ref/current/maven-embedder/core-extensions.html}<<<mvn/extensions.xml>>>}} (since Maven 3.3.1)
+
+  []
+
+  Declaring an extension in POM is the most classical and flexible way to do: the only drawback is that the extension
+  is activated after POM reading, which can be too late for some very specific use cases like EventSpy.
+
+  Installing an extension directly inside Maven installation avoids the previous limitation, but is not flexible. 
+
+  <<<-Dmaven.ext.class.path=[path to files]>>> is a little bit more flexible, but remains not configured into
+  the build, which is not suitable to ensure an extension is available at build time.
+
+  <<<mvn/extensions.xml>>> is the ultimate solution for these use cases. Its only drawback is that it has been
+  added only in Maven 3.3.1.
+
+
 * References
 
   * {{{/guides/mini/guide-maven-classloading.html} Guide to Maven Classloading}}