Search in sources :

Example 11 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class AetherTestCase method testAetherFetchingDependenciesWithUselessProperties.

@Test
public void testAetherFetchingDependenciesWithUselessProperties() throws Throwable {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.springframework.cloud:spring-cloud-starter-eureka", "1.1.2.RELEASE");
    Assert.assertNotNull(result);
    File artifact = result.artifact();
    boolean exists = false;
    try {
        Assert.assertNotNull(artifact);
        Assert.assertTrue(artifact.exists());
        exists = true;
        List<ArtifactResult> deps = result.dependencies();
        Assert.assertEquals(10, deps.size());
        log.debug("deps = " + deps);
    } finally {
        if (exists) {
            // delete this one
            Assert.assertTrue(artifact.delete());
        }
    }
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 12 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class AetherTestCase method testFilterOverrides.

@Test
public void testFilterOverrides() throws Throwable {
    CmrRepository repository = createAetherRepository();
    RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
    ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.osgi:org.osgi.core", "4.0.0");
    Assert.assertNotNull(result);
    Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
    File artifact = result.artifact();
    boolean exists = false;
    try {
        Assert.assertNotNull(artifact);
        Assert.assertTrue(artifact.exists());
        exists = true;
        Assert.assertNotNull(result.filter());
        Assert.assertTrue(result.filter().accept("org/osgi/test"));
        Assert.assertFalse(result.filter().accept("org/eclipse/test"));
    } finally {
        if (exists) {
            // delete this one
            Assert.assertTrue(artifact.delete());
        }
    }
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 13 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class AetherTestCase method testListVersionsAether.

@Test
public void testListVersionsAether() throws Exception {
    CmrRepository repository = createAetherRepository();
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    ModuleVersionQuery lookup = new ModuleVersionQuery("com.sparkjava:spark-core", "1.", Type.JAR);
    ModuleVersionResult result = manager.completeVersions(lookup);
    Assert.assertEquals(3, result.getVersions().size());
    Assert.assertNotNull(result.getVersions().get("1.0"));
    Assert.assertNotNull(result.getVersions().get("1.1"));
    Assert.assertNotNull(result.getVersions().get("1.1.1"));
    for (ModuleVersionDetails res : result.getVersions().values()) {
        Assert.assertEquals("Spark\nA Sinatra inspired java web framework\nhttp://www.sparkjava.com", res.getDoc());
        Assert.assertEquals("The Apache Software License, Version 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0.txt", res.getLicense());
        NavigableSet<ModuleDependencyInfo> deps = res.getDependencies();
        List<ModuleDependencyInfo> compileDeps = new ArrayList<>(deps.size());
        for (ModuleDependencyInfo dep : res.getDependencies()) {
            if (dep.getModuleScope() == ModuleScope.COMPILE || dep.getModuleScope() == ModuleScope.PROVIDED)
                compileDeps.add(dep);
        }
        Assert.assertEquals(4, compileDeps.size());
    }
    lookup = new ModuleVersionQuery("com.sparkjava:spark-core", null, Type.JAR);
    result = manager.completeVersions(lookup);
    // Count the version up to 2.3
    int cnt = 0;
    for (ModuleVersionDetails mvd : result.getVersions().values()) {
        cnt++;
        if ("2.3".equals(mvd.getVersion())) {
            break;
        }
    }
    Assert.assertEquals(7, cnt);
    // now check that we only downloaded the POMs for that, and not the jars
    File repo = new File("build/test-classes/maven-settings/repository");
    File folder = new File(repo, "com/sparkjava/spark-core/1.0");
    Assert.assertTrue(new File(folder, "spark-core-1.0.pom").exists());
    Assert.assertFalse(new File(folder, "spark-core-1.0.jar").exists());
    Assert.assertFalse(new File(repo, "org/eclipse/jetty/jetty-server/9.0.2.v20130417/jetty-server-9.0.2.v20130417.jar").exists());
    // this one has a conflict if we do resolve it non-lazily
    lookup = new ModuleVersionQuery("org.hibernate:hibernate-validator", "3.", Type.JAR);
    result = manager.completeVersions(lookup);
    Assert.assertEquals(4, result.getVersions().size());
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ArrayList(java.util.ArrayList) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) Test(org.junit.Test)

Example 14 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class AetherTestCase method testReplaceOverrides.

@Test
public void testReplaceOverrides() throws Throwable {
    CmrRepository repository = createAetherRepository();
    RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
    ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.apache.camel:camel-core", "2.9.2");
    Assert.assertNotNull(result);
    Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
    File artifact = result.artifact();
    boolean exists = false;
    try {
        Assert.assertNotNull(artifact);
        Assert.assertTrue(artifact.exists());
        exists = true;
        List<ArtifactResult> deps = result.dependencies();
        Assert.assertEquals(deps.size(), 0);
    } finally {
        if (exists) {
            // delete this one
            Assert.assertTrue(artifact.delete());
        }
    }
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 15 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class ResolverTestCase method testMavenDependecyResolver.

@Test
public void testMavenDependecyResolver() throws Exception {
    final MavenDependencyResolver resolver = new MavenDependencyResolver();
    doTest(new Tester() {

        public void run(CmrRepository repository, final File artifact) {
            ModuleInfo infos = resolver.resolve(new TestArtifactResult(repository, "org.apache.camel:camel-core", "2.9.2", artifact), null);
            Assert.assertNotNull(infos);
            Assert.assertEquals(String.valueOf(infos), 3, infos.getDependencies().size());
        }
    });
}
Also used : ModuleInfo(org.eclipse.ceylon.cmr.api.ModuleInfo) MavenDependencyResolver(org.eclipse.ceylon.cmr.maven.MavenDependencyResolver) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) Test(org.junit.Test)

Aggregations

CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)43 File (java.io.File)26 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)26 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)24 Test (org.junit.Test)24 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)15 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)9 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)5 DefaultRepository (org.eclipse.ceylon.cmr.impl.DefaultRepository)4 Node (org.eclipse.ceylon.cmr.spi.Node)3 IOException (java.io.IOException)2 URL (java.net.URL)2 TreeSet (java.util.TreeSet)2 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)2 ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)2 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)2 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)2