You may want to check how we do this in m2eclipse [1] or during maven
performance regression tests [2].
[1]
http://github.com/sonatype/m2eclipse-core/blob/master/org.maven.ide.eclipse/src/org/maven/ide/eclipse/internal/embedder/MavenImpl.java
[2]
https://svn.sonatype.org/spice/trunk/maven-performance-tests/src/test/java/org/apache/maven/performance/tests/p001/P001EmbedderTest.java
--
Regards,
Igor
Steffen Stundzig wrote:
Hi folks,
sorry for the spam. I'm also posted on users. Whats the correct list for
such plugin developer questions?
---
I've tried the whole day on how can i embedd a call for a maven goal
into my java src. I'm working with maven-3.0-beta-1.
Here are my sample snippets which the appropriate error messages:
public class MavenEmbedTest {
public static void main(String[] args) {
File workingDir = new File("/path/to/a/maven/project");
// [1]
MavenCli cli = new MavenCli();
cli.doMain(new String[] { "package" }, workingDir.getAbsolutePath(),
System.out, System.err);
// [2]
DefaultMaven maven = new DefaultMaven();
DefaultMavenExecutionRequest request = new
DefaultMavenExecutionRequest();
request.setBaseDirectory(workingDir);
List<String> goals = new ArrayList<String>();
goals.add("package");
request.setGoals(goals);
MavenExecutionResult result = maven.execute(request);
// [3]
File pom = new File(workingDir, "pom.xml");
DefaultProjectBuilder projectBuilder = new DefaultProjectBuilder();
ProjectBuildingResult project = projectBuilder.build(pom, new
DefaultProjectBuildingRequest());
}
}
As result of [1] running as local java program, i got:
[ERROR] Error executing Maven.
[ERROR] Cycle detected in component graph in the system:
[ERROR] Caused by: Cyclic requirement detected
[ERROR] Caused by: Edge between
'Vertex{label='org.apache.maven.lifecycle.LifecycleExecutor:default'}'
and
'Vertex{label='org.apache.maven.project.MavenProjectBuilder:default'}'
introduces to cycle in the graph
org.apache.maven.project.MavenProjectBuilder:default -->
org.apache.maven.project.ProjectBuilder:default -->
org.apache.maven.model.building.ModelBuilder:default -->
org.apache.maven.model.plugin.LifecycleBindingsInjector:default -->
org.apache.maven.lifecycle.LifecycleExecutor:default -->
org.apache.maven.project.MavenProjectBuilder:default
As result of [2] I got a NullPointerException, because of the annotated
components were not injected. How can I start the PlexusContainer correctly?
The result of [3] is "RepositorySystem is missing" which is nearly the
same problem as in [2].
What I need is to start a maven plugin, which is deployed in my local
repo and is based on maven3.
Could anybody help my please? Are there any samples or code snippets,
which I could use?
Currently I'm working on a hudson build trigger for maven3 based free
style projects. The trigger checks updates on the maven dependencies and
the schedules a rebuild.
Regards
Steffen...
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]