Search in sources :

Example 46 with ArtifactContext

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

the class SmokeTestCase method testPropertiesPut.

@Test
public void testPropertiesPut() throws Exception {
    RepositoryManager manager = getRepositoryManager();
    ArtifactContext context = new ArtifactContext(null, "org.acme.props", "1.0", ArtifactContext.JAR);
    try {
        manager.putArtifact(context, mockJar("someentry", "qwerty".getBytes()));
        manager.putArtifact(context.getModuleProperties(), new ByteArrayInputStream("moduletest=0.1\n".getBytes()));
        File file = manager.getArtifact(context);
        Assert.assertNotNull(file);
    } finally {
        manager.removeArtifact(context);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File) Test(org.junit.Test)

Example 47 with ArtifactContext

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

the class SmokeTestCase method testForcedPut.

@Test
public void testForcedPut() throws Exception {
    RepositoryManager manager = getRepositoryManager();
    ByteArrayInputStream baos = new ByteArrayInputStream("qwerty".getBytes());
    String name = "org.eclipse.foobar2";
    String version = "1.0.0.Alpha1";
    try {
        ArtifactContext context = new ArtifactContext();
        context.setName(name);
        context.setVersion(version);
        context.setForceOperation(true);
        manager.putArtifact(context, baos);
        File file = manager.getArtifact(null, name, version);
        Assert.assertNotNull("Failed to retrieve after put", file);
        baos = new ByteArrayInputStream("ytrewq".getBytes());
        manager.putArtifact(context, baos);
        file = manager.getArtifact(null, name, version);
        Assert.assertNotNull("Failed to retrieve after forced put", file);
    } finally {
        manager.removeArtifact(null, name, version);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File) Test(org.junit.Test)

Example 48 with ArtifactContext

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

the class SmokeTestCase method testPropertiesResolver.

@Test
public void testPropertiesResolver() throws Exception {
    RepositoryManager manager = getRepositoryManager();
    ArtifactContext context = new ArtifactContext(null, "old-jar", "1.2.CR1", ArtifactContext.JAR);
    File file = manager.getArtifact(context);
    Assert.assertNotNull(file);
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File) Test(org.junit.Test)

Example 49 with ArtifactContext

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

the class AetherRepository method toModuleName.

@Override
protected String toModuleName(Node node) {
    ArtifactContext context = ArtifactContext.fromNode(node);
    if (context != null) {
        return context.getName();
    }
    String moduleName = node.getLabel();
    Node parent = NodeUtils.firstParent(node);
    String groupId = NodeUtils.getFullPath(parent, ".");
    // That's sort of an invariant, but let's be safe
    if (groupId.startsWith("."))
        groupId = groupId.substring(1);
    moduleName = groupId != null ? groupId + ":" + moduleName : moduleName;
    return moduleName;
}
Also used : Node(org.eclipse.ceylon.cmr.spi.Node) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext)

Example 50 with ArtifactContext

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

the class AetherUtils method findDependencies.

private ArtifactResult findDependencies(RepositoryManager manager, Node node, Boolean fetchSingleArtifact) {
    final ArtifactContext ac = ArtifactContext.fromNode(node);
    if (ac == null)
        return null;
    final String name = ac.getName();
    String[] groupArtifactIds = nameToGroupArtifactIds(name);
    if (groupArtifactIds == null) {
        return null;
    }
    String groupId = groupArtifactIds[0];
    String artifactId = groupArtifactIds[1];
    String classifier = groupArtifactIds[2];
    String version = ac.getVersion();
    String repositoryDisplayString = NodeUtils.getRepositoryDisplayString(node);
    CmrRepository repository = NodeUtils.getRepository(node);
    if (CeylonUtils.arrayContains(ac.getSuffixes(), ArtifactContext.LEGACY_SRC)) {
        classifier = "sources";
    }
    return fetchDependencies(manager, repository, groupId, artifactId, classifier, version, fetchSingleArtifact != null ? fetchSingleArtifact : ac.isIgnoreDependencies(), repositoryDisplayString);
}
Also used : MavenArtifactContext(org.eclipse.ceylon.cmr.api.MavenArtifactContext) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository)

Aggregations

ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)62 File (java.io.File)33 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)25 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)22 Test (org.junit.Test)20 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)17 IOException (java.io.IOException)13 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)9 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)7 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)6 ArrayList (java.util.ArrayList)5 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)5 Manifest (java.util.jar.Manifest)4 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)4 Module (org.eclipse.ceylon.model.typechecker.model.Module)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileWriter (java.io.FileWriter)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3