From 0e7d64a2d83676bcef0b34c02af656db32942605 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 19 Nov 2010 10:47:02 +0000 Subject: Update to support passing in an intial contribution to install and start, and also to support pointing at a Maven project contribution without needing to have the target/classes suffix git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1036795 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/shell/Shell.java | 41 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java index 33859f3abb..d91d94219a 100644 --- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java +++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java @@ -23,11 +23,15 @@ import static java.lang.System.in; import static java.lang.System.out; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -70,14 +74,25 @@ public class Shell { public static void main(final String[] args) throws Exception { boolean useJline = true; String domainURI = "default"; + + String contribution = null; for (String s : args) { if ("-nojline".equals(s)) { useJline = false; } else { - domainURI = s; + File f = new File(s); + if (f.exists()) { + contribution = s; + } else { + domainURI = s; + } } } - new Shell(domainURI, useJline).run(); + Shell shell = new Shell(domainURI, useJline); + if (contribution != null) { + shell.install(Arrays.asList(new String[]{"install", contribution, "-start"})); + } + shell.run(); } public Shell(String domainURI, boolean useJLine) { @@ -152,12 +167,34 @@ public class Shell { } else { curl = first; } + + curl = mavenProject(curl); String uri = getNode().installContribution(curi, curl, metaDataURL, duris, startDeployables); out.println("installed at: " + uri); return true; } + /** + * Try to simplify pointing at a Maven project contribution without needing target/classes suffix + */ + private String mavenProject(String curl) { + File f = new File(curl); + if (!f.exists()) { + return curl; + } + f = new File(f, "target"); + if (!f.exists()) { + return curl; + } + f = new File(f, "classes"); + if (f.exists()) { + return f.toURI().toString(); + } + // TODO: look for .zip or .jar in target? + return curl; + } + boolean installed(final List toks) { List curis; if (toks.size() > 1) { -- cgit v1.2.3