mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-26 05:32:58 +08:00
Update for 0.5.0.M1
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
bin
|
|
||||||
build
|
build
|
||||||
target
|
target
|
||||||
.springBeans
|
.springBeans
|
||||||
|
|||||||
75
app.groovy
75
app.groovy
@@ -1,4 +1,5 @@
|
|||||||
@Grab("org.springframework.zero:spring-actuator:0.5.0.BUILD-SNAPSHOT")
|
package app
|
||||||
|
|
||||||
@Grab("org.codehaus.groovy:groovy-ant:2.1.6")
|
@Grab("org.codehaus.groovy:groovy-ant:2.1.6")
|
||||||
@Grab("org.codehaus.groovy.modules.http-builder:http-builder:0.5.2")
|
@Grab("org.codehaus.groovy.modules.http-builder:http-builder:0.5.2")
|
||||||
@Grab(group='net.sf.json-lib', module='json-lib', version='2.3', classifier='jdk15')
|
@Grab(group='net.sf.json-lib', module='json-lib', version='2.3', classifier='jdk15')
|
||||||
@@ -14,6 +15,9 @@ class MainController {
|
|||||||
@Value('${TMPDIR:.}')
|
@Value('${TMPDIR:.}')
|
||||||
private String tmpdir
|
private String tmpdir
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Reactor reactor
|
||||||
|
|
||||||
private gettingStartedRepos = []
|
private gettingStartedRepos = []
|
||||||
|
|
||||||
@RequestMapping("/")
|
@RequestMapping("/")
|
||||||
@@ -29,12 +33,6 @@ class MainController {
|
|||||||
template "home.html", model
|
template "home.html", model
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/installer")
|
|
||||||
@ResponseBody
|
|
||||||
String installer(@RequestHeader(required=false) String host) {
|
|
||||||
template "installer.sh", [host: host!=null ? host : home]
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping("/spring")
|
@RequestMapping("/spring")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
ResponseEntity<byte[]> spring() {
|
ResponseEntity<byte[]> spring() {
|
||||||
@@ -54,9 +52,12 @@ class MainController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
ResponseEntity<byte[]> spring(PomRequest request) {
|
ResponseEntity<byte[]> spring(PomRequest request) {
|
||||||
|
|
||||||
|
def tempFiles = []
|
||||||
|
|
||||||
def model = [:]
|
def model = [:]
|
||||||
String pom = new String(pom(request, model).body)
|
String pom = new String(pom(request, model).body)
|
||||||
File dir = File.createTempFile("tmp","",new File(tmpdir));
|
File dir = File.createTempFile("tmp","",new File(tmpdir));
|
||||||
|
tempFiles << dir
|
||||||
dir.delete()
|
dir.delete()
|
||||||
dir.mkdirs()
|
dir.mkdirs()
|
||||||
new File(dir, "pom.xml").write(pom)
|
new File(dir, "pom.xml").write(pom)
|
||||||
@@ -65,11 +66,14 @@ class MainController {
|
|||||||
src.mkdirs()
|
src.mkdirs()
|
||||||
|
|
||||||
def body = template "Application.java", model
|
def body = template "Application.java", model
|
||||||
log.info("Creating: " + src + "Application.java")
|
log.info("Creating: " + src + "/Application.java")
|
||||||
new File(src, "Application.java").write(body)
|
new File(src, "Application.java").write(body)
|
||||||
|
|
||||||
File download = new File(tmpdir, dir.name + ".zip")
|
File download = new File(tmpdir, dir.name + ".zip")
|
||||||
log.info("Creating: " + download)
|
log.info("Creating: " + download)
|
||||||
|
tempFiles << download
|
||||||
|
|
||||||
|
reactor.notify("tempfiles", Event.wrap(tempFiles))
|
||||||
|
|
||||||
new AntBuilder().zip(destfile: download) {
|
new AntBuilder().zip(destfile: download) {
|
||||||
zipfileset(dir:dir, includes:"**")
|
zipfileset(dir:dir, includes:"**")
|
||||||
@@ -135,13 +139,60 @@ class MainController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
import org.springframework.actuate.properties.SecurityProperties
|
import reactor.spring.context.ConsumerBeanPostProcessor;
|
||||||
|
@Configuration
|
||||||
|
@EnableReactor
|
||||||
|
class ReactorConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public reactor.core.Environment reactorEnvironment() {
|
||||||
|
return new reactor.core.Environment(); // TODO: use Spring Environment to configure?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Reactor rootReactor() {
|
||||||
|
return reactorEnvironment().getRootReactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Log
|
||||||
|
class TemporaryFileCleaner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
Reactor reactor
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
void init() {
|
||||||
|
reactor.on(Selectors.$("tempfiles"), [
|
||||||
|
accept: {
|
||||||
|
def tempFiles = event.data
|
||||||
|
log.info "Tempfiles: " + tempFiles
|
||||||
|
if (tempFiles) {
|
||||||
|
tempFiles.each {
|
||||||
|
File file = it as File
|
||||||
|
if (file.directory) {
|
||||||
|
file.deleteDir()
|
||||||
|
} else {
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
] as Consumer)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grab("org.springframework.boot:spring-boot-starter-actuator:0.5.0.M1")
|
||||||
|
import org.springframework.boot.ops.properties.SecurityProperties
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
@Configuration
|
@Configuration
|
||||||
@Log
|
@Log
|
||||||
class SecurityConfiguration {
|
class SecurityConfiguration {
|
||||||
|
|
||||||
@Bean(name = "org.springframework.actuate.properties.SecurityProperties")
|
@Bean(name = "org.springframework.boot.ops.properties.SecurityProperties")
|
||||||
SecurityProperties securityProperties() {
|
SecurityProperties securityProperties() {
|
||||||
SecurityProperties security = new SecurityProperties()
|
SecurityProperties security = new SecurityProperties()
|
||||||
security.getBasic().setPath("/gs/**")
|
security.getBasic().setPath("/gs/**")
|
||||||
@@ -165,12 +216,12 @@ class PomRequest {
|
|||||||
def style = []
|
def style = []
|
||||||
|
|
||||||
String name = "demo"
|
String name = "demo"
|
||||||
String description = "Demo project for Spring Zero"
|
String description = "Demo project for Spring Boot"
|
||||||
String groupId = "org.test"
|
String groupId = "org.test"
|
||||||
String artifactId
|
String artifactId
|
||||||
String version = "0.0.1.SNAPSHOT"
|
String version = "0.0.1.SNAPSHOT"
|
||||||
String packageName
|
String packageName
|
||||||
String getName() {
|
String getArtifactId() {
|
||||||
artifactId == null ? name : artifactId
|
artifactId == null ? name : artifactId
|
||||||
}
|
}
|
||||||
String getPackageName() {
|
String getPackageName() {
|
||||||
|
|||||||
20
logback.xml
20
logback.xml
@@ -1,22 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n%wex"/>
|
|
||||||
|
|
||||||
<conversionRule conversionWord="wex" converterClass="org.springframework.bootstrap.logging.logback.WhitespaceThrowableProxyConverter" />
|
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||||
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="CONSOLE" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<logger name="org.springframework.zero" level="DEBUG"/>
|
|
||||||
<logger name="org.springframework.security" level="DEBUG"/>
|
|
||||||
<logger name="sun.net.www.protocol.http.HttpURLConnection" level="TRACE"/>
|
|
||||||
|
|
||||||
|
<logger name="org.springframework" level="DEBUG"/>
|
||||||
|
<logger name="org.springframework.core.env" level="WARN"/>
|
||||||
|
<logger name="org.springframework.jndi" level="WARN"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ applications:
|
|||||||
instances: 1
|
instances: 1
|
||||||
url: initializr.cfapps.io
|
url: initializr.cfapps.io
|
||||||
path: .
|
path: .
|
||||||
command: java -jar ./spring/lib/*.jar run --local app.groovy -- --server.port=$PORT
|
command: java -jar ./spring/lib/*.jar run --cp . --local app.groovy -- --server.port=$PORT
|
||||||
# buildpack: https://github.com/dsyer/cloudfoundry-buildpack-java
|
# buildpack: https://github.com/dsyer/cloudfoundry-buildpack-java
|
||||||
|
|||||||
96
static/install.sh
Normal file
96
static/install.sh
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
# set -x
|
||||||
|
|
||||||
|
VERSION="0.5.0.M1"
|
||||||
|
if [ -z "${PREFIX}" ]; then
|
||||||
|
PREFIX="/usr/local/bin"
|
||||||
|
fi
|
||||||
|
if [ -z "${JAR_FILE}" ]; then
|
||||||
|
JAR_FILE="/tmp/spring.jar"
|
||||||
|
if [ -z "${JAR_URL}" ]; then
|
||||||
|
|
||||||
|
echo "Downloading spring ${VERSION} distribution"
|
||||||
|
echo
|
||||||
|
|
||||||
|
JAR_URL="https://repo.springsource.org/milestone/org/springframework/boot/spring-boot-cli/${VERSION}/spring-boot-cli-${VERSION}.jar"
|
||||||
|
curl --progress-bar --fail "$JAR_URL" -o "$JAR_FILE"
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
trap "echo Installation failed." EXIT
|
||||||
|
|
||||||
|
test -f "${JAR_FILE}"
|
||||||
|
|
||||||
|
SPRING_HOME="${HOME}/.spring"
|
||||||
|
mkdir -p "$SPRING_HOME"
|
||||||
|
cp "$JAR_FILE" "${SPRING_HOME}/spring.jar"
|
||||||
|
cd "${SPRING_HOME}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
rm -rf "${SPRING_HOME}"/spring
|
||||||
|
cat > "${SPRING_HOME}"/spring <<"EOF"
|
||||||
|
#!/bin/sh
|
||||||
|
java -jar ${SPRING_HOME}/spring.jar \$*
|
||||||
|
EOF
|
||||||
|
chmod +x "${SPRING_HOME}/spring"
|
||||||
|
test -x "${SPRING_HOME}/spring"
|
||||||
|
|
||||||
|
echo "spring ${VERSION} has been installed in your home directory (~/.spring)."
|
||||||
|
echo
|
||||||
|
|
||||||
|
if rm -f "$PREFIX/spring" && ln -sf "${SPRING_HOME}/spring" "$PREFIX/spring" >/dev/null 2>&1; then
|
||||||
|
echo
|
||||||
|
echo "Linking ~/.spring/spring to $PREFIX/spring for your convenience."
|
||||||
|
cat <<"EOF"
|
||||||
|
|
||||||
|
To get started:
|
||||||
|
|
||||||
|
$ spring --version
|
||||||
|
$ spring help
|
||||||
|
|
||||||
|
And take a look at the README at https://github.com/springsource/spring-boot#readme.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
elif type sudo >/dev/null 2>&1; then
|
||||||
|
echo "Linking ~/.spring/spring to $PREFIX/spring for your convenience."
|
||||||
|
echo "This may prompt for your password."
|
||||||
|
if sudo rm -f "$PREFIX/spring" && sudo ln -sf "${SPRING_HOME}/spring" "$PREFIX/spring" >/dev/null 2>&1; then
|
||||||
|
cat <<"EOF"
|
||||||
|
|
||||||
|
To get started:
|
||||||
|
|
||||||
|
$ spring --version
|
||||||
|
$ spring help
|
||||||
|
|
||||||
|
And take a look at the README at https://github.com/springsource/spring-boot#readme.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat <<"EOF"
|
||||||
|
Couldn't create the symlink. Please either:
|
||||||
|
(1) Run the following as root:
|
||||||
|
cp ~/.spring/spring /usr/bin/spring
|
||||||
|
(2) Add ~/.spring to your path, or
|
||||||
|
(3) Rerun this command to try again.
|
||||||
|
|
||||||
|
Then to get started, take a look at 'spring help' or see the README at
|
||||||
|
https://github.com/springsource/spring-boot#readme.
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cat <<"EOF"
|
||||||
|
|
||||||
|
Now you need to do one of the following:
|
||||||
|
|
||||||
|
(1) Add ~/.spring to your path, or
|
||||||
|
(2) Run this command as root:
|
||||||
|
cp ~/.spring/spring /usr/bin/spring
|
||||||
|
|
||||||
|
Then to get started, take a look at 'spring help' or see the README at
|
||||||
|
https://github.com/springsource/spring-boot#readme.
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap - EXIT
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -e spring -a ! -d spring ]; then
|
|
||||||
echo "You already have a local file called 'spring' and it's not a directory"
|
|
||||||
echo "Remove it before trying again"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d spring ]; then
|
|
||||||
echo "You already have a local directory called 'spring'. Removing..."
|
|
||||||
rm -rf spring
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Installing Spring in local directory..."
|
|
||||||
|
|
||||||
if [ ! -e spring.zip ]; then
|
|
||||||
wget ${host}/spring.zip
|
|
||||||
else
|
|
||||||
echo "Using locally cached spring.zip"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Unpacking spring.zip"
|
|
||||||
unzip -u spring.zip
|
|
||||||
rm spring.zip
|
|
||||||
|
|
||||||
echo "To use the spring CLI:"
|
|
||||||
echo " export SPRING_HOME="`pwd`/spring
|
|
||||||
echo " export PATH="`pwd`/spring/bin':\$PATH'
|
|
||||||
echo "And (e.g.) 'spring run app.groovy'"
|
|
||||||
Reference in New Issue
Block a user