public void execute(Configuration conf) throws Exception {
String exe = conf.module;
// FIXME: argument checks could be done earlier
if (exe == null) {
throw new CeylonRuntimeException("No initial module defined");
}
int p = exe.indexOf("/");
if (p == 0) {
throw new CeylonRuntimeException("Missing runnable info: " + exe);
}
if (p == exe.length() - 1) {
throw new CeylonRuntimeException("Missing version info: " + exe);
}
String name = exe.substring(0, p > 0 ? p : exe.length());
String mv = (p > 0 ? exe.substring(p + 1) : null);
final ClassLoaderHolder clh = createClassLoader(name, mv, conf);
mv = clh.getVersion();
final ClassLoader cl = clh.getClassLoader();
Module runtimeModule = loadModuleMetaData(cl, name);
if (runtimeModule != null) {
final String mn = runtimeModule.name();
if (name.equals(mn) == false) {
throw new CeylonRuntimeException("Input module name doesn't match module's name: " + name + " != " + mn);
}
final String version = runtimeModule.version();
if (mv.equals(version) == false && Constants.DEFAULT.toString().equals(name) == false) {
throw new CeylonRuntimeException("Input module version doesn't match module's version: " + mv + " != " + version);
}
} else if (Constants.DEFAULT.toString().equals(name) == false) {
// Don't throw, we might be executing a plain Java module!
//throw new CeylonRuntimeException("Missing module.class info: " + name); // TODO -- dump some more useful msg
}