Search in sources :

Example 11 with MavenRepositoryURL

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

the class DeploymentUpdater method parseMavenRepositoryURLs.

protected List<MavenRepositoryURL> parseMavenRepositoryURLs() throws MalformedURLException {
    List<MavenRepositoryURL> repositories = new ArrayList<MavenRepositoryURL>();
    String text = getRepositories();
    if (Strings.isNotBlank(text)) {
        StringTokenizer iter = new StringTokenizer(text);
        while (iter.hasMoreTokens()) {
            String url = iter.nextToken();
            if (url.endsWith(",")) {
                url = url.substring(0, url.length() - 1);
            }
            MavenRepositoryURL mavenUrl = new MavenRepositoryURL(url);
            repositories.add(mavenUrl);
        }
    }
    return repositories;
}
Also used : StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL)

Example 12 with MavenRepositoryURL

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

the class OpenShiftPomDeployer method updateRepositories.

/**
 * Ensure that the given maven repositories are added to the pom.xml
 */
protected void updateRepositories(Element repositories, List<MavenRepositoryURL> repos) throws XPathExpressionException {
    for (MavenRepositoryURL repo : repos) {
        String url = repo.getURL().toString();
        String id = repo.getId();
        if (Strings.isNotBlank(url)) {
            Element repository = recreateChild(repositories, "repository[url='" + url + "']", "repository", 2);
            if (Strings.isNotBlank(id)) {
                createAndAppendChild(repository, "id", 3, id);
            }
            createAndAppendChild(repository, "url", 3, url);
            addRepositoryFlag(repository, "releases", repo.isReleasesEnabled());
            addRepositoryFlag(repository, "snapshots", repo.isSnapshotsEnabled());
        }
    }
}
Also used : Element(org.w3c.dom.Element) MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL)

Aggregations

MavenRepositoryURL (io.fabric8.maven.util.MavenRepositoryURL)12 Test (org.junit.Test)5 MalformedURLException (java.net.MalformedURLException)4 ArrayList (java.util.ArrayList)4 File (java.io.File)3 JarFile (java.util.jar.JarFile)2 Element (org.w3c.dom.Element)2 Parser (io.fabric8.maven.util.Parser)1 OpenShiftPomDeployer (io.fabric8.openshift.agent.OpenShiftPomDeployer)1 StringTokenizer (java.util.StringTokenizer)1 LocalRepository (org.eclipse.aether.repository.LocalRepository)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 Document (org.w3c.dom.Document)1