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);
}
}
Aggregations