Search in sources :

Example 6 with MavenConfigurationImpl

use of io.fabric8.maven.util.MavenConfigurationImpl in project fabric8 by jboss-fuse.

the class MavenProxyServletSupportTest method createResolver.

private MavenResolver createResolver(String localRepo, List<String> remoteRepos, String proxyProtocol, String proxyHost, int proxyPort, String proxyUsername, String proxyPassword, String proxyNonProxyHosts) {
    Hashtable<String, String> props = new Hashtable<>();
    props.put("localRepository", localRepo);
    if (remoteRepos != null) {
        props.put("repositories", join(remoteRepos, ","));
    }
    MavenConfigurationImpl config = new MavenConfigurationImpl(new DictionaryPropertyResolver(props), null);
    if (proxyProtocol != null) {
        Proxy proxy = new Proxy();
        proxy.setProtocol(proxyProtocol);
        proxy.setHost(proxyHost);
        proxy.setPort(proxyPort);
        proxy.setUsername(proxyUsername);
        proxy.setPassword(proxyPassword);
        proxy.setNonProxyHosts(proxyNonProxyHosts);
        config.getSettings().addProxy(proxy);
    }
    return new AetherBasedResolver(config);
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) Proxy(org.apache.maven.settings.Proxy) Hashtable(java.util.Hashtable) DictionaryPropertyResolver(org.ops4j.util.property.DictionaryPropertyResolver) AetherBasedResolver(io.fabric8.maven.url.internal.AetherBasedResolver)

Example 7 with MavenConfigurationImpl

use of io.fabric8.maven.util.MavenConfigurationImpl in project fabric8 by jboss-fuse.

the class ProfileWatcherImpl method retrieveMavenConfiguration.

protected MavenConfiguration retrieveMavenConfiguration() {
    MavenConfiguration mavenConfiguration = null;
    try {
        Configuration configuration = configurationAdmin.get().getConfiguration("org.ops4j.pax.url.mvn");
        if (configuration != null) {
            Dictionary dictonary = configuration.getProperties();
            if (dictonary != null) {
                DictionaryPropertyResolver resolver = new DictionaryPropertyResolver(dictonary);
                mavenConfiguration = new MavenConfigurationImpl(resolver, "org.ops4j.pax.url.mvn");
            }
        }
    } catch (IOException e) {
        LOG.error("Error retrieving maven configuration", e);
    }
    return mavenConfiguration;
}
Also used : MavenConfiguration(io.fabric8.maven.util.MavenConfiguration) Dictionary(java.util.Dictionary) MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) Configuration(org.osgi.service.cm.Configuration) MavenConfiguration(io.fabric8.maven.util.MavenConfiguration) DictionaryPropertyResolver(org.ops4j.util.property.DictionaryPropertyResolver) IOException(java.io.IOException)

Example 8 with MavenConfigurationImpl

use of io.fabric8.maven.util.MavenConfigurationImpl in project fabric8 by jboss-fuse.

the class Log4jLogQuery method loadCoords.

protected String loadCoords(String coords, String filePath, String classifier) throws IOException {
    String[] split = coords.split("/");
    if (split != null && split.length > 2) {
        String groupId = split[0];
        String artifactId = split[1];
        String version = split[2];
        if (resolver == null) {
            Properties defaultProperties = getDefaultProperties();
            Properties systemProperties = System.getProperties();
            if (config == null) {
                Properties combined = new Properties();
                combined.putAll(defaultProperties);
                combined.putAll(systemProperties);
                if (properties != null) {
                    combined.putAll(properties);
                }
                config = new MavenConfigurationImpl(new PropertiesPropertyResolver(combined), ServiceConstants.PID);
            }
            resolver = new AetherBasedResolver(config);
        }
        File file = resolver.resolveFile(groupId, artifactId, classifier, "jar", version);
        if (file.exists() && file.isFile()) {
            if (isRoot(filePath)) {
                return jarIndex(file);
            }
            String fileUri = file.toURI().toString();
            URL url = new URL("jar:" + fileUri + "!" + filePath);
            return loadString(url);
        }
    }
    return null;
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) PropertiesPropertyResolver(org.ops4j.util.property.PropertiesPropertyResolver) Properties(java.util.Properties) File(java.io.File) URL(java.net.URL) AetherBasedResolver(io.fabric8.maven.url.internal.AetherBasedResolver)

Example 9 with MavenConfigurationImpl

use of io.fabric8.maven.util.MavenConfigurationImpl in project fabric8 by jboss-fuse.

the class AetherTimeoutTest method basicMavenConfiguration.

private MavenConfigurationImpl basicMavenConfiguration(int timeoutInMs) {
    Properties properties = new Properties();
    properties.setProperty("pid.localRepository", "target/" + UUID.randomUUID().toString());
    properties.setProperty("pid.timeout", Integer.toString(timeoutInMs));
    properties.setProperty("pid.globalChecksumPolicy", "ignore");
    properties.setProperty("pid.connection.retryCount", "0");
    return new MavenConfigurationImpl(new PropertiesPropertyResolver(properties), "pid");
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) PropertiesPropertyResolver(org.ops4j.util.property.PropertiesPropertyResolver) Properties(java.util.Properties)

Example 10 with MavenConfigurationImpl

use of io.fabric8.maven.util.MavenConfigurationImpl in project fabric8 by jboss-fuse.

the class AetherTimeoutTest method basicMavenConfigurationWithTwoTimeouts.

private MavenConfigurationImpl basicMavenConfigurationWithTwoTimeouts(int readTimeoutInMs, int connectTimeoutInMs) {
    Properties properties = new Properties();
    properties.setProperty("pid.localRepository", "target/" + UUID.randomUUID().toString());
    properties.setProperty("pid.timeout", Integer.toString(readTimeoutInMs));
    properties.setProperty("pid.socket.connectionTimeout", Integer.toString(connectTimeoutInMs));
    properties.setProperty("pid.globalChecksumPolicy", "ignore");
    properties.setProperty("pid.connection.retryCount", "0");
    return new MavenConfigurationImpl(new PropertiesPropertyResolver(properties), "pid");
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) PropertiesPropertyResolver(org.ops4j.util.property.PropertiesPropertyResolver) Properties(java.util.Properties)

Aggregations

MavenConfigurationImpl (io.fabric8.maven.util.MavenConfigurationImpl)11 PropertiesPropertyResolver (org.ops4j.util.property.PropertiesPropertyResolver)5 Properties (java.util.Properties)4 DictionaryPropertyResolver (org.ops4j.util.property.DictionaryPropertyResolver)4 AetherBasedResolver (io.fabric8.maven.url.internal.AetherBasedResolver)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 MavenResolver (io.fabric8.maven.MavenResolver)2 MavenConfiguration (io.fabric8.maven.util.MavenConfiguration)2 TimeoutException (java.util.concurrent.TimeoutException)2 File (java.io.File)1 URL (java.net.URL)1 Dictionary (java.util.Dictionary)1 Hashtable (java.util.Hashtable)1 Proxy (org.apache.maven.settings.Proxy)1 RepositoryException (org.eclipse.aether.RepositoryException)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 ArtifactNotFoundException (org.eclipse.aether.transfer.ArtifactNotFoundException)1 ArtifactTransferException (org.eclipse.aether.transfer.ArtifactTransferException)1 PropertyResolver (org.ops4j.util.property.PropertyResolver)1