Dear All,
I think it will be highly unfair to have such a wonderful product as
m2eclipse and having to know all nitty-gritty details of Maven and
Eclipse in order to use it programmatically from other bundles/components.
In order to simplify things, James Ervin and I started another project -
very closely related to m2eclipse - m2eclipse APIs. The purpose - is to
ease programmer's access to the Maven universe. For now we came from our
immediate needs - necessity to find an Artifact, find all Artifact
dependencies as a resolved scoped classpath or mavenize an Eclipse project.
*SVN repository* is at *http://svn.sonatype.org/m2eclipse/branches/api/*
and is tightly coupled with m2eclipse version. Current version 1.0.8 has
been tested with m2e 0.9.2 One of the projects there -
org.maven.ide.eclipse.api.test - shows how to use it from another bundle
(TestHandler.java). Usage is very simplistic:
MavenEclipseApi mavenApi =
(MavenEclipseApi)MavenApiPlugin.getDefault().getMavenEclipseApi();
mavenApi.[API call here] ...
*Update site* is available at:
*http://svn.sonatype.org/m2eclipse/branches/api/org.maven.ide.eclipse.api.site/*
It would be awesome to hear comments - what kind of functionality is
interesting for users.
What we have now is a flat list of calls:
//---------------------------------------------------------------------
/**
* read & parse the POM file from an IProject
*/
public Model parsePom( final IProject project )
throws MavenApiException;
//---------------------------------------------------------------------
/**
* read & parse the POM file from an IFile
*/
public Model parsePom( final IFile file )
throws MavenApiException;
//---------------------------------------------------------------------
/**
* read & parse the POM file from a real File.
* <b>Please use with caution: this is not thread-safe call!! </b>
*/
public Model parsePom( final File file )
throws MavenApiException;
//---------------------------------------------------------------------
/**
* return local repository
*/
public ArtifactRepository localRepository() throws MavenApiException;
//---------------------------------------------------------------------
/**
* take existing Eclipse project and mavenize it with the supplied model
*/
public abstract IProject mavenizeProject( final
ProjectMavenizationRequest req )
throws MavenEclipseApiException
;
//---------------------------------------------------------------------
public abstract Artifact resolveArtifact( final ArtifactMetadata md )
throws MavenApiException
;
//-------------------------------------------------------------------------------------
public abstract MetadataTreeNode resolveArtifactMetadataAsTree(
ArtifactMetadata md
)
throws MavenApiException
;
//-------------------------------------------------------------------------------------
public abstract MavenProject resolveArtifactAsProject( final
Artifact artifact )
throws MavenApiException
;
//-------------------------------------------------------------------------------------
public abstract MetadataGraph resolveArtifactAsScopeGraph( final
ArtifactMetadata md )
throws MavenApiException
;
//-------------------------------------------------------------------------------------
public abstract List<Artifact> resolveArtifactAsClasspath( final
ArtifactMetadata md )
throws MavenApiException
;
public Artifact resolveArtifact( final Artifact artifact )
throws MavenApiException;
//-------------------------------------------------------------------------------------
public abstract Collection<Artifact> findGroup( String groupRegEx )
throws MavenApiException
;
//-------------------------------------------------------------------------------------
public abstract Collection<Artifact> findArtifact( String query )
throws MavenApiException
;
Thanks,
Oleg