use of org.eclipse.ceylon.common.Backends in project ceylon by eclipse.
the class Overrides method applyOverrides.
public ModuleInfo applyOverrides(String module, String version, ModuleInfo source) {
ArtifactOverrides artifactOverrides = getArtifactOverrides(new ArtifactContext(null, module, version));
Set<ModuleDependencyInfo> result = new HashSet<ModuleDependencyInfo>();
for (ModuleDependencyInfo dep : source.getDependencies()) {
String depNamespace = dep.getNamespace();
String depName = dep.getName();
String depVersion = dep.getVersion();
boolean optional = dep.isOptional();
boolean export = dep.isExport();
ModuleScope scope = dep.getModuleScope();
Backends backends = dep.getNativeBackends();
ArtifactContext ctx = new ArtifactContext(depNamespace, depName, depVersion);
if ((artifactOverrides != null && artifactOverrides.isRemoved(ctx)) || isRemoved(ctx))
continue;
if (artifactOverrides != null && artifactOverrides.isAddedOrUpdated(ctx))
continue;
ArtifactContext replacement = replace(ctx);
if (replacement != null) {
depNamespace = replacement.getNamespace();
depName = replacement.getName();
depVersion = replacement.getVersion();
ctx = replacement;
}
if (isVersionOverridden(ctx))
depVersion = getVersionOverride(ctx);
if (artifactOverrides != null) {
if (artifactOverrides.isShareOverridden(ctx))
export = artifactOverrides.isShared(ctx);
if (artifactOverrides.isOptionalOverridden(ctx))
optional = artifactOverrides.isOptional(ctx);
}
result.add(new ModuleDependencyInfo(depNamespace, depName, depVersion, optional, export, backends, scope));
}
String filter = source.getFilter();
if (artifactOverrides != null) {
if (artifactOverrides.getFilter() != null)
filter = artifactOverrides.getFilter();
for (DependencyOverride add : artifactOverrides.getAdd()) {
ArtifactContext addContext = add.getArtifactContext();
result.add(new ModuleDependencyInfo(addContext.getNamespace(), addContext.getName(), addContext.getVersion(), add.isOptional(), add.isShared()));
}
}
return new ModuleInfo(source.getNamespace(), module, version, source.getGroupId(), source.getArtifactId(), source.getClassifier(), filter, result);
}
Aggregations