Search in sources :

Example 1 with Repository

use of org.eclipse.ceylon.model.cmr.Repository in project ceylon by eclipse.

the class JvmBackendUtil method loadStaticMetamodel.

public static void loadStaticMetamodel(InputStream is, List<String> dexEntries, StaticMetamodelLoader staticMetamodelLoader) {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
        String line;
        ModuleSpec module = null;
        SortedSet<String> packages = new TreeSet<>();
        List<ArtifactResult> imports = new LinkedList<ArtifactResult>();
        while ((line = reader.readLine()) != null) {
            if (line.startsWith("=")) {
                if (module != null)
                    finishLoadingModule(module, packages, imports, dexEntries, staticMetamodelLoader);
                module = ModuleSpec.parse(line.substring(1));
                packages.clear();
                imports.clear();
                continue;
            }
            boolean _optional = false;
            boolean _shared = false;
            if (line.startsWith("?")) {
                _optional = true;
                line = line.substring(1);
            }
            if (line.startsWith("+")) {
                _shared = true;
                line = line.substring(1);
            }
            // SERIOUSLY!!
            final boolean optional = _optional;
            final boolean shared = _shared;
            if (line.startsWith("@")) {
                packages.add(line.substring(1));
                continue;
            }
            // it's an import
            ModuleSpec importSpec = ModuleSpec.parse(line);
            final String namespace = ModuleUtil.getNamespaceFromUri(importSpec.getName());
            final String name = ModuleUtil.getModuleNameFromUri(importSpec.getName());
            final String version = importSpec.getVersion();
            imports.add(new ArtifactResult() {

                @Override
                public String namespace() {
                    return namespace;
                }

                @Override
                public String name() {
                    return name;
                }

                @Override
                public String version() {
                    return version;
                }

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

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

                @Override
                public ArtifactResultType type() {
                    // Is this important?
                    return ArtifactResultType.OTHER;
                }

                @Override
                public VisibilityType visibilityType() {
                    return VisibilityType.STRICT;
                }

                @Override
                public File artifact() throws RepositoryException {
                    return null;
                }

                @Override
                public PathFilter filter() {
                    return null;
                }

                @Override
                public List<ArtifactResult> dependencies() throws RepositoryException {
                    return null;
                }

                @Override
                public String artifactId() {
                    return ModuleUtil.getMavenArtifactIdIfMavenModule(name);
                }

                @Override
                public String groupId() {
                    return ModuleUtil.getMavenGroupIdIfMavenModule(name);
                }

                @Override
                public String classifier() {
                    return ModuleUtil.getMavenClassifierIfMavenModule(name);
                }

                @Override
                public String repositoryDisplayString() {
                    return "Android dependency";
                }

                @Override
                public Repository repository() {
                    return null;
                }

                @Override
                public ModuleScope moduleScope() {
                    return ModuleScope.COMPILE;
                }

                @Override
                public List<Exclusion> getExclusions() {
                    return null;
                }
            });
        }
        if (module != null)
            finishLoadingModule(module, packages, imports, dexEntries, staticMetamodelLoader);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : PathFilter(org.eclipse.ceylon.model.cmr.PathFilter) InputStreamReader(java.io.InputStreamReader) ModuleScope(org.eclipse.ceylon.model.cmr.ModuleScope) RepositoryException(org.eclipse.ceylon.model.cmr.RepositoryException) IOException(java.io.IOException) LinkedList(java.util.LinkedList) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Repository(org.eclipse.ceylon.model.cmr.Repository) ArtifactResultType(org.eclipse.ceylon.model.cmr.ArtifactResultType) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) VisibilityType(org.eclipse.ceylon.model.cmr.VisibilityType) TreeSet(java.util.TreeSet) BufferedReader(java.io.BufferedReader) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Aggregations

BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 ZipFile (java.util.zip.ZipFile)1 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)1 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)1 ArtifactResultType (org.eclipse.ceylon.model.cmr.ArtifactResultType)1 ModuleScope (org.eclipse.ceylon.model.cmr.ModuleScope)1 PathFilter (org.eclipse.ceylon.model.cmr.PathFilter)1 Repository (org.eclipse.ceylon.model.cmr.Repository)1 RepositoryException (org.eclipse.ceylon.model.cmr.RepositoryException)1 VisibilityType (org.eclipse.ceylon.model.cmr.VisibilityType)1