You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-commits@maven.apache.org by bu...@apache.org on 2015/03/11 22:24:40 UTC

svn commit: r943402 - in /websites/staging/maven/trunk/content: ./ maven-site-1.0-site.jar reference/ reference/maven-classloading.html

Author: buildbot
Date: Wed Mar 11 21:24:39 2015
New Revision: 943402

Log:
Staging update by buildbot for maven

Added:
    websites/staging/maven/trunk/content/reference/
    websites/staging/maven/trunk/content/reference/maven-classloading.html
Modified:
    websites/staging/maven/trunk/content/   (props changed)
    websites/staging/maven/trunk/content/maven-site-1.0-site.jar

Propchange: websites/staging/maven/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Mar 11 21:24:39 2015
@@ -1 +1 @@
-1665820
+1666016

Modified: websites/staging/maven/trunk/content/maven-site-1.0-site.jar
==============================================================================
Binary files - no diff available.

Added: websites/staging/maven/trunk/content/reference/maven-classloading.html
==============================================================================
--- websites/staging/maven/trunk/content/reference/maven-classloading.html (added)
+++ websites/staging/maven/trunk/content/reference/maven-classloading.html Wed Mar 11 21:24:39 2015
@@ -0,0 +1,342 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ | Generated by Apache Maven Doxia at 2015-03-11
+ | Rendered using Apache Maven Stylus Skin 1.5
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <title>Maven &#x2013; Maven classloading</title>
+    <style type="text/css" media="all">
+      @import url("../css/maven-base.css");
+      @import url("../css/maven-theme.css");
+      @import url("../css/site.css");
+    </style>
+    <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
+        <meta name="Date-Revision-yyyymmdd" content="20150311" />
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+                                                    
+<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
+                                                        
+<script type="text/javascript">_uacct = "UA-140879-1";
+        urchinTracker();</script>
+                              </head>
+  <body class="composite">
+    <div id="banner">
+                                      <a href=".././" id="bannerLeft">
+                                                <img src="../images/apache-maven-project-2.png" alt="" />
+                </a>
+                        <span id="bannerRight">
+                                                <img src="../images/maven-logo-2.gif" alt="" />
+                </span>
+            <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="breadcrumbs">
+            
+                                   <div class="xleft">
+                          <a href="http://www.apache.org/" class="externalLink">Apache</a>
+        &gt;
+                  <a href="../index.html">Maven</a>
+        &gt;
+        Maven classloading
+        </div>
+            <div class="xright">        
+                                    Last Published: 2015-03-11
+            </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="leftColumn">
+      <div id="navcolumn">
+             
+                                                   <h5>Main</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../index.html">Welcome</a>
+            </li>
+          </ul>
+                       <h5>Get Maven</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../download.html">Download</a>
+            </li>
+                  <li class="none">
+                  <a href="../docs/history.html">Releases History</a>
+            </li>
+                  <li class="none">
+                  <a href="../docs/3.2.5/release-notes.html">Release Notes (3.2.5)</a>
+            </li>
+                  <li class="none">
+                  <a href="../docs/3.1.1/release-notes.html">Release Notes (3.1.1)</a>
+            </li>
+                  <li class="none">
+                  <a href="../docs/3.0.5/release-notes.html">Release Notes (3.0.5)</a>
+            </li>
+                  <li class="none">
+                  <a href="../release-notes-all.html">All Release Notes</a>
+            </li>
+                  <li class="none">
+                  <a href="http://www.apache.org/licenses/" class="externalLink">License</a>
+            </li>
+                  <li class="none">
+                  <a href="../security.html">Security</a>
+            </li>
+          </ul>
+                       <h5>IDE Integration</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../eclipse-plugin.html">Eclipse</a>
+            </li>
+                  <li class="none">
+                  <a href="../netbeans-module.html">NetBeans</a>
+            </li>
+          </ul>
+                       <h5>About Maven</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../what-is-maven.html">What is Maven?</a>
+            </li>
+                  <li class="none">
+                  <a href="../maven-features.html">Features</a>
+            </li>
+                  <li class="none">
+                  <a href="../general.html">FAQ (official)</a>
+            </li>
+                  <li class="none">
+                  <a href="http://docs.codehaus.org/display/MAVENUSER/FAQs-1" class="externalLink">FAQ (unofficial)</a>
+            </li>
+                  <li class="none">
+                  <a href="../support-and-training.html">Support and Training</a>
+            </li>
+          </ul>
+                       <h5>Documentation</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../plugins/index.html">Maven Plugins</a>
+            </li>
+                  <li class="none">
+                  <a href="../guides/index.html">Index (category)</a>
+            </li>
+                  <li class="none">
+                  <a href="../run-maven/index.html">Running Maven</a>
+            </li>
+                                                                                                                                            <li class="collapsed">
+                  <a href="../users/index.html">User Centre</a>
+                  </li>
+                                                                                                        <li class="collapsed">
+                  <a href="../plugin-developers/index.html">Plugin Developer Centre</a>
+                  </li>
+                  <li class="none">
+                  <a href="../repository/index.html">Maven Repository Centre</a>
+            </li>
+                  <li class="none">
+                  <a href="../developers/index.html">Maven Developer Centre</a>
+            </li>
+                  <li class="none">
+                  <a href="../articles.html">Books and Resources</a>
+            </li>
+                  <li class="none">
+                  <a href="http://docs.codehaus.org/display/MAVENUSER/Home" class="externalLink">Wiki</a>
+            </li>
+          </ul>
+                       <h5>Community</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../community.html">Community Overview</a>
+            </li>
+                  <li class="none">
+                  <a href="../guides/development/guide-helping.html">How to Contribute</a>
+            </li>
+                  <li class="none">
+                  <a href="../guides/mini/guide-maven-evangelism.html">Maven Repository</a>
+            </li>
+                  <li class="none">
+                  <a href="../users/getting-help.html">Getting Help</a>
+            </li>
+                  <li class="none">
+                  <a href="../issue-tracking.html">Issue Tracking</a>
+            </li>
+                  <li class="none">
+                  <a href="../source-repository.html">Source Repository</a>
+            </li>
+                  <li class="none">
+                  <a href="../team-list.html">The Maven Team</a>
+            </li>
+          </ul>
+                       <h5>Project Documentation</h5>
+                  <ul>
+                                                                                                                                                              <li class="collapsed">
+                  <a href="../project-info.html">Project Information</a>
+                  </li>
+          </ul>
+                       <h5>Maven Projects</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="../ant-tasks/index.html">Ant Tasks</a>
+            </li>
+                  <li class="none">
+                  <a href="../archetype/index.html">Archetype</a>
+            </li>
+                  <li class="none">
+                  <a href="../doxia/index.html">Doxia</a>
+            </li>
+                  <li class="none">
+                  <a href="../jxr/index.html">JXR</a>
+            </li>
+                  <li class="none">
+                  <a href="../ref/current">Maven</a>
+            </li>
+                  <li class="none">
+                  <a href="../pom/index.html">Parent POMs</a>
+            </li>
+                  <li class="none">
+                  <a href="../plugins/index.html">Plugins</a>
+            </li>
+                  <li class="none">
+                  <a href="../plugin-testing/index.html">Plugin Testing</a>
+            </li>
+                  <li class="none">
+                  <a href="../plugin-tools/index.html">Plugin Tools</a>
+            </li>
+                  <li class="none">
+                  <a href="../apache-resource-bundles/index.html">Resource Bundles</a>
+            </li>
+                  <li class="none">
+                  <a href="../scm/index.html">SCM</a>
+            </li>
+                  <li class="none">
+                  <a href="../shared/index.html">Shared Components</a>
+            </li>
+                  <li class="none">
+                  <a href="../skins/index.html">Skins</a>
+            </li>
+                  <li class="none">
+                  <a href="../surefire/index.html">Surefire</a>
+            </li>
+                  <li class="none">
+                  <a href="../wagon/index.html">Wagon</a>
+            </li>
+          </ul>
+                       <h5>ASF</h5>
+                  <ul>
+                  <li class="none">
+                  <a href="http://www.apache.org/foundation/how-it-works.html" class="externalLink">How Apache Works</a>
+            </li>
+                  <li class="none">
+                  <a href="http://www.apache.org/foundation/" class="externalLink">Foundation</a>
+            </li>
+                  <li class="none">
+                  <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsoring Apache</a>
+            </li>
+                  <li class="none">
+                  <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a>
+            </li>
+          </ul>
+                                 <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
+          <img alt="Built by Maven" src="../images/logos/maven-feather.png"/>
+        </a>
+                       
+                               </div>
+    </div>
+    <div id="bodyColumn">
+      <div id="contentBox">
+        <h1>Maven classloading</h1>
+<p>![](maven-classloading.png)</p>
+<div class="section">
+<h2><a name="ClassWorlds_bootstrap_classloader"></a>ClassWorlds bootstrap classloader</h2>
+<p>This classloader is created and managed by the calling environment: JVM launcher, integration testing harness, etc.</p>
+<p>During normal command line Maven invocation this is the JVM System classloader and contains classes from <tt>${maven.home}/boot/plexus-classworlds-*.jar</tt> and classes from <tt>-javaagent</tt>.</p></div>
+<div class="section">
+<h2><a name="Maven_Core_classloader"></a>Maven Core classloader</h2>
+<p>This classloader contains core Maven runtime classes like MavenProject, AsbtractMojo and so on. This is the classloader set as the &#x201c;container realm&#x201d; in the Plexus container instance unless Maven Extensions classloader is created (see below).</p>
+<p>Contents of this classloader are configured in <tt>${maven.home}/bin/m2.conf</tt> and typically contains <tt>${maven.home}/lib/ext/*.jar</tt> and <tt>${maven.home}/lib/*.jar</tt>.</p></div>
+<div class="section">
+<h2><a name="Maven_Core_Extensions_classloaders"></a>Maven Core Extensions classloaders</h2>
+<p>Core Extensions is a new mechanism introduced in Maven 3.3.0 which allows additional components to be loaded into Maven Core as part of a build session.</p>
+<p>Each core extension is loaded in a separate classloader and there is no mechanism to share classes among core extensions. Core extensions classloaders use Maven Core classloader as the parent and have access to both exported and internal Maven Core classes.</p>
+<p>Core extension can use <tt>META-INF/maven/extension.xml</tt> descriptor to declare packages and artifacts exported by the extension. If the descriptor is not present, no packages or artifacts are exported, but the extension can still contribute components to Maven Core extension points.</p>
+<p>Core extensions are configured in <tt>${maven.projectBasedir}/.mvn/extensions.xml</tt> configuration file.</p>
+
+<div class="source">
+<div class="source">
+<pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;extensions&gt;
+  &lt;extension&gt;
+    &lt;groupId&gt;...&lt;/groupId&gt;
+    &lt;artifactId&gt;...&lt;/artifactId&gt;
+    &lt;version&gt;...&lt;/version&gt;
+  &lt;/extension&gt;
+  &lt;extension&gt;...&lt;/extension&gt;
+  ...
+&lt;/extensions&gt;
+</pre></div></div>
+<p>Core extensions are loaded as part of Maven runtime startup and disposed of as part of Maven runtime shutdown.</p></div>
+<div class="section">
+<h2><a name="Maven_extensions_classloader"></a>Maven extensions classloader</h2>
+<p>Maven extensions classloader aggregates packages exported by core extensions realms. It also loads additional classpath entries specified in <tt>-Dmaven.ext.class.path</tt> command line parameter.</p>
+<p>Maven extensions classloader is created only when core extensions are configured for the build. If created, it will be set as &#x201c;container realm&#x201d; in the Plexus container. </p></div>
+<div class="section">
+<h2><a name="Maven_API_classloader"></a>Maven API classloader</h2>
+<p>Maven API classloader aggregates exported packages from Maven Core and Maven Core Extensions classloaders. Maven API classloader does not include any classes directly.</p>
+<p>Maven API uses approximate JVM Bootstrap classloader as its parent. (there is no API to access JVM Bootstrap classloader, implementation uses <tt>ClassLoader.getSystemClassLoader().getParent()</tt>). The parent classloader does not contain any application or javaagent classes, which allows for consistent Maven API classpath regardless how Maven JVM was launched.</p></div>
+<div class="section">
+<h2><a name="Build_Extension_classloaders"></a>Build Extension classloaders</h2>
+<p>Modern Maven 3.x build extensions are build extensions that either consist of multiple artifacts or have <tt>META-INF/maven/extension.xml</tt>. Each modern build extension is loaded in a a fully isolated classloader, i.e. it is not possible to share classes or inject components among extensions.</p>
+<p>Maven guarantees that each distinct modern build extension (as identified by plugin groupId, artifactId, version and set of dependecies) is loaded by one and only one extensions classloader and the classloader is wired to all projects that use the extension.</p>
+<p>Build extension classloaders use ClassWorld bootstrap classloader as the parent, which allows build extensions access to <tt>-javaagent</tt> classes.</p></div>
+<div class="section">
+<h2><a name="Project_classloaders"></a>Project classloaders</h2>
+<p>Project classloader aggregates Maven API packages, packages exported by project build extensions. </p>
+<p>Project classloaders use Maven API classloader as the parent and import exported classes from project build extension realms. Legacy Maven 2.x build extensions, i.e. extensions that consist of single artifact which does not include <tt>META-INF/maven/extension.xml</tt> descriptor, are directly in project classloaders.</p>
+<p>Maven guarantees there will be one and only one project classloader for each unique set of project build extensions and the same classloader will be used by all projects that have the set of build extensions.</p></div>
+<div class="section">
+<h2><a name="Plugin_classloaders"></a>Plugin classloaders</h2>
+<p>Plugin classloaders are wired differently for projects with and without build extensions.</p>
+<p>For projects without build extensions, single classloader is created for each plugin identified by groupId:artifactId:version and the classloader imports API packages from Maven API classloader. Maven will create one and only one classloader for each unique plugin+dependency combination.</p>
+<p>For projects that use build extensions, plugin classloaders are wired to project classloaders. This gives plugin code access to both Maven API packages and packages exported by the project build extensions. Maven will create one and only one classlaoder for each unique plugin+dependencies+buid-extensions combination.</p>
+<p>All plugin classloaders use ClassWorlds bootstrap classloader as the parent. This provides relatively clean and therefore consistent plugin classpath, while still allowing plugins access to <tt>-javaagent</tt> classes (see <a class="externalLink" href="http://jira.codehaus.org/browse/MNG-4747">MNG-4747</a>).</p>
+<p>Reporting plugins are wired differently still, but reporting plugins are a special case and are outside of the scope of this document.</p></div>
+<div class="section">
+<h2><a name="Exported_artifacts_and_packages"></a>Exported artifacts and packages</h2>
+<p>Maven Core, Session and Build Extensions use <tt>META-INF/maven/extension.xml</tt> descriptor to declare API packages and artifacts exported by the classloader. </p>
+
+<div class="source">
+<div class="source">
+<pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;extension&gt;
+ &lt;!-- 
+   | list of exported classname prefixes.
+   --&gt;
+ &lt;exportedPackages&gt;
+   &lt;exportedPackage&gt;org.something.myextension&lt;/exportedPackage&gt;
+ &lt;/exportedPackages&gt;
+     
+ &lt;!-- 
+   | exported artifacts in groupId:artifactId format 
+   --&gt;
+ &lt;exportedArtifacts&gt;
+   &lt;exportedArtifact&gt;org.company:myextension&lt;/exportedArtifact&gt;
+ &lt;/exportedArtifacts&gt;
+&lt;/extension&gt;
+</pre></div></div></div>
+      </div>
+    </div>
+    <div class="clear">
+      <hr/>
+    </div>
+    <div id="footer">
+      <div class="xright">
+        &#169;            2002-2015
+              The Apache Software Foundation
+            
+                          - <a href="http://maven.apache.org/privacy-policy.html">Privacy Policy</a>.
+        Apache Maven, Maven, Apache, the Apache feather logo, and the Apache Maven project logos are trademarks of The Apache Software Foundation.
+      </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+  </body>
+</html>