use of org.apache.maven.settings.Settings in project che by eclipse.
the class MavenServerImpl method getSettings.
private Settings getSettings(SettingsBuilder builder, MavenSettings settings, Properties systemProperties, Properties userProperties) throws RemoteException {
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setGlobalSettingsFile(settings.getGlobalSettings());
request.setUserSettingsFile(settings.getUserSettings());
request.setSystemProperties(systemProperties);
request.setUserProperties(userProperties);
Settings result = new Settings();
try {
result = builder.build(request).getEffectiveSettings();
} catch (SettingsBuildingException e) {
MavenServerContext.getLogger().info(e);
}
result.setOffline(settings.isOffline());
if (settings.getLocalRepository() != null) {
result.setLocalRepository(settings.getLocalRepository().getPath());
}
if (result.getLocalRepository() == null) {
result.setLocalRepository(new File(System.getProperty("user.home"), ".m2/repository").getPath());
}
return result;
}
use of org.apache.maven.settings.Settings in project intellij-community by JetBrains.
the class Maven30ServerEmbedderImpl method buildSettings.
private static Settings buildSettings(SettingsBuilder builder, MavenServerSettings settings, Properties systemProperties, Properties userProperties) throws RemoteException {
SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile(settings.getGlobalSettingsFile());
settingsRequest.setUserSettingsFile(settings.getUserSettingsFile());
settingsRequest.setSystemProperties(systemProperties);
settingsRequest.setUserProperties(userProperties);
Settings result = new Settings();
try {
result = builder.build(settingsRequest).getEffectiveSettings();
} catch (SettingsBuildingException e) {
Maven3ServerGlobals.getLogger().info(e);
}
result.setOffline(settings.isOffline());
if (settings.getLocalRepository() != null) {
result.setLocalRepository(settings.getLocalRepository().getPath());
}
if (result.getLocalRepository() == null) {
result.setLocalRepository(new File(SystemProperties.getUserHome(), ".m2/repository").getPath());
}
return result;
}
use of org.apache.maven.settings.Settings in project maven-plugins by apache.
the class JavadocUtilTest method testIsValidPackageList.
/**
* Method to test isValidPackageList()
*
* @throws Exception if any
*/
public void testIsValidPackageList() throws Exception {
Settings settings = null;
Proxy proxy;
URL url = null;
URL wrongUrl;
try {
JavadocUtil.isValidPackageList(url, settings, false);
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
}
url = new File(getBasedir(), "/pom.xml").toURL();
assertTrue(JavadocUtil.isValidPackageList(url, settings, false));
try {
assertFalse(JavadocUtil.isValidPackageList(url, settings, true));
} catch (IOException e) {
assertTrue(true);
}
url = this.getClass().getResource("/JavadocUtilTest-package-list.txt").toURI().toURL();
assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
url = new URL("http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list");
assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
wrongUrl = new URL("http://maven.apache.org/plugins/maven-javadoc-plugin/apidocs/package-list2");
try {
JavadocUtil.isValidPackageList(wrongUrl, settings, false);
fail();
} catch (IOException e) {
assertTrue(true);
}
// real proxy
ProxyServer proxyServer = null;
AuthAsyncProxyServlet proxyServlet;
try {
proxyServlet = new AuthAsyncProxyServlet();
proxyServer = new ProxyServer(proxyServlet);
proxyServer.start();
settings = new Settings();
assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
try {
JavadocUtil.isValidPackageList(wrongUrl, settings, false);
fail();
} catch (IOException e) {
assertTrue(true);
}
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
}
Map<String, String> authentications = new HashMap<String, String>();
authentications.put("foo", "bar");
// wrong auth
try {
proxyServlet = new AuthAsyncProxyServlet(authentications);
proxyServer = new ProxyServer(proxyServlet);
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive(true);
proxy.setHost(proxyServer.getHostName());
proxy.setPort(proxyServer.getPort());
proxy.setProtocol("http");
settings.addProxy(proxy);
JavadocUtil.isValidPackageList(url, settings, false);
fail();
} catch (FileNotFoundException e) {
assertTrue(true);
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
}
// auth proxy
try {
proxyServlet = new AuthAsyncProxyServlet(authentications);
proxyServer = new ProxyServer(proxyServlet);
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive(true);
proxy.setHost(proxyServer.getHostName());
proxy.setPort(proxyServer.getPort());
proxy.setProtocol("http");
proxy.setUsername("foo");
proxy.setPassword("bar");
settings.addProxy(proxy);
assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
try {
JavadocUtil.isValidPackageList(wrongUrl, settings, false);
fail();
} catch (IOException e) {
assertTrue(true);
}
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
}
// timeout
try {
// more than 2000, see fetchURL
proxyServlet = new AuthAsyncProxyServlet(authentications, 3000);
proxyServer = new ProxyServer(proxyServlet);
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive(true);
proxy.setHost(proxyServer.getHostName());
proxy.setPort(proxyServer.getPort());
proxy.setProtocol("http");
proxy.setUsername("foo");
proxy.setPassword("bar");
settings.addProxy(proxy);
JavadocUtil.isValidPackageList(url, settings, true);
fail();
} catch (SocketTimeoutException e) {
assertTrue(true);
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
}
// nonProxyHosts
try {
proxyServlet = new AuthAsyncProxyServlet(authentications);
proxyServer = new ProxyServer(proxyServlet);
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive(true);
proxy.setHost(proxyServer.getHostName());
proxy.setPort(proxyServer.getPort());
proxy.setProtocol("http");
proxy.setUsername("foo");
proxy.setPassword("bar");
proxy.setNonProxyHosts("maven.apache.org");
settings.addProxy(proxy);
assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
}
}
use of org.apache.maven.settings.Settings in project maven-plugins by apache.
the class JavadocUtilTest method testHideProxyPassword.
/**
* Method to test the hiding proxy password.
*
* @throws Exception if any
*/
public void testHideProxyPassword() throws Exception {
String cmdLine = "javadoc.exe " + "-J-Dhttp.proxySet=true " + "-J-Dhttp.proxyHost=127.0.0.1 " + "-J-Dhttp.proxyPort=80 " + "-J-Dhttp.nonProxyHosts=\"www.google.com|*.somewhere.com\" " + "-J-Dhttp.proxyUser=\"toto\" " + "-J-Dhttp.proxyPassword=\"toto\" " + "@options @packages";
cmdLine = JavadocUtil.hideProxyPassword(cmdLine, null);
assertFalse(cmdLine.contains("-J-Dhttp.proxyPassword=\"****\""));
Settings settings = new Settings();
Proxy proxy = new Proxy();
proxy.setActive(true);
proxy.setHost("127.0.0.1");
proxy.setPort(80);
proxy.setProtocol("http");
proxy.setUsername("toto");
proxy.setPassword("toto");
proxy.setNonProxyHosts("www.google.com|*.somewhere.com");
settings.addProxy(proxy);
cmdLine = "javadoc.exe " + "-J-Dhttp.proxySet=true " + "-J-Dhttp.proxyHost=127.0.0.1 " + "-J-Dhttp.proxyPort=80 " + "-J-Dhttp.nonProxyHosts=\"www.google.com|*.somewhere.com\" " + "-J-Dhttp.proxyUser=\"toto\" " + "-J-Dhttp.proxyPassword=\"toto\" " + "@options @packages";
cmdLine = JavadocUtil.hideProxyPassword(cmdLine, settings);
assertTrue(cmdLine.contains("-J-Dhttp.proxyPassword=\"****\""));
settings = new Settings();
proxy = new Proxy();
proxy.setActive(true);
proxy.setHost("127.0.0.1");
proxy.setPort(80);
proxy.setProtocol("http");
proxy.setUsername("toto");
proxy.setNonProxyHosts("www.google.com|*.somewhere.com");
settings.addProxy(proxy);
cmdLine = "javadoc.exe " + "-J-Dhttp.proxySet=true " + "-J-Dhttp.proxyHost=127.0.0.1 " + "-J-Dhttp.proxyPort=80 " + "-J-Dhttp.nonProxyHosts=\"www.google.com|*.somewhere.com\" " + "-J-Dhttp.proxyUser=\"toto\" " + "-J-Dhttp.proxyPassword=\"toto\" " + "@options @packages";
cmdLine = JavadocUtil.hideProxyPassword(cmdLine, null);
assertFalse(cmdLine.contains("-J-Dhttp.proxyPassword=\"****\""));
}
use of org.apache.maven.settings.Settings in project maven-plugins by apache.
the class InterpolationTest method testProfilesWithNoFile.
public void testProfilesWithNoFile() throws Exception {
InvokerMojo invokerMojo = new InvokerMojo();
setVariableValueToObject(invokerMojo, "profiles", Arrays.asList("zloug"));
setVariableValueToObject(invokerMojo, "settings", new Settings());
String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + "resources" + File.separatorChar + "unit" + File.separatorChar + "profiles-from-file";
List<String> profiles = invokerMojo.getProfiles(new File(dirPath));
assertTrue(profiles.contains("zloug"));
assertEquals(1, profiles.size());
}
Aggregations