You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jerome Lacoste <je...@gmail.com> on 2008/05/23 07:59:51 UTC

Re: [clover:instrument forked lifecyle] modified project artifacts list do not get propagated to the WAR/EAR mojos. Is this expected ?

On Wed, May 21, 2008 at 8:09 PM, Jerome Lacoste
<je...@gmail.com> wrote:
> Clovered EAR / WAR artifacts lacks clovered versions of transitive
> dependencies. Cf:  http://jira.codehaus.org/browse/MCLOVER-70. This
> issue still exists in the maven clover plugin 3.7 from atlassian.
> We've tested maven 2.0.6 and 2.0.9.
>
> The issue is caused apparently as the clover plugins tries to modify
> the project artifacts list in a forked lifecycle, but the change is
> not propagated to the mojos executed later on. My understanding is
> that the way clover tries to achieve this is not possible, as the
> forked lifecycle ends before the war/ear mojos are executed.
>
> Can someone confirm this reasoning, and maybe provide an alternative
> solution to this problem ?

Changing to developer list. [original message:
http://www.mail-archive.com/users@maven.apache.org/msg85358.html]

The issue might look to come from the DefaultPluginManager.
http://maven.apache.org/ref/2.0.4/maven-core/xref/org/apache/maven/plugin/DefaultPluginManager.html#1117
[1]

It looks like it overrides the transitive dependencies after
re-resolving them, hence losing the changes the clover plugin made.
The non transitive dependencies don't seem to be overriden (with a
comment mentionning clover).

Does anyone know if the difference in behavior between transitive and
non transitive dependencies is intended ?

We're going to try to patch the class and open an issue if that works for us.

Jerome

[1] Cf. http://developer.atlassian.com/jira/browse/CLMVN-25?focusedCommentId=16756#action_16756

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [clover:instrument forked lifecyle] modified project artifacts list do not get propagated to the WAR/EAR mojos. Is this expected ?

Posted by Jerome Lacoste <je...@gmail.com>.
On Fri, May 23, 2008 at 7:59 AM, Jerome Lacoste
<je...@gmail.com> wrote:
> On Wed, May 21, 2008 at 8:09 PM, Jerome Lacoste
> <je...@gmail.com> wrote:
>> Clovered EAR / WAR artifacts lacks clovered versions of transitive
>> dependencies. Cf:  http://jira.codehaus.org/browse/MCLOVER-70. This
>> issue still exists in the maven clover plugin 3.7 from atlassian.
>> We've tested maven 2.0.6 and 2.0.9.

I've had some time to investigate the problem further.

Maven re-resolves the list of transitive dependencies for each plugin
it runs that uses requiresDependencyResolution.  The results are
different depending in which phase the plugin is to going to get ran.
At the same time, clover with its "swizzle" method, tried to redefine
the list of dependencies. Doing so, it worked with a set of transitive
dependencies that is going to be discarded in a later phase by maven.

I managed to hack maven to do what I want. I've added a way to
register the "swizzle" functionality from clover so that this
operation gets registered and applied each time the artifacts are
re-resolved and the transitive dependencies reset:

     public void setArtifacts( Set artifacts )
     {
         this.artifacts = artifacts;

         // flush the calculated artifactMap
         this.artifactMap = null;
+
+        postProcessArtifacts();
     }

+    public static interface ArtifactPostProcessor {
+        Set convert( Set artifacts );
+    }
+
+    private List artifactPostProcessors = new ArrayList();
+
+    public void addArtifactPostProcessor( ArtifactPostProcessor
artifactPostProcessor )
+    {
+        artifactPostProcessors.add( artifactPostProcessor );
+    }
+
+    private void postProcessArtifacts() {
+        for ( Iterator i = artifactPostProcessors.iterator(); i.hasNext(); )
+        {
+            ArtifactPostProcessor postProcessor =
(ArtifactPostProcessor) i.next();
+
+            this.artifacts = postProcessor.convert( this.artifacts );
+        }
+    }
+

This requires a change of the clover plugin of course. I've tested it
with my simple helloWorld WAR project and all transitive dependencies
are now added properly. I expect it to work with EARs as well.

Not sure what a better solution should be, especially in light of
2.1.x.  A better idea ? Or is there no solution to this problem ?

Jerome

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org