-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I would imagine you will need to interact more with the project in this
case, but I'm not sure. If there isn't already, there should be methods
on MavenProject that allow something similar to:

project.addCompileClasspathElement( File|Artifact element );

using a similar pattern to:

project.addCompileSourceRoot( String sourceRoot );

Personally, I'm not that wild about using params as return values (which
is very much like what modifying the List of artifacts would be)...on
the other hand, if you need to modify something (since the return type
is void), I think modifying the project instance is much more intuitive.
But that's just my opinion...

Vincent, if the aforementioned addCompileClasspathElement() doesn't
exist, let me know.

- -john

Vincent Massol wrote:
> Hi,
> 
> I need to add the Clover JAR defined in the Clover plugin to the compile CP
> of the project using the Clover plugin. This is because the Clover
> instruments the source code and thus when compiling the instrumenting
> sources the Clover JAR needs to be in the CP.
> 
> I've tried doing the following in my CloverMojo:
> 
>     /**
>      * @parameter expression="${plugin.artifacts}"
>      * @required
>      */
>     private List pluginArtifacts;
> 
> [...]
> 
>     private void addCloverDependencyToCompileClasspath()
>     {
>         Artifact cloverArtifact = null;
>         Iterator artifacts = this.pluginArtifacts.iterator();
>         while (artifacts.hasNext())
>         {
>             Artifact artifact = (Artifact) artifacts.next();
>             if (artifact.getArtifactId().equalsIgnoreCase("clover"))
>             {
>                 cloverArtifact = artifact;
>                 break;
>             }
>         }
> 
>         List artifactsToAdd = new ArrayList();
>         artifactsToAdd.add(cloverArtifact);
>         
>         this.project.addArtifacts(artifactsToAdd, 
>             new DefaultArtifactFactory()); 
>     }
> 
> The cloverArtifact variable is correctly filled with the Clover artifact but
> the addArtifact() call does not seem to add the Clover JAR to the CP since
> the compilation gives an error saying that the Clover JAR is missing.
> 
> Is that the right way to dynamically add an artifact to the CP?
> 
> Thanks
> -Vincent
> 
> 
>       
> 
>       
>               
> ___________________________________________________________________________ 
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
> T�l�chargez cette version sur http://fr.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFCrc7uK3h2CZwO/4URAmI/AJ0d+/QBq6rnN4+rj2FvzIIClQDdrACeITme
1zjvVUCFytcdXQq6w6qqkps=
=EODv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to