I'll report to the Maven user list and warn on
http://jira.codehaus.org/browse/MDEPLOY-157
Thank you,
Julien
From: Benjamin Bentmann
Date: Tue, 11 Mar 2014 21:20:13 +0100
Julien CARSIQUE wrote:
Here it is: the "deployAtEnd" option doesn't work after building a module involving my plugin because a new "Class realm
plugin" is then created and its static fields are reset (in that case, the
org.apache.maven.plugin.deploy.DeployMojo.readyProjectsCounter field).
Aether has nothing to do with the way Maven manages class
loaders for plugins, i.e. you should reach out to the Maven user
list instead.
Also, your analysis suggests a bug in the maven-deploy-plugin
in that it relies on the erroneous assumption that a single
class loader is used per plugin through out a multi-module
build.
Benjamin
On 11/03/2014 19:53, Julien CARSIQUE wrote:
Hi,
I recently discovered an issue with my plugin
(ant-assembly-maven-plugin) based on Aether and I'm having hard
time to analyze the cause.
The issue raised using maven-deploy-plugin's deployAtEnd option
but it likely has nothing to do with that plugin and revealed a
more general issue in my implementation.
Here it is: the "deployAtEnd" option doesn't work after building a
module involving my plugin because a new "Class realm plugin" is
then created and its static fields are reset (in that case, the
org.apache.maven.plugin.deploy.DeployMojo.readyProjectsCounter
field).
Code from maven-deploy-plugin (readyProjectsCounter restarted to
zero will never equal to reactorProjects.size(), projectsReady
will be always false):
@Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true )
private List<MavenProject> reactorProjects;
private static final AtomicInteger readyProjectsCounter = new AtomicInteger();
org.apache.maven.plugin.deploy.DeployMojo.execute() {
boolean projectsReady = readyProjectsCounter.incrementAndGet() == reactorProjects.size();
In the following sample case, the culprit
ant-assembly-maven-plugin is called by the
"nuxeo-distribution-resources" module (after that, no deployment
will ever happen since the counter has been reset and will never
reach the number of "reactorProjects"):
$ mvn clean deploy -Pqa -DskipTests -pl nuxeo-functional-tests,nuxeo-launcher,nuxeo-distribution-resources -nsu -X|grep maven-deploy-plugin
[DEBUG] Goal: org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy)
[INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) @ nuxeo-functional-tests ---
[DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.8.1:
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1
[DEBUG] Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.8.1
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1, parent: sun.misc.Launcher$AppClassLoader@4821e115]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy' with basic configurator -->
[DEBUG] Goal: org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy)
[INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) @ nuxeo-launcher ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1, parent: sun.misc.Launcher$AppClassLoader@4821e115]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy' with basic configurator -->
[DEBUG] Goal: org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy)
[INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) @ nuxeo-distribution-resources ---
[DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.8.1:
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1--724569306
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1--724569306
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1--724569306
[DEBUG] Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.8.1
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.8.1--724569306, parent: sun.misc.Launcher$AppClassLoader@4821e115]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy' with basic configurator -->
Could someone explain or guess why/when a "new class realm
plugin>org.apache.maven.plugins:maven-deploy-plugin" is created
(in bold) instead of reusing the previous one?
What could cause that in my code?
The full log of above reproduction case: http://ubuntuone.com/0WeyQGBzaDacZWh97CwcvE
The ant-assembly-maven-plugin source code: https://github.com/nuxeo/ant-assembly-maven-plugin
Issue management: https://jira.nuxeo.com/browse/NXBT-739
Thanks,
--
Julien
Carsique
DevOps Nuxeo, Paris, France
|