Hi,
after digging around i found a
http://maven.40175.n5.nabble.com/Maven-Embedder-2-0-4-replacement-Where-to-start-td3399113.html
good post which brought me a large step further....
But currently i'm hanging in my code, cause every time i run my code it will
fail with an exception ( throw new IllegalArgumentException( "mavenTools:
null" ))....
which means my initialization/configuration code seemed to be wrong...
MavenProject( RepositorySystem repositorySystem, ProjectBuilder
mavenProjectBuilder,
ProjectBuildingRequest projectBuilderConfiguration, Logger
logger )
{
if ( repositorySystem == null )
{
throw new IllegalArgumentException( "mavenTools: null" );
}
this.mavenProjectBuilder = mavenProjectBuilder;
this.projectBuilderConfiguration = projectBuilderConfiguration;
this.repositorySystem = repositorySystem;
this.logger = logger;
}
So the question is: Does someone has an idea what could be wrong or may be a
better source of information/documentation....?
PlexusContainer pc = null;
try {
pc = getPlexusContainer();
} catch (PlexusContainerException e1) {
LOGGER.error("Failure during creation of plexus container:" ,
e1);
}
RepositorySystemSession repoSession = null;
MavenExecutionRequest mavenExecutionRequest =
createExecutionRequest();
ArtifactRepository localRepository = getLocalRepository();
org.sonatype.aether.RepositorySystem repoSystem = null;
try {
repoSystem = lookup(org.sonatype.aether.RepositorySystem.class);
} catch (ComponentLookupException e2) {
LOGGER.error("ComponentLookupException:" , e2);
} catch (PlexusContainerException e2) {
LOGGER.error("PlexusContainerException:" , e2);
}
MavenRepositorySystemSession mavenRepositorySystemSession = new
MavenRepositorySystemSession();
mavenRepositorySystemSession.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(new
LocalRepository(localRepository
.getBasedir())));
mavenExecutionRequest.setBaseDirectory(workingDirectory);
MavenExecutionResult mavenExecutionResult = new
DefaultMavenExecutionResult();
try {
repoSession = createRepositorySession(mavenExecutionRequest);
} catch (ComponentLookupException e1) {
LOGGER.error("ComponentLookupException:" , e1);
} catch (PlexusContainerException e1) {
LOGGER.error("PlexusContainerException:" , e1);
}
MavenSession session = new MavenSession(pc, repoSession,
mavenExecutionRequest, mavenExecutionResult);
op.setSession(session);
DefaultProjectBuilder defaultProjectBuilder = new
DefaultProjectBuilder();
op.setProjectBuilder(defaultProjectBuilder);
try {
lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest);
ProjectBuildingRequest configuration =
mavenExecutionRequest.getProjectBuildingRequest();
configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_STRICT);
configuration.setRepositorySession(createRepositorySession(mavenExecutionRequest));
MavenProject workspaceProject =
lookup(ProjectBuilder.class).build(new File(workingDirectory, "pom.xml"),
configuration).getProject();
op.setWorkspaceProject(workspaceProject);
op.execute();
result = true;
} catch (MojoExecutionException e) {
LOGGER.error("MojoExecutionException:", e);
} catch (MojoFailureException e) {
LOGGER.error("MojoFailureException:", e);
} catch (MavenExecutionRequestPopulationException e) {
LOGGER.error("MavenExecutionRequestPopulationException:", e);
} catch (ComponentLookupException e) {
LOGGER.error("ComponentLookupException:", e);
} catch (PlexusContainerException e) {
LOGGER.error("PlexusContainerException:", e);
} catch (ProjectBuildingException e) {
LOGGER.error("ProjectBuildingException:", e);
}
Many thanks in advance
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/Integrate-Maven-Plugin-Code-Mojo-s-into-Application-tp3397120p3407981.html
Sent from the Maven - Users mailing list archive at Nabble.com.