On 31 May 2016 at 12:22, Igor Fedorenko <i...@ifedorenko.com> wrote:

> There is no good/sane Maven embedding API. You really need to
> reimplement relevant parts of MavenCli and DefaultMaven in your code.
> You can check how we do this in m2e [1], although embedding Maven in
> long-running OSGi application certainly adds its own lever of
> complexity.
>

Thanks for the confirmation, at least I know now that I'm not doing
something stupid :)

I've actually already been using m2e's MavenImpl as a guide for what I
should be doing, it's been quite helpful.

One question that I'm trying to solve now, when resolving dependencies, if
you want to do so without actually building the project it seems that you
would probably have to create your own WorkspaceReader implementation that
will return a dummy artifact when the resolver tries to resolve the jar
artifact, is that correct?  I've tried mavens reactor WorkspaceReader, but
it only returns the pom artifact, the jar artifact remains not found.

[1]
>
> http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
>
> --
> Regards,
> Igor
>
> On Mon, May 30, 2016, at 09:33 PM, James Roper wrote:
> > On 30 May 2016 at 17:39, Michael Osipov <1983-01...@gmx.net> wrote:
> > >
> > > I think, you are looking for Maven Embedder.
> > >
> >
> > No, really, I'm not.  I have been head deep in the maven embedder source
> > code for a day now, and it does not do what you think it does.
> >
> > org.apache.maven.cli.MavenCli, the class I mentioned above, is the
> > primary
> > interface that maven embedder provides.  This is the single public method
> > it offers:
> >
> > public int doMain( CliRequest cliRequest )
> >
> > This is the only method I can find in maven embedder to integrate with
> > maven, and as you can see, it only returns int, there is no way to ask
> > for
> > a list of projects for example. As far as I can see, Maven embedder is
> > only
> > for programmatically issuing execution requests, not for interrogating
> > the
> > build.  In order to interrogate the build, I have had to copy large
> > swaths
> > of code from maven embedder.
> >
> > Is there a better way?
> >
> > > >
> > > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> > > For additional commands, e-mail: dev-h...@maven.apache.org
> > >
> >
> >
> > --
> > *James Roper*
> > *Software Engineer*
> >
> > Lightbend <https://www.lightbend.com/> – Build reactive apps!
> > Twitter: @jroper <https://twitter.com/jroper>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> For additional commands, e-mail: dev-h...@maven.apache.org
>
>


-- 
*James Roper*
*Software Engineer*

Lightbend <https://www.lightbend.com/> – Build reactive apps!
Twitter: @jroper <https://twitter.com/jroper>

Reply via email to