use of org.apache.maven.execution.DefaultMavenExecutionRequest in project intellij-community by JetBrains.
the class MavenEmbedder method createRequest.
private MavenExecutionRequest createRequest(File file, List<String> activeProfiles, List<String> inactiveProfiles, List<String> goals) {
Properties executionProperties = myEmbedderSettings.getProperties();
if (executionProperties == null)
executionProperties = new Properties();
DefaultEventDispatcher dispatcher = new DefaultEventDispatcher();
dispatcher.addEventMonitor(new DefaultEventMonitor(myLogger));
// subclassing because in DefaultMavenExecutionRequest field isRecursive is always false
MavenExecutionRequest result = new DefaultMavenExecutionRequest(myLocalRepository, mySettings, dispatcher, goals, file.getParent(), createProfileManager(activeProfiles, inactiveProfiles, executionProperties), executionProperties, new Properties(), true) {
private boolean myIsRecursive;
@Override
public boolean isRecursive() {
return myIsRecursive;
}
@Override
public void setRecursive(final boolean recursive) {
myIsRecursive = recursive;
}
};
result.setPomFile(file.getPath());
result.setRecursive(myEmbedderSettings.isRecursive());
return result;
}
use of org.apache.maven.execution.DefaultMavenExecutionRequest in project maven-plugins by apache.
the class AbstractSiteDeployWebDavTest method davDeployThruProxyWithoutAuthzInProxy.
@Test
public void davDeployThruProxyWithoutAuthzInProxy() throws Exception {
FileUtils.cleanDirectory(siteTargetPath);
SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler(siteTargetPath);
try {
File pluginXmlFile = getTestFile("src/test/resources/unit/deploy-dav/pom.xml");
AbstractMojo mojo = getMojo(pluginXmlFile);
assertNotNull(mojo);
SiteMavenProjectStub siteMavenProjectStub = new SiteMavenProjectStub("deploy-dav");
// olamy, Note : toto is something like foo or bar for french folks :-)
String siteUrl = "dav:http://toto.com/site/";
siteMavenProjectStub.getDistributionManagement().getSite().setUrl(siteUrl);
setVariableValueToObject(mojo, "project", siteMavenProjectStub);
Settings settings = new Settings();
Proxy proxy = new Proxy();
//dummy proxy
proxy.setActive(true);
proxy.setHost("localhost");
proxy.setPort(simpleDavServerHandler.getPort());
proxy.setProtocol("http");
proxy.setNonProxyHosts("www.google.com|*.somewhere.com");
settings.addProxy(proxy);
setVariableValueToObject(mojo, "settings", settings);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setProxies(Arrays.asList(proxy));
MavenSession mavenSession = new MavenSession(getContainer(), null, request, null);
setVariableValueToObject(mojo, "mavenSession", mavenSession);
File inputDirectory = new File("src/test/resources/unit/deploy-dav/target/site");
setVariableValueToObject(mojo, "inputDirectory", inputDirectory);
mojo.execute();
assertContentInFiles();
assertTrue(requestsContainsProxyUse(simpleDavServerHandler.httpRequests));
for (HttpRequest rq : simpleDavServerHandler.httpRequests) {
log.info(rq.toString());
}
} finally {
simpleDavServerHandler.stop();
}
}
use of org.apache.maven.execution.DefaultMavenExecutionRequest in project maven-plugins by apache.
the class DefaultDependencyResolverTest method newMavenSession.
protected MavenSession newMavenSession(MavenProject project) {
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
MavenExecutionResult result = new DefaultMavenExecutionResult();
MavenRepositorySystemSession repoSession = new MavenRepositorySystemSession();
repoSession.setLocalRepositoryManager(LegacyLocalRepositoryManager.wrap(new StubArtifactRepository("target/local-repo"), null));
MavenSession session = new MavenSession(getContainer(), repoSession, request, result);
session.setCurrentProject(project);
session.setProjects(Arrays.asList(project));
return session;
}
use of org.apache.maven.execution.DefaultMavenExecutionRequest in project meecrowave by apache.
the class MeecrowaveRunMojoTest method run.
@Test
public void run() throws Exception {
final File moduleBase = jarLocation(MeecrowaveRunMojoTest.class).getParentFile().getParentFile();
final File basedir = new File(moduleBase, "src/test/resources/" + getClass().getSimpleName());
final File pom = new File(basedir, "pom.xml");
final MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setBaseDirectory(basedir);
final ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
final DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory().newInstance(repositorySession, new LocalRepository(new File(moduleBase, "target/fake"), "")));
configuration.setRepositorySession(repositorySession);
final MavenProject project = mojo.lookup(ProjectBuilder.class).build(pom, configuration).getProject();
final MavenSession session = mojo.newMavenSession(project);
final int port;
try (final ServerSocket serverSocket = new ServerSocket(0)) {
port = serverSocket.getLocalPort();
}
final MojoExecution execution = mojo.newMojoExecution("run");
execution.getConfiguration().addChild(new Xpp3Dom("httpPort") {
{
setValue(Integer.toString(port));
}
});
final InputStream in = System.in;
final CountDownLatch latch = new CountDownLatch(1);
System.setIn(new InputStream() {
// just to not return nothing
private int val = 2;
@Override
public int read() throws IOException {
try {
latch.await();
} catch (final InterruptedException e) {
Thread.interrupted();
fail(e.getMessage());
}
return val--;
}
});
final Thread runner = new Thread() {
@Override
public void run() {
try {
mojo.executeMojo(session, project, execution);
} catch (final Exception e) {
fail(e.getMessage());
}
}
};
try {
runner.start();
for (int i = 0; i < 120; i++) {
try {
assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + port + "/api/test")));
assertTrue(IOUtils.toString(new URL("http://localhost:" + port + "/api/test/model")).contains("first_name"));
assertTrue(IOUtils.toString(new URL("http://localhost:" + port + "/api/test/model")).contains("last_name"));
assertTrue(IOUtils.toString(new URL("http://localhost:" + port + "/api/test/model")).contains("firstname"));
assertTrue(IOUtils.toString(new URL("http://localhost:" + port + "/api/test/model")).contains("null"));
latch.countDown();
break;
} catch (final Exception | AssertionError e) {
Thread.sleep(500);
}
}
} finally {
runner.join(TimeUnit.MINUTES.toMillis(1));
System.setIn(in);
if (runner.isAlive()) {
runner.interrupt();
fail("Runner didn't terminate properly");
}
}
}
Aggregations