You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Marek Psiuk <ma...@agh.edu.pl> on 2011/12/22 00:47:19 UTC

Maven plugin for dependency resolution

Hello,

I am working on a maven plugin which is supposed to write a list of
dependencies (all dependencies, also transitive ones) of the current
artifact to the file. All those dependencies are OSGi bundles which are
used in the following step in a pax runner to launch OSGi environment. I
found aether and managed to write simple POC which lists dependencies that
I need. However I have the following problem. I want my plugin to be usable
in both maven-2.x and maven-3.x and I cannot force aether to work in
maven-2.x.
Is there some uniform way of getting all transitive dependencies of the
current artifact which would be compatible with both maven-2.x and
maven-3.x?

For now I figured out that I can built separate JAR artifact which
assemblies all needed depedencies (aether and others) and then simply do:
    Process p = Runtime
    .getRuntime()
    .exec("java -jar artifact.jar-with-dependencies.jar");

Yeah I know that it's ugly but it works :]. Another workaround would be to
also have this separate JAR and jail it in my own classloader - not that
hard to do.

Anyway I cannot figure out straighforward solution.

I would be thankful for any help.


Kind Regards,

Marek Psiuk

Re: Maven plugin for dependency resolution

Posted by Marek Psiuk <ma...@agh.edu.pl>.
Hi Karl,

thanks for help.
Yes I spotted this depedency-plugin and managed to write simple POC which
works (to some extent).

The thing is that I wanted also to sort of "run" my plugin from standalone
java application (Eclipse -> Run As -> Java Application). Aether is great
for such kind of things. I wonder if You could point me to a source which
tells how to run maven-2 plugins ... outside of maven.


Kind Regards,

Marek Psiuk

On Thu, Dec 22, 2011 at 10:57 AM, Karl Heinz Marbaise <ka...@soebes.de>wrote:

> Hi,
>
> have you taken a look into the maven-dependency-plugin code ? This works as
> well in M2 as well in M3 ...
>
> Aether is intended only for M3 world...within a plugin you can get the
> Dependencies via:
>
> this.project.getArtifacts();
>
> if you inject the MavenProject on your plugin parameters:
>
> /**
> * The Maven project.
> *
> * @parameter expression="${project}"
> * @required
> * @readonly
> */
>    protected MavenProject project;
>
>
> Take a look at:
>
> https://github.com/khmarbaise/Maven-License-Verifier-Plugin/blob/master/src/main/java/com/soebes/maven/plugins/mlv/AbstractLicenseVerifierPlugIn.java
>
> Or take a look at the Maven-dependency-plugin...code...might be a better
> place...
>
> Kind regards
> Karl Heinz Marbaise
>
> -----
> Kind regards
> Karl Heinz Marbaise
> ----
> http://www.soebes.de
> http://www.skmwiki.de
> http://supose.org/wiki/supose
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Maven-plugin-for-dependency-resolution-tp5093256p5094161.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven plugin for dependency resolution

Posted by Karl Heinz Marbaise <ka...@soebes.de>.
Hi,

have you taken a look into the maven-dependency-plugin code ? This works as
well in M2 as well in M3 ...

Aether is intended only for M3 world...within a plugin you can get the
Dependencies via:

this.project.getArtifacts();

if you inject the MavenProject on your plugin parameters:

/**
* The Maven project.
*
* @parameter expression="${project}"
* @required
* @readonly
*/
    protected MavenProject project;


Take a look at:
https://github.com/khmarbaise/Maven-License-Verifier-Plugin/blob/master/src/main/java/com/soebes/maven/plugins/mlv/AbstractLicenseVerifierPlugIn.java

Or take a look at the Maven-dependency-plugin...code...might be a better
place...

Kind regards
Karl Heinz Marbaise

-----
Kind regards
Karl Heinz Marbaise
----
http://www.soebes.de
http://www.skmwiki.de
http://supose.org/wiki/supose
--
View this message in context: http://maven.40175.n5.nabble.com/Maven-plugin-for-dependency-resolution-tp5093256p5094161.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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