List of usage examples for org.apache.maven.execution MavenExecutionRequest setProjectPresent
MavenExecutionRequest setProjectPresent(boolean isProjectPresent);
From source file:net.oneandone.maven.plugins.prerelease.util.Maven.java
License:Apache License
/** * Creates an DefaultMaven instance, initializes it form parentRequest (in Maven, this is done by MavenCli - also by * loading settings)./*from ww w .j a v a2 s.c o m*/ */ public void build(FileNode basedir, Map<String, String> userProperties, ExecutionListener theExecutionListener, FilteringMojoExecutor.Filter filter, String... goals) throws BuildException { DefaultPlexusContainer container; org.apache.maven.Maven maven; MavenExecutionRequest request; MavenExecutionResult result; BuildException exception; FilteringMojoExecutor mojoExecutor; request = DefaultMavenExecutionRequest.copy(parentSession.getRequest()); container = (DefaultPlexusContainer) parentSession.getContainer(); try { maven = container.lookup(org.apache.maven.Maven.class); } catch (ComponentLookupException e) { throw new IllegalStateException(e); } request.setPom(basedir.join("pom.xml").toPath().toFile()); request.setProjectPresent(true); request.setGoals(Arrays.asList(goals)); request.setBaseDirectory(basedir.toPath().toFile()); request.setUserProperties(merged(request.getUserProperties(), userProperties)); request.setExecutionListener(theExecutionListener); mojoExecutor = FilteringMojoExecutor.install(container, filter); log.info("[" + basedir + " " + filter + "] mvn " + props(request.getUserProperties()) + Separator.SPACE.join(goals)); nestedOutputOn(); try { result = maven.execute(request); } finally { nestedOutputOff(); mojoExecutor.uninstall(); } exception = null; for (Throwable e : result.getExceptions()) { if (exception == null) { exception = new BuildException("build failed: " + e, e); } else { exception.addSuppressed(e); } } if (exception != null) { throw exception; } }