Skip to content

Commit

Permalink
Fixed problem with parameters only needed for first setup of the boot…
Browse files Browse the repository at this point in the history
… module loader being passed on subsequent invocations.

Now obtaining the Ceylon system version from the System properties.
  • Loading branch information
quintesse committed Feb 26, 2013
1 parent 681f58a commit 5cea38b
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions bootstrap/src/main/java/ceylon/modules/bootstrap/CeylonRunTool.java
Expand Up @@ -21,7 +21,6 @@
import java.util.Collections;
import java.util.List;

import com.redhat.ceylon.common.Versions;
import com.redhat.ceylon.common.tool.Argument;
import com.redhat.ceylon.common.tool.Description;
import com.redhat.ceylon.common.tool.Option;
Expand All @@ -47,7 +46,7 @@
)
public class CeylonRunTool implements Tool {
private static final String CEYLON_RUNTIME = "ceylon.runtime";
private static final String FULL_CEYLON_RUNTIME = CEYLON_RUNTIME + ":" + Versions.CEYLON_VERSION_NUMBER;

private static volatile Module runtimeModule;

private String moduleNameOptVersion;
Expand Down Expand Up @@ -108,19 +107,15 @@ public void setVerbose(String verboseFlags) {
public void run() {
ArrayList<String> argList = new ArrayList<String>();

String ceylonVersion = System.getProperty("ceylon.system.version");

String sysRep;
if (systemRepo != null) {
sysRep = systemRepo;
} else {
sysRep = System.getProperty("ceylon.system.repo");
}

argList.addAll(Arrays.asList(
"-mp", sysRep,
FULL_CEYLON_RUNTIME,
"+executable", "ceylon.modules.jboss.runtime.JBossRuntime")
);

if (run != null) {
argList.add("-run");
argList.add(run);
Expand Down Expand Up @@ -150,20 +145,19 @@ public void run() {
argList.addAll(args);

try {
String[] args = argList.toArray(new String[argList.size()]);
if (runtimeModule == null) {
synchronized (ModuleLoader.class) {
if (runtimeModule == null) {
org.jboss.modules.Main.main(args);
org.jboss.modules.Main.main(setupArguments(argList, sysRep, ceylonVersion));
// set runtime module
ModuleLoader ml = Module.getBootModuleLoader();
runtimeModule = ml.loadModule(ModuleIdentifier.create(CEYLON_RUNTIME, Versions.CEYLON_VERSION_NUMBER));
runtimeModule = ml.loadModule(ModuleIdentifier.create(CEYLON_RUNTIME, ceylonVersion));
} else {
runtimeModule.run(args);
runtimeModule.run(moduleArguments(argList));
}
}
} else {
runtimeModule.run(args);
runtimeModule.run(moduleArguments(argList));
}
} catch (Error err) {
throw err;
Expand All @@ -173,4 +167,24 @@ public void run() {
throw new RuntimeException(t);
}
}

private String[] setupArguments(List<String> argList, String sysRep, String ceylonVersion) {
ArrayList<String> setupArgs = new ArrayList<String>();
setupArgs.addAll(Arrays.asList(
"-mp", sysRep,
CEYLON_RUNTIME + ":" + ceylonVersion,
"+executable", "ceylon.modules.jboss.runtime.JBossRuntime"));
setupArgs.addAll(argList);
String[] args = setupArgs.toArray(new String[setupArgs.size()]);
return args;
}

private String[] moduleArguments(List<String> argList) {
ArrayList<String> moduleArgs = new ArrayList<String>();
moduleArgs.addAll(Arrays.asList(
"+executable", "ceylon.modules.jboss.runtime.JBossRuntime"));
moduleArgs.addAll(argList);
String[] args = moduleArgs.toArray(new String[moduleArgs.size()]);
return args;
}
}

0 comments on commit 5cea38b

Please sign in to comment.