use of org.apache.maven.execution.MavenExecutionRequest in project yeoman-maven-plugin by trecloux.
the class YeomanMojoTest method getMavenProject.
private MavenProject getMavenProject(String pomPath) throws Exception {
File pom = new File(pomPath);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setPom(pom);
ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
return lookup(ProjectBuilder.class).build(pom, configuration).getProject();
}
use of org.apache.maven.execution.MavenExecutionRequest 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.MavenExecutionRequest in project maven-plugins by apache.
the class AbstractDeployMojo method getProxy.
/**
* Get proxy information for Maven 3.
*
* @param repository
* @param settingsDecrypter
* @return
*/
private ProxyInfo getProxy(Repository repository, SettingsDecrypter settingsDecrypter) {
String protocol = repository.getProtocol();
String url = repository.getUrl();
getLog().debug("repository protocol " + protocol);
String originalProtocol = protocol;
// so we will check both
if (StringUtils.equalsIgnoreCase("dav", protocol) && url.startsWith("dav:")) {
url = url.substring(4);
if (url.startsWith("http")) {
try {
URL urlSite = new URL(url);
protocol = urlSite.getProtocol();
getLog().debug("found dav protocol so transform to real transport protocol " + protocol);
} catch (MalformedURLException e) {
getLog().warn("fail to build URL with " + url);
}
}
} else {
getLog().debug("getProxy 'protocol': " + protocol);
}
if (mavenSession != null && protocol != null) {
MavenExecutionRequest request = mavenSession.getRequest();
if (request != null) {
List<Proxy> proxies = request.getProxies();
if (proxies != null) {
for (Proxy proxy : proxies) {
if (proxy.isActive() && (protocol.equalsIgnoreCase(proxy.getProtocol()) || originalProtocol.equalsIgnoreCase(proxy.getProtocol()))) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy));
proxy = result.getProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost(proxy.getHost());
// so hackish for wagon the protocol is https for site dav:
// dav:https://dav.codehaus.org/mojo/
// proxy.getProtocol() );
proxyInfo.setType(protocol);
proxyInfo.setPort(proxy.getPort());
proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
proxyInfo.setUserName(proxy.getUsername());
proxyInfo.setPassword(proxy.getPassword());
getLog().debug("found proxyInfo " + ("host:port " + proxyInfo.getHost() + ":" + proxyInfo.getPort() + ", " + proxyInfo.getUserName()));
return proxyInfo;
}
}
}
}
}
getLog().debug("getProxy 'protocol': " + protocol + " no ProxyInfo found");
return null;
}
use of org.apache.maven.execution.MavenExecutionRequest 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.MavenExecutionRequest in project maven-archetype by apache.
the class RemoteCatalogArchetypeDataSource method getProxy.
private ProxyInfo getProxy(String protocol) {
MavenSession session = legacySupport.getSession();
if (session != null && protocol != null) {
MavenExecutionRequest request = session.getRequest();
if (request != null) {
List<Proxy> proxies = request.getProxies();
if (proxies != null) {
for (Proxy proxy : proxies) {
if (proxy.isActive() && protocol.equalsIgnoreCase(proxy.getProtocol())) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy));
proxy = result.getProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost(proxy.getHost());
proxyInfo.setType(proxy.getProtocol());
proxyInfo.setPort(proxy.getPort());
proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
proxyInfo.setUserName(proxy.getUsername());
proxyInfo.setPassword(proxy.getPassword());
return proxyInfo;
}
}
}
}
}
return null;
}
Aggregations