Search in sources :

Example 1 with SimpleRepositoryManager

use of org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager in project ceylon by eclipse.

the class ModuleLoaderTest method testNoDotsFromMavenWithOverrides.

@Test
public void testNoDotsFromMavenWithOverrides() throws ModuleNotFoundException {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    Overrides ov = RepositoryManagerBuilder.parseOverrides(overrides);
    Assert.assertTrue(ov.getAddedArtifacts().isEmpty());
    RepositoryManager manager = new SimpleRepositoryManager(repository, log, ov);
    Map<String, String> extraModules = new HashMap<>();
    extraModules.put("org.antlr:stringtemplate", "3.2.1");
    // this one has an override that adds aopalliance:aopalliance/1.0
    extraModules.put("org.postgresql:postgresql", "9.4.1208");
    TestableModuleLoader moduleLoader = new TestableModuleLoader(manager, null, extraModules, true);
    moduleLoader.loadModule("com.google.inject:guice", "4.0", ModuleScope.RUNTIME);
    // Check that we got them
    Assert.assertEquals("2.7.7", moduleLoader.getModuleVersion("maven:antlr:antlr"));
    Assert.assertEquals("1.0", moduleLoader.getModuleVersion("maven:aopalliance:aopalliance"));
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) HashMap(java.util.HashMap) Overrides(org.eclipse.ceylon.cmr.api.Overrides) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) Test(org.junit.Test)

Example 2 with SimpleRepositoryManager

use of org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager in project ceylon by eclipse.

the class ModuleLoaderTest method testModuleLoader.

@Test
public void testModuleLoader() throws ModuleNotFoundException {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    Map<String, String> extraModules = new HashMap<>();
    extraModules.put("org.springframework.boot:spring-boot-starter-web", "1.3.5.RELEASE");
    extraModules.put("org.springframework.boot:spring-boot-starter-undertow", "1.3.5.RELEASE");
    extraModules.put("org.springframework.boot:spring-boot-starter-data-jpa", "1.3.5.RELEASE");
    extraModules.put("org.springframework.cloud:spring-cloud-starter-eureka", "1.1.2.RELEASE");
    extraModules.put("org.postgresql:postgresql", "9.4.1208");
    extraModules.put("org.liquibase:liquibase-core", "3.4.2");
    TestableModuleLoader moduleLoader = new TestableModuleLoader(manager, null, extraModules, false);
    moduleLoader.loadModule("org.liquibase:liquibase-core", "3.4.2", ModuleScope.RUNTIME);
    // Check that we got the latest version
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-core"));
    // Check that this one did not get removed
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-context"));
    // Those two should not be there
    Assert.assertNull(moduleLoader.getModuleVersion("javax.servlet:servlet-api"));
    Assert.assertNull(moduleLoader.getModuleVersion("org.springframework:spring"));
    // Check that we got the runtime dep
    Assert.assertEquals("3.3.6.Final", moduleLoader.getModuleVersion("org.jboss.xnio:xnio-nio"));
    moduleLoader.cleanup();
    moduleLoader.loadModule("org.liquibase:liquibase-core", "3.4.2", ModuleScope.COMPILE);
    // Check that we got the latest version
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-core"));
    // Check that this one did not get removed
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-context"));
    // Those two should not be there
    Assert.assertNull(moduleLoader.getModuleVersion("javax.servlet:servlet-api"));
    Assert.assertNull(moduleLoader.getModuleVersion("org.springframework:spring"));
    // Check that we have no runtime dep
    Assert.assertNull(moduleLoader.getModuleVersion("org.jboss.xnio:xnio-nio"));
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) HashMap(java.util.HashMap) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) Test(org.junit.Test)

Example 3 with SimpleRepositoryManager

use of org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager 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 4 with SimpleRepositoryManager

use of org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager 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 5 with SimpleRepositoryManager

use of org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager 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)

Aggregations

RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)19 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)19 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)18 Test (org.junit.Test)18 File (java.io.File)14 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)11 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)2 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)2 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)1 ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)1 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)1 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)1 ModuleVersionResult (org.eclipse.ceylon.cmr.api.ModuleVersionResult)1 Overrides (org.eclipse.ceylon.cmr.api.Overrides)1 AbstractArtifactResult (org.eclipse.ceylon.cmr.impl.AbstractArtifactResult)1 AetherContentStore (org.eclipse.ceylon.cmr.maven.AetherContentStore)1 StructureBuilder (org.eclipse.ceylon.cmr.spi.StructureBuilder)1 Ignore (org.junit.Ignore)1