Search in sources :

Example 1 with MavenRepositoryURL

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

the class AetherBasedResolver method selectRepositories.

private List<RemoteRepository> selectRepositories() {
    List<RemoteRepository> list = new ArrayList<RemoteRepository>();
    List<MavenRepositoryURL> urls = Collections.emptyList();
    try {
        urls = m_config.getRepositories();
    } catch (MalformedURLException exc) {
        LOG.error("invalid repository URLs", exc);
    }
    for (MavenRepositoryURL r : urls) {
        if (r.isMulti()) {
            addSubDirs(list, r.getFile());
        } else {
            addRepo(list, r);
        }
    }
    return list;
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL)

Example 2 with MavenRepositoryURL

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

the class AetherBasedResolver method addLocalSubDirs.

private void addLocalSubDirs(List<LocalRepository> list, File parentDir) {
    if (!parentDir.isDirectory()) {
        LOG.debug("Repository marked with @multi does not resolve to a directory: " + parentDir);
        return;
    }
    for (File repo : parentDir.listFiles()) {
        if (repo.isDirectory()) {
            try {
                String repoURI = repo.toURI().toString() + "@id=" + repo.getName();
                LOG.debug("Adding repo from inside multi dir: " + repoURI);
                addLocalRepo(list, new MavenRepositoryURL(repoURI));
            } catch (MalformedURLException e) {
                LOG.error("Error resolving repo url of a multi repo " + repo.toURI());
            }
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL) File(java.io.File) JarFile(java.util.jar.JarFile)

Example 3 with MavenRepositoryURL

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

the class AetherBasedResolver method selectDefaultRepositories.

List<LocalRepository> selectDefaultRepositories() {
    List<LocalRepository> list = new ArrayList<LocalRepository>();
    List<MavenRepositoryURL> urls = Collections.emptyList();
    try {
        urls = m_config.getDefaultRepositories();
    } catch (MalformedURLException exc) {
        LOG.error("invalid repository URLs", exc);
    }
    for (MavenRepositoryURL r : urls) {
        if (r.isMulti()) {
            addLocalSubDirs(list, r.getFile());
        } else {
            addLocalRepo(list, r);
        }
    }
    return list;
}
Also used : MalformedURLException(java.net.MalformedURLException) LocalRepository(org.eclipse.aether.repository.LocalRepository) ArrayList(java.util.ArrayList) MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL)

Example 4 with MavenRepositoryURL

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

the class MavenRepositoryURLTest method testSimpleSpec.

@Test
public void testSimpleSpec() throws MalformedURLException {
    String spec = "http://repo1.maven.org/maven2";
    MavenRepositoryURL repo = new MavenRepositoryURL(spec);
    Assert.assertTrue(repo.isReleasesEnabled());
    Assert.assertFalse(repo.isSnapshotsEnabled());
    Assert.assertEquals("repo_" + String.valueOf("http://repo1.maven.org/maven2/".hashCode()), repo.getId());
}
Also used : MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL) Test(org.junit.Test)

Example 5 with MavenRepositoryURL

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

the class MavenRepositoryURLTest method testSpecWithSnapshotsAndId.

@Test
public void testSpecWithSnapshotsAndId() throws MalformedURLException {
    String spec = "http://repo1.maven.org/maven2@snapshots@id=central";
    MavenRepositoryURL repo = new MavenRepositoryURL(spec);
    Assert.assertTrue(repo.isReleasesEnabled());
    Assert.assertTrue(repo.isSnapshotsEnabled());
    Assert.assertEquals("central", repo.getId());
    spec = "http://repo1.maven.org/maven2@id=central@snapshots";
    repo = new MavenRepositoryURL(spec);
    Assert.assertTrue(repo.isReleasesEnabled());
    Assert.assertTrue(repo.isSnapshotsEnabled());
    Assert.assertEquals("central", repo.getId());
}
Also used : MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL) Test(org.junit.Test)

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