Skip to content

Commit

Permalink
Fix args order, allow any version.
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed Dec 14, 2011
1 parent bff02f0 commit 8b01d7a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
Expand Up @@ -24,7 +24,6 @@

import ceylon.language.descriptor.Module;
import ceylon.modules.api.util.CeylonToJava;
import ceylon.modules.api.util.ModuleVersion;
import ceylon.modules.spi.Constants;

import java.util.ArrayList;
Expand Down Expand Up @@ -88,9 +87,9 @@ public void execute(Map<String, String> args) throws Exception {
throw new IllegalArgumentException("Missing version info: " + exe);

String name = exe.substring(0, p > 0 ? p : exe.length());
ModuleVersion mv = (p > 0 ? ModuleVersion.parseVersion(exe.substring(p + 1)) : ModuleVersion.DEFAULT_VERSION);
String mv = (p > 0 ? exe.substring(p + 1) : Constants.DEFAULT_VERSION.toString());

ClassLoader cl = createClassLoader(name, mv.toString(), args);
ClassLoader cl = createClassLoader(name, mv, args);
Module runtimeModule = loadModule(cl, name);
if (runtimeModule == null)
throw new IllegalArgumentException("Something went very wrong, missing runtime module!"); // TODO -- dump some more useful msg
Expand All @@ -99,7 +98,7 @@ public void execute(Map<String, String> args) throws Exception {
if (name.equals(mn) == false)
throw new IllegalArgumentException("Input module name doesn't match module's name: " + name + " != " + mn);
String version = CeylonToJava.toString(runtimeModule.getVersion());
if (mv.equals(ModuleVersion.parseVersion(version)) == false)
if (mv.equals(version) == false && Constants.DEFAULT.toString().equals(name) == false)
throw new IllegalArgumentException("Input module version doesn't match module's version: " + mv + " != " + version);

List<String> la = new ArrayList<String>();
Expand Down
Expand Up @@ -80,7 +80,7 @@ protected RemoteModuleLoader(ModuleLoader delegate) {
throw new IllegalArgumentException("Null delegate");

this.delegate = delegate;
this.rootURL = System.getProperty("modules.remote.root.url", "http://ceylon-lang.org/modules/repository/");
this.rootURL = System.getProperty("modules.remote.root.url", "http://modules.ceylon.org/");
this.ceylonVersion = System.getProperty("ceylon.modules.version", DEFAULT_CEYLON_VERSION);
this.repoRoot = new File(getCeylonRepository());
}
Expand Down
6 changes: 3 additions & 3 deletions dist/bin/ceylon
Expand Up @@ -18,6 +18,6 @@ java -Dboot.module.loader=ceylon.modules.bootstrap.loader.DistributionModuleLoad
-cp $DIR/jboss-modules.jar:$DIR/ceylon-runtime-bootstrap.jar \
org.jboss.modules.Main \
-mp $DIR/../runtime-repo ceylon.runtime \
+executable ceylon.modules.jboss.runtime.JBossRuntime \
+repository ~/.ceylon/repo \
+module $@
-executable ceylon.modules.jboss.runtime.JBossRuntime \
-repository ~/.ceylon/repo \
-module $@
9 changes: 4 additions & 5 deletions spi/src/main/java/ceylon/modules/Main.java
Expand Up @@ -27,7 +27,7 @@

import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
Expand Down Expand Up @@ -62,14 +62,13 @@ public static void execute(String[] args) throws Exception {
}

private static Map<String, String> parseArgs(String[] args) {
final Map<String, String> map = new HashMap<String, String>();
final Map<String, String> map = new LinkedHashMap<String, String>();
boolean first = true; // filter out ModuleIdentifier
int n = args.length;
for (int i = 0; i < n; i++) {
final String arg = args[i];
if (arg.startsWith(Constants.MODULES_OP.toString())) {
i++; // it's a JBoss Modules command
} else if (arg.startsWith(Constants.OP.toString())) {
// should not see any JBoss Modules args
if (arg.startsWith(Constants.OP.toString())) {
if (i == n - 1)
throw new IllegalArgumentException("Missing argument value: " + arg);

Expand Down
7 changes: 3 additions & 4 deletions spi/src/main/java/ceylon/modules/spi/Constants.java
Expand Up @@ -30,14 +30,13 @@
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public enum Constants {
OP("+"),
MODULES_OP("-"),
EXTERNAL_OP("-"),
OP("-"),
EXECUTABLE("executable"),
DEFAULT("default"),
DEFAULT_VERSION("main"),
MODULE("module"),
REPOSITORY("repository"),
SOURCE("src"),
DEFAULT("d"),
SOURCES("sources"),
CLASSES("classes"),
CACHE_CONTENT("cache_content"),
Expand Down
Expand Up @@ -33,7 +33,7 @@
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -90,7 +90,7 @@ public File run() {
String name = fullName.substring(0, p);
String version = fullName.substring(p + 1, fullName.lastIndexOf("."));

Map<Constants, String> args = new HashMap<Constants, String>();
Map<Constants, String> args = new LinkedHashMap<Constants, String>();
args.put(Constants.EXECUTABLE, RUNTIME_IMPL);
args.put(Constants.MODULE, name + "/" + version);
args.put(Constants.REPOSITORY, tmpdir.toString());
Expand All @@ -116,7 +116,7 @@ protected void src(String module, String src) throws Throwable {
}

protected void car(String module, Map<Constants, String> extra) throws Throwable {
Map<Constants, String> args = new HashMap<Constants, String>();
Map<Constants, String> args = new LinkedHashMap<Constants, String>();
args.put(Constants.EXECUTABLE, RUNTIME_IMPL);
args.put(Constants.REPOSITORY, getRepo().getPath());
args.put(Constants.MODULE, module);
Expand All @@ -127,7 +127,7 @@ protected void car(String module, Map<Constants, String> extra) throws Throwable
}

protected void src(String module, String src, Map<Constants, String> extra) throws Throwable {
Map<Constants, String> args = new HashMap<Constants, String>();
Map<Constants, String> args = new LinkedHashMap<Constants, String>();
args.put(Constants.EXECUTABLE, RUNTIME_IMPL);
args.put(Constants.MODULE, module);
args.put(Constants.SOURCE, src);
Expand Down

0 comments on commit 8b01d7a

Please sign in to comment.