[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]
This commit is contained in:
parent
8a4b50e289
commit
c91e83c7d2
|
@ -62,7 +62,7 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<id>make-distribution</id>
|
||||
<phase>install</phase>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<id>make-distribution</id>
|
||||
<phase>install</phase>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||
*/
|
||||
public class SpringBootstrapCli {
|
||||
|
||||
public static final String CLI_APP = "spr";
|
||||
public static final String CLI_APP = "spring";
|
||||
|
||||
private static final Set<BootstrapCliException.Option> NO_EXCEPTION_OPTIONS = EnumSet
|
||||
.noneOf(BootstrapCliException.Option.class);
|
||||
|
@ -53,7 +53,7 @@ public class SpringBootstrapCli {
|
|||
*/
|
||||
public SpringBootstrapCli() {
|
||||
setCommands(Arrays.asList(new VersionCommand(), new RunCommand(),
|
||||
new CreateCommand()));
|
||||
new CreateCommand(), new CleanCommand()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,8 +143,8 @@ public class SpringBootstrapCli {
|
|||
}
|
||||
}
|
||||
System.out.println("");
|
||||
System.out
|
||||
.println("See 'spr help <command>' for more information on a specific command.");
|
||||
System.out.println("See '" + CLI_APP
|
||||
+ " help <command>' for more information on a specific command.");
|
||||
}
|
||||
|
||||
protected void errorMessage(String message) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.bootstrap.cli;
|
||||
|
||||
/**
|
||||
* {@link Command} to displat the 'version' number.
|
||||
* {@link Command} to display the 'version' number.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
@ -29,7 +29,8 @@ public class VersionCommand extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
throw new IllegalStateException("Not implemented"); // FIXME
|
||||
// FIXME: add version introspection
|
||||
throw new IllegalStateException("Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 $*
|
|
@ -159,7 +159,7 @@ public class SpringBootstrapCliTests {
|
|||
assertThat(new NoSuchOptionException("name").getMessage(),
|
||||
equalTo("Unknown option: --name"));
|
||||
assertThat(new NoSuchCommandException("name").getMessage(),
|
||||
equalTo("spr: 'name' is not a valid command. See 'spr --help'."));
|
||||
equalTo("spring: 'name' is not a valid command. See 'spring --help'."));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -21,14 +21,10 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>7.0.35</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-logging-juli</artifactId>
|
||||
<version>7.0.35</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
@ -38,10 +34,20 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>8.1.9.v20130131</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jsp</artifactId>
|
||||
<version>8.1.9.v20130131</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
|
Loading…
Reference in New Issue