Search in sources :

Example 21 with CmrRepository

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

the class SmokeTestCase method testExternalNodes.

@Test
public void testExternalNodes() throws Exception {
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    InMemoryContentStore imcs = new InMemoryContentStore();
    OpenNode root = imcs.createRoot();
    CmrRepository repo = new DefaultRepository(root);
    RepositoryManager manager = builder.addRepository(repo).buildRepository();
    // a few impl details, feel free to remove/ignore this test
    String name = "org.eclipse.acme";
    String version = "1.0.0.CR1";
    ArtifactContext context = new ArtifactContext(null, name, version);
    // ignore with in-memory
    context.setIgnoreSHA(true);
    OpenNode parent = repo.createParent(context);
    parent.addContent(name + "-" + version + ArtifactContext.CAR, new ByteArrayInputStream("qwerty".getBytes()), context);
    try {
        File file = manager.getArtifact(context);
        Assert.assertNotNull("Failed to retrieve after put", file);
    } finally {
        manager.removeArtifact(null, name, version);
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryContentStore(org.eclipse.ceylon.test.smoke.support.InMemoryContentStore) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) Test(org.junit.Test)

Example 22 with CmrRepository

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

Example 23 with CmrRepository

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

the class MavenRepositoryBuilder method createMavenRepository.

private CmrRepository[] createMavenRepository(String token, String prefix, RepositoryBuilderConfig config) throws Exception {
    String settingsXml = null;
    if (prefix != null) {
        String settings = token.substring(prefix.length());
        // backwards compat: ignore overrides from here, previously located after | symbol
        int p = settings.indexOf("|");
        if (p < 0) {
            settingsXml = settings;
        } else {
            settingsXml = settings.substring(0, p);
        }
    }
    Class<?> aetherRepositoryClass = Class.forName(AETHER_REPOSITORY_CLASS);
    Method createRepository = aetherRepositoryClass.getMethod("createRepository", Logger.class, String.class, boolean.class, int.class, String.class);
    CmrRepository repo = (CmrRepository) createRepository.invoke(null, config.log, settingsXml, config.offline, config.timeout, config.currentDirectory);
    return new CmrRepository[] { repo };
}
Also used : Method(java.lang.reflect.Method) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository)

Example 24 with CmrRepository

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

the class NodeUtils method getRepository.

/**
 * Get repository info.
 *
 * @param node the node
 * @return repository info
 */
public static CmrRepository getRepository(Node node) {
    if (node instanceof OpenNode) {
        final OpenNode on = (OpenNode) node;
        final Node info = on.peekChild(INFO);
        return (info != null) ? info.getValue(CmrRepository.class) : null;
    }
    return null;
}
Also used : OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) Node(org.eclipse.ceylon.cmr.spi.Node) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode)

Example 25 with CmrRepository

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

the class AetherUtils method createArtifactResult.

protected ArtifactResult createArtifactResult(final RepositoryManager manager, CmrRepository repository, final String groupId, final String artifactId, final String classifier, final String dVersion, final boolean shared, final boolean optional, final ModuleScope scope, final String repositoryDisplayString, final List<ExclusionDescriptor> exclusions) {
    final String dName = MavenUtils.moduleName(groupId, artifactId, classifier);
    return new MavenArtifactResult(repository, dName, dVersion, groupId, artifactId, classifier, repositoryDisplayString) {

        private ArtifactResult result;

        {
            if (exclusions != null) {
                List<Exclusion> ret = new ArrayList<>(exclusions.size());
                for (ExclusionDescriptor xDescr : exclusions) {
                    ret.add(new Exclusion(xDescr.getGroupId(), xDescr.getArtifactId()));
                }
                setExclusions(ret);
            }
        }

        @Override
        public boolean exported() {
            return shared;
        }

        @Override
        public boolean optional() {
            return optional;
        }

        @Override
        public ModuleScope moduleScope() {
            return scope;
        }

        private synchronized ArtifactResult getResult() {
            if (result == null) {
                result = fetchDependencies(manager, (CmrRepository) repository(), groupId, artifactId, classifier, dVersion, false, repositoryDisplayString);
            }
            return result;
        }

        protected File artifactInternal() throws RepositoryException {
            return getResult().artifact();
        }

        public List<ArtifactResult> dependencies() throws RepositoryException {
            return getResult().dependencies();
        }
    };
}
Also used : Exclusion(org.eclipse.ceylon.model.cmr.Exclusion) ArrayList(java.util.ArrayList) ExclusionDescriptor(org.eclipse.ceylon.cmr.resolver.aether.ExclusionDescriptor) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) LazyArtifactResult(org.eclipse.ceylon.cmr.impl.LazyArtifactResult) AbstractArtifactResult(org.eclipse.ceylon.cmr.impl.AbstractArtifactResult) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

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