[bs-59] Add zip packaging for cli module
* Also added "spring" shell script (in zip), so you can unzip it and run out of the box * To run in developer mode use SPRING_HOME, e.g. $ cd spring-bootstrap-cli $ SPRING_HOME=target src/main/scripts/spring run samples/web.groovy * Also added "clean" command to remove spring bootstrap grapes (useful to force a refresh of snapshot jars) [#48644271]pull/1/merge
parent
8a4b50e289
commit
c91e83c7d2
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2013 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.bootstrap.cli;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.apache.ivy.util.FileUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link Command} to 'clean' up grapes.
|
||||||
|
*
|
||||||
|
* @author Dave Syer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CleanCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
public CleanCommand() {
|
||||||
|
super("clean",
|
||||||
|
"Clean up groovy grapes (useful if snapshots are needed and you need an update)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
|
||||||
|
String dir = System.getenv("GROOVY_HOME");
|
||||||
|
String userdir = System.getProperty("user.home");
|
||||||
|
|
||||||
|
File home;
|
||||||
|
if (dir == null || !new File(dir).exists()) {
|
||||||
|
dir = userdir;
|
||||||
|
home = new File(dir, ".groovy");
|
||||||
|
} else {
|
||||||
|
home = new File(dir);
|
||||||
|
}
|
||||||
|
if (dir == null || !new File(dir).exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!home.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File grapes = new File(home, "grapes");
|
||||||
|
// TODO: add support for other packages as args
|
||||||
|
String[] packages = new String[] { "org.springframework.bootstrap" };
|
||||||
|
for (String pkg : packages) {
|
||||||
|
File file = new File(grapes, pkg);
|
||||||
|
if (file.exists()) {
|
||||||
|
FileUtil.forceDelete(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false;
|
||||||
|
darwin=false;
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN*)
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
|
||||||
|
Darwin*)
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "${JAVA_HOME}" ]; then
|
||||||
|
if $darwin ; then
|
||||||
|
[ -z "$JAVA_HOME" -a -f "/usr/libexec/java_home" ] && export JAVA_HOME=`/usr/libexec/java_home`
|
||||||
|
[ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
|
||||||
|
[ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
|
||||||
|
else
|
||||||
|
javaExecutable="`which javac`"
|
||||||
|
[ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
|
||||||
|
# readlink(1) is not available as standard on Solaris 10.
|
||||||
|
readLink=`which readlink`
|
||||||
|
[ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
|
||||||
|
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||||
|
JAVA_HOME="$javaHome"
|
||||||
|
export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "${JAVA_HOME}/bin/java" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "======================================================================================================"
|
||||||
|
echo " Please ensure that your JAVA_HOME points to a valid Java SDK."
|
||||||
|
echo " You are currently pointing to:"
|
||||||
|
echo ""
|
||||||
|
echo " ${JAVA_HOME}"
|
||||||
|
echo ""
|
||||||
|
echo " This does not seem to be valid. Please rectify and restart."
|
||||||
|
echo "======================================================================================================"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SPRING_HOME" == "" ]; then
|
||||||
|
SPRING_HOME=`cd "$(dirname $0)"/.. && pwd`
|
||||||
|
fi
|
||||||
|
SPRING_BIN=$(dirname $0)
|
||||||
|
|
||||||
|
TARGETDIR=target/classes
|
||||||
|
if [ -f build.gradle ]; then
|
||||||
|
TARGETDIR=build/classes/main
|
||||||
|
fi
|
||||||
|
mkdir -p "${TARGETDIR%/}"
|
||||||
|
|
||||||
|
CLASSPATH="${SPRING_BIN}":"${TARGETDIR}"
|
||||||
|
|
||||||
|
for f in "${SPRING_HOME}"/lib/*.jar; do
|
||||||
|
CLASSPATH="${CLASSPATH}":$f
|
||||||
|
done
|
||||||
|
|
||||||
|
for f in "${SPRING_HOME}"/*.jar; do
|
||||||
|
CLASSPATH="${CLASSPATH}":$f
|
||||||
|
done
|
||||||
|
|
||||||
|
if $cygwin; then
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
${JAVA_HOME}/bin/java -cp "$CLASSPATH" org.springframework.bootstrap.cli.SpringBootstrapCli $*
|
Loading…
Reference in New Issue