Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
runtime: Let the runtime use the information from CMR about dist over…
Browse files Browse the repository at this point in the history
…rides

Part of #5734
  • Loading branch information
tombentley committed Nov 17, 2015
1 parent a73ddfb commit cefc74a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
2 changes: 2 additions & 0 deletions runtime/api/src/main/java/ceylon/runtime/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* present to ensure the Ceylon module has package called ceylon.runtime*/
package ceylon.runtime;
37 changes: 37 additions & 0 deletions runtime/dist/repo/dist-overrides.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<overrides>
<replace module="ceylon.language" version="1.2.0">
<with module="ceylon.language" version="1.2.1"/>
</replace>

<replace module="ceylon.runtime" version="1.2.0">
<with module="ceylon.runtime" version="1.2.1"/>
</replace>

<replace module="ceylon.bootstrap" version="1.2.0">
<with module="ceylon.bootstrap" version="1.2.1"/>
</replace>

<replace module="com.redhat.ceylon.common" version="1.2.0">
<with module="com.redhat.ceylon.common" version="1.2.1"/>
</replace>

<replace module="com.redhat.ceylon.typechecker" version="1.2.0">
<with module="com.redhat.ceylon.typechecker" version="1.2.1"/>
</replace>

<replace module="com.redhat.ceylon.module-resolver" version="1.2.0">
<with module="com.redhat.ceylon.module-resolver" version="1.2.1"/>
</replace>

<replace module="com.redhat.ceylon.model" version="1.2.0">
<with module="com.redhat.ceylon.model" version="1.2.1"/>
</replace>

<replace module="com.redhat.ceylon.compiler.java" version="1.2.0">
<with module="com.redhat.ceylon.compiler.java" version="1.2.1"/>
</replace>

<replace module="com.redhat.ceylon.compiler.js" version="1.2.0">
<with module="com.redhat.ceylon.compiler.js" version="1.2.1"/>
</replace>
</overrides>
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.jboss.modules.AliasModuleSpec;
import org.jboss.modules.DependencySpec;
import org.jboss.modules.LocalLoader;
import org.jboss.modules.Module;
Expand Down Expand Up @@ -117,6 +119,7 @@ public class CeylonModuleLoader extends ModuleLoader {
BOOTSTRAP.add(JANDEX);
BOOTSTRAP.add(LOGMANAGER);
BOOTSTRAP.add(RUNTIME);


Set<String> jdkPaths = new HashSet<>();
JDK_MODULE_NAMES = new HashSet<>();
Expand Down Expand Up @@ -223,9 +226,10 @@ private void relink(ModuleIdentifier mi, Set<ModuleIdentifier> visited) throws M

@Override
protected org.jboss.modules.Module preloadModule(ModuleIdentifier mi) throws ModuleLoadException {
if (BOOTSTRAP.contains(mi))
mi = findOverride(mi);
if (BOOTSTRAP.contains(mi)) {
return org.jboss.modules.Module.getBootModuleLoader().loadModule(mi);

}
return super.preloadModule(mi);
}

Expand All @@ -243,6 +247,12 @@ protected ArtifactResult findArtifact(ModuleIdentifier mi) {
final ArtifactContext context = new ArtifactContext(mi.getName(), mi.getSlot(), ArtifactContext.CAR, ArtifactContext.JAR);
return repository.getArtifactResult(context);
}

public ModuleIdentifier findOverride(ModuleIdentifier mi) {
final ArtifactContext context = new ArtifactContext(mi.getName(), mi.getSlot(), ArtifactContext.CAR, ArtifactContext.JAR);
ArtifactContext override = repository.getArtifactOverride(context);
return ModuleIdentifier.create(override.getName(), override.getVersion());
}

protected boolean isLogging(List<DependencySpec> deps, Builder builder, ArtifactResult result) {
for (LogChecker checker : checkers) {
Expand All @@ -265,6 +275,12 @@ protected ModuleSpec findModule(ModuleIdentifier moduleIdentifier) throws Module
if (artifact == null)
return null;

if (!artifact.version().equals(moduleIdentifier.getSlot())) {
AliasModuleSpec alias = (AliasModuleSpec)ModuleSpec.buildAlias(moduleIdentifier,
ModuleIdentifier.create(artifact.name(), artifact.version())).create();
return alias;
}

final File moduleFile = artifact.artifact();
final boolean isDefault = RepositoryManager.DEFAULT_MODULE.equals(moduleIdentifier.getName());
boolean isMaven = artifact.type() == ArtifactResultType.MAVEN;
Expand Down

0 comments on commit cefc74a

Please sign in to comment.