use of org.apache.maven.shared.invoker.InvocationRequest in project scala-maven-plugin by davidB.
the class ScalaContinuousTestMojo method postCompileActions.
@Override
protected void postCompileActions() throws Exception {
if (test == null) {
getLog().info("Now running all the unit tests. Use -Dtest=FooTest to run a single test by name");
} else {
getLog().info("Now running tests matching: " + test);
}
final InvocationRequest request = new DefaultInvocationRequest();
request.setLocalRepositoryDirectory(localRepositoryPath);
request.setInteractive(false);
request.setErrorHandler(new SystemOutHandler(true));
request.setOutputHandler(new SystemOutHandler(true));
request.setBaseDirectory(project.getBasedir());
request.setPomFile(new File(project.getBasedir(), "pom.xml"));
request.setGoals(getMavenGoals());
request.setOffline(false);
if (test != null) {
Properties properties = new Properties();
properties.put("test", test);
request.setProperties(properties);
}
if (getLog().isDebugEnabled()) {
try {
getLog().debug("Executing: " + new MavenCommandLineBuilder().build(request));
} catch (CommandLineConfigurationException e) {
getLog().debug("Failed to display command line: " + e.getMessage());
}
}
try {
invoker.execute(request);
} catch (final MavenInvocationException e) {
getLog().debug("Error invoking Maven: " + e.getMessage(), e);
throw new BuildFailureException("Maven invocation failed. " + e.getMessage(), e);
}
}
use of org.apache.maven.shared.invoker.InvocationRequest in project maven-plugins by apache.
the class InvokerPropertiesTest method testConfigureRequestProject.
public void testConfigureRequestProject() throws Exception {
Properties props = new Properties();
InvokerProperties facade = new InvokerProperties(props);
InvocationRequest request = new DefaultInvocationRequest();
File tempPom = File.createTempFile("maven-invoker-plugin-test", ".pom");
File tempDir = tempPom.getParentFile();
request.setBaseDirectory(tempDir);
facade.configureInvocation(request, 0);
assertEquals(tempDir, request.getBaseDirectory());
assertEquals(null, request.getPomFile());
props.setProperty("invoker.project", tempPom.getName());
request.setBaseDirectory(tempDir);
facade.configureInvocation(request, 0);
assertEquals(tempDir, request.getBaseDirectory());
assertEquals(tempPom, request.getPomFile());
props.setProperty("invoker.project", "");
request.setBaseDirectory(tempDir);
facade.configureInvocation(request, 0);
assertEquals(tempDir, request.getBaseDirectory());
assertEquals(null, request.getPomFile());
tempPom.delete();
}
use of org.apache.maven.shared.invoker.InvocationRequest in project maven-plugins by apache.
the class InvokerPropertiesTest method testConfigureRequestRecursion.
public void testConfigureRequestRecursion() throws Exception {
Properties props = new Properties();
InvokerProperties facade = new InvokerProperties(props);
InvocationRequest request = new DefaultInvocationRequest();
request.setRecursive(true);
facade.configureInvocation(request, 0);
assertTrue(request.isRecursive());
request.setRecursive(false);
facade.configureInvocation(request, 0);
assertFalse(request.isRecursive());
props.setProperty("invoker.nonRecursive", "true");
facade.configureInvocation(request, 0);
assertFalse(request.isRecursive());
props.setProperty("invoker.nonRecursive", "false");
facade.configureInvocation(request, 0);
assertTrue(request.isRecursive());
}
use of org.apache.maven.shared.invoker.InvocationRequest in project maven-plugins by apache.
the class InvokerPropertiesTest method testConfigureRequestFailureBehavior.
public void testConfigureRequestFailureBehavior() throws Exception {
Properties props = new Properties();
InvokerProperties facade = new InvokerProperties(props);
InvocationRequest request = new DefaultInvocationRequest();
request.setReactorFailureBehavior(InvocationRequest.ReactorFailureBehavior.FailAtEnd);
facade.configureInvocation(request, 0);
assertEquals(InvocationRequest.ReactorFailureBehavior.FailAtEnd, request.getReactorFailureBehavior());
props.setProperty("invoker.failureBehavior", InvocationRequest.ReactorFailureBehavior.FailNever.getLongOption());
facade.configureInvocation(request, 0);
assertEquals("fail-never", request.getReactorFailureBehavior().getLongOption());
}
use of org.apache.maven.shared.invoker.InvocationRequest in project maven-plugins by apache.
the class InvokerPropertiesTest method testConfigureRequestProfiles.
public void testConfigureRequestProfiles() throws Exception {
Properties props = new Properties();
InvokerProperties facade = new InvokerProperties(props);
InvocationRequest request = new DefaultInvocationRequest();
request.setProfiles(Collections.singletonList("test"));
facade.configureInvocation(request, 0);
assertEquals(Collections.singletonList("test"), request.getProfiles());
props.setProperty("invoker.profiles", "verify");
facade.configureInvocation(request, 0);
assertEquals(Collections.singletonList("verify"), request.getProfiles());
props.setProperty("invoker.profiles", " ");
facade.configureInvocation(request, 0);
assertEquals(Arrays.asList(new String[0]), request.getProfiles());
props.setProperty("invoker.profiles", " clean , test verify ,");
facade.configureInvocation(request, 0);
assertEquals(Arrays.asList(new String[] { "clean", "test", "verify" }), request.getProfiles());
props.setProperty("invoker.profiles", "");
facade.configureInvocation(request, 0);
assertEquals(Arrays.asList(new String[0]), request.getProfiles());
}
Aggregations